source: trunk/misc/coding_tools/check-debugging.py

Last change on this file was b856238, checked in by Alexandre Detiste <alexandre.detiste@…>, at 2024-02-15T15:53:34Z

remove old Python2 future statements

  • Property mode set to 100755
File size: 870 bytes
Line 
1#! /usr/bin/python
2
3"""
4Checks for defer.setDebugging().
5
6Runs on Python 3.
7
8Usage: ./check-debugging.py src
9"""
10
11
12import sys, re, os
13
14ok = True
15
16for 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)
31print("No cases of defer.setDebugging(True) were found, good!")
32sys.exit(0)
Note: See TracBrowser for help on using the repository browser.