2016-04-06 23:57:41 +00:00
|
|
|
#! /usr/bin/python
|
|
|
|
|
|
|
|
# ./check-debugging.py src
|
|
|
|
|
2019-03-22 10:40:58 +00:00
|
|
|
from __future__ import print_function
|
|
|
|
|
2016-04-06 23:57:41 +00:00
|
|
|
import sys, re, os
|
|
|
|
|
|
|
|
ok = True
|
|
|
|
umids = {}
|
|
|
|
|
|
|
|
for starting_point in sys.argv[1:]:
|
|
|
|
for root, dirs, files in os.walk(starting_point):
|
2020-11-27 21:28:23 +00:00
|
|
|
for f in files:
|
|
|
|
if not f.endswith(".py"):
|
|
|
|
continue
|
|
|
|
if f == "check-debugging.py":
|
|
|
|
continue
|
|
|
|
fn = os.path.join(root, f)
|
2016-04-06 23:57:41 +00:00
|
|
|
for lineno,line in enumerate(open(fn, "r").readlines()):
|
|
|
|
lineno = lineno+1
|
|
|
|
mo = re.search(r"\.setDebugging\(True\)", line)
|
|
|
|
if mo:
|
2019-03-22 10:40:58 +00:00
|
|
|
print("Do not use defer.setDebugging(True) in production")
|
|
|
|
print("First used here: %s:%d" % (fn, lineno))
|
2016-04-06 23:57:41 +00:00
|
|
|
sys.exit(1)
|
2019-03-22 10:40:58 +00:00
|
|
|
print("No cases of defer.setDebugging(True) were found, good!")
|
2016-04-06 23:57:41 +00:00
|
|
|
sys.exit(0)
|