diff options
author | Nick Mathewson <nickm@torproject.org> | 2019-07-30 11:54:05 -0400 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2019-07-30 11:54:05 -0400 |
commit | a79e2c2975f478045c1a3a6fdd34d22d355cce8b (patch) | |
tree | 0dcac2cfe718d917e543fc23df56bb3723a03035 /scripts | |
parent | 3f303c102a3adea24d8a3f513c8528eb417d5283 (diff) | |
download | tor-a79e2c2975f478045c1a3a6fdd34d22d355cce8b.tar.gz tor-a79e2c2975f478045c1a3a6fdd34d22d355cce8b.zip |
practracker: better warning/regen handling
Now that there is only one toplevel place where we print problems,
we can redirect just that one print to a file when we are
regenerating the exceptions.txt file. Previously we redirected
sys.stdout, which is naughty, and forced us to send warnings (and
warnings alone) to stderr.
Diffstat (limited to 'scripts')
-rwxr-xr-x | scripts/maint/practracker/practracker.py | 9 | ||||
-rw-r--r-- | scripts/maint/practracker/problem.py | 4 |
2 files changed, 5 insertions, 8 deletions
diff --git a/scripts/maint/practracker/practracker.py b/scripts/maint/practracker/practracker.py index fb6649bdcb..a60b0a8425 100755 --- a/scripts/maint/practracker/practracker.py +++ b/scripts/maint/practracker/practracker.py @@ -192,11 +192,11 @@ def main(argv): if args.regen: tmpname = exceptions_file + ".tmp" tmpfile = open(tmpname, "w") - sys.stdout = tmpfile - sys.stdout.write(HEADER) + problem_file = tmpfile ProblemVault = problem.ProblemVault() else: ProblemVault = problem.ProblemVault(exceptions_file) + problem_file = sys.stdout # 2.1) Adjust the exceptions so that we warn only about small problems, # and produce errors on big ones. @@ -208,10 +208,11 @@ def main(argv): for item in filt.filter(consider_all_metrics(files_list)): status = ProblemVault.register_problem(item) if status == problem.STATUS_ERR: - print(item) + print(item, file=problem_file) found_new_issues += 1 elif status == problem.STATUS_WARN: - item.warn() + # warnings always go to stdout. + print("(warning) {}".format(item)) if args.regen: tmpfile.close() diff --git a/scripts/maint/practracker/problem.py b/scripts/maint/practracker/problem.py index d162e19ef9..d09e941518 100644 --- a/scripts/maint/practracker/problem.py +++ b/scripts/maint/practracker/problem.py @@ -145,10 +145,6 @@ class Item(object): else: return STATUS_OK - def warn(self): - """Warn about this problem on stderr only.""" - print("(warning) {}".format(self), file=sys.stderr) - def key(self): """Generate a unique key that describes this problem that can be used as a dictionary key""" # Item location is a filesystem path, so we need to normalize this |