|
@@ -117,8 +117,8 @@ HEADER="""\
|
|
|
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+
|
|
|
+
|
|
|
|
|
|
|
|
|
|
|
@@ -142,17 +142,30 @@ HEADER="""\
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
|
+
|
|
|
|
|
|
""".format(**globals())
|
|
|
|
|
|
def main(argv):
|
|
|
- if (len(argv) != 2):
|
|
|
- print("Usage:\n\t$ practracker.py <tor topdir>\n\t(e.g. $ practracker.py ~/tor/)")
|
|
|
- return
|
|
|
+ import argparse
|
|
|
+
|
|
|
+ progname = argv[0]
|
|
|
+ parser = argparse.ArgumentParser(prog=progname)
|
|
|
+ parser.add_argument("--regen", action="store_true",
|
|
|
+ help="Regenerate the exceptions file")
|
|
|
+ parser.add_argument("--exceptions",
|
|
|
+ help="Override the location for the exceptions file")
|
|
|
+ parser.add_argument("topdir", default=".", nargs="?",
|
|
|
+ help="Top-level directory for the tor source")
|
|
|
+ args = parser.parse_args(argv[1:])
|
|
|
|
|
|
global TOR_TOPDIR
|
|
|
- TOR_TOPDIR = sys.argv[1]
|
|
|
- exceptions_file = os.path.join(TOR_TOPDIR, "scripts/maint/practracker", EXCEPTIONS_FNAME)
|
|
|
+ TOR_TOPDIR = args.topdir
|
|
|
+ if args.exceptions:
|
|
|
+ exceptions_file = args.exceptions
|
|
|
+ else:
|
|
|
+ exceptions_file = os.path.join(TOR_TOPDIR, "scripts/maint/practracker", EXCEPTIONS_FNAME)
|
|
|
|
|
|
|
|
|
files_list = util.get_tor_c_files(TOR_TOPDIR)
|
|
@@ -160,13 +173,26 @@ def main(argv):
|
|
|
|
|
|
|
|
|
global ProblemVault
|
|
|
- ProblemVault = problem.ProblemVault(exceptions_file)
|
|
|
+
|
|
|
+ if args.regen:
|
|
|
+ tmpname = exceptions_file + ".tmp"
|
|
|
+ tmpfile = open(tmpname, "w")
|
|
|
+ sys.stdout = tmpfile
|
|
|
+ sys.stdout.write(HEADER)
|
|
|
+ ProblemVault = problem.ProblemVault()
|
|
|
+ else:
|
|
|
+ ProblemVault = problem.ProblemVault(exceptions_file)
|
|
|
|
|
|
|
|
|
found_new_issues = consider_all_metrics(files_list)
|
|
|
|
|
|
+ if args.regen:
|
|
|
+ tmpfile.close()
|
|
|
+ os.rename(tmpname, exceptions_file)
|
|
|
+ sys.exit(0)
|
|
|
+
|
|
|
|
|
|
- if (found_new_issues):
|
|
|
+ if found_new_issues and not args.regen:
|
|
|
new_issues_str = """\
|
|
|
FAILURE: practracker found new problems in the code: see warnings above.
|
|
|
|