Line | |
---|
1 | #! /usr/bin/python |
---|
2 | |
---|
3 | """ |
---|
4 | Checks for defer.setDebugging(). |
---|
5 | |
---|
6 | Runs on Python 3. |
---|
7 | |
---|
8 | Usage: ./check-debugging.py src |
---|
9 | """ |
---|
10 | |
---|
11 | |
---|
12 | import sys, re, os |
---|
13 | |
---|
14 | ok = True |
---|
15 | |
---|
16 | for starting_point in sys.argv[1:]: |
---|
17 | for root, dirs, files in os.walk(starting_point): |
---|
18 | for f in files: |
---|
19 | if not f.endswith(".py"): |
---|
20 | continue |
---|
21 | if f == "check-debugging.py": |
---|
22 | continue |
---|
23 | fn = os.path.join(root, f) |
---|
24 | for lineno,line in enumerate(open(fn, "r").readlines()): |
---|
25 | lineno = lineno+1 |
---|
26 | mo = re.search(r"\.setDebugging\(True\)", line) |
---|
27 | if mo: |
---|
28 | print("Do not use defer.setDebugging(True) in production") |
---|
29 | print("First used here: %s:%d" % (fn, lineno)) |
---|
30 | sys.exit(1) |
---|
31 | print("No cases of defer.setDebugging(True) were found, good!") |
---|
32 | sys.exit(0) |
---|
Note: See
TracBrowser
for help on using the repository browser.