[tor-commits] [doctor/master] Adding a flag for local development
atagar at torproject.org
atagar at torproject.org
Wed Jun 18 16:58:02 UTC 2014
commit 2678b1549a3489f6de8babd962dd49c67aa1fadd
Author: Damian Johnson <atagar at torproject.org>
Date: Wed Jun 18 09:48:07 2014 -0700
Adding a flag for local development
whenever I work on the consensus tracker I replace the email sending
functionality with print statements. Adding a flag that does it to make this
simpler.
---
consensus_health_checker.py | 20 ++++++++++++++++----
1 file changed, 16 insertions(+), 4 deletions(-)
diff --git a/consensus_health_checker.py b/consensus_health_checker.py
index f80be87..cc2b4ab 100755
--- a/consensus_health_checker.py
+++ b/consensus_health_checker.py
@@ -20,6 +20,10 @@ import stem.util.enum
from stem import Flag
from stem.util.lru_cache import lru_cache
+# Set this flag to print results rather than email them.
+
+TEST_RUN = False
+
Runlevel = stem.util.enum.UppercaseEnum("NOTICE", "WARNING", "ERROR")
DIRECTORY_AUTHORITIES = stem.descriptor.remote.get_authorities()
@@ -169,11 +173,15 @@ def main():
if not is_all_suppressed:
log.debug("Sending notification for issues")
- util.send(EMAIL_SUBJECT, body_text = '\n'.join(map(str, issues)))
- # notification for #tor-bots
+ if TEST_RUN:
+ print '\n'.join(map(str, issues))
+ else:
+ util.send(EMAIL_SUBJECT, body_text = '\n'.join(map(str, issues)))
+
+ # notification for #tor-bots
- util.send('Announce or', body_text = '\n'.join(['[consensus-health] %s' % issue for issue in issues]), destination = 'tor-misc at commit.noreply.org')
+ util.send('Announce or', body_text = '\n'.join(['[consensus-health] %s' % issue for issue in issues]), destination = 'tor-misc at commit.noreply.org')
else:
if issues:
log.info("All %i issues were suppressed. Not sending a notification." % len(issues))
@@ -615,4 +623,8 @@ if __name__ == '__main__':
except:
msg = "consensus_health_checker.py failed with:\n\n%s" % traceback.format_exc()
log.error(msg)
- util.send("Script Error", body_text = msg, destination = util.ERROR_ADDRESS)
+
+ if TEST_RUN:
+ print "Error: %s" % msg
+ else:
+ util.send("Script Error", body_text = msg, destination = util.ERROR_ADDRESS)
More information about the tor-commits
mailing list