[tor-commits] [metrics-tasks/master] Add links to metrics.tpo graphs for every censorship incident.
karsten at torproject.org
karsten at torproject.org
Fri Jun 15 16:41:56 UTC 2012
commit ca2169aa0272ebe08d2e00c52435fabe3f9e25a5
Author: George Kadianakis <desnacked at riseup.net>
Date: Fri Jun 15 17:38:03 2012 +0300
Add links to metrics.tpo graphs for every censorship incident.
---
task-2718/detector.py | 18 ++++++++++++++++--
1 files changed, 16 insertions(+), 2 deletions(-)
diff --git a/task-2718/detector.py b/task-2718/detector.py
index 9fa5584..5cc8bb7 100644
--- a/task-2718/detector.py
+++ b/task-2718/detector.py
@@ -356,6 +356,17 @@ def write_all(tss, minc, maxc, INTERVAL=7):
ranges_file.write("%s,%s,%s,%s\n" % (tss.all_dates[i], c, minv, maxv))
ranges_file.close()
+"""Return a URL that points to a graph in metrics.tpo that displays
+the number of direct Tor users in country 'country_code', for a
+'period'-days period.
+
+Let's hope that the metrics.tpo URL scheme doesn't change often.
+"""
+def get_tor_usage_graph_url_for_cc_and_date(country_code, dates, period):
+ url = "https://metrics.torproject.org/users.html?graph=direct-users&start=%s&end=%s&country=%s&events=on&dpi=72#direct-users\n" % \
+ (dates[-period], dates[-1], country_code)
+ return url
+
"""Write a file containing a short censorship report over the last
'notification_period' days.
"""
@@ -384,12 +395,15 @@ def write_ml_report(tss, minx, maxx, INTERV, DAYS, notification_period=None):
file_prologue_written = True
if ((upscores > 0) and (downscores == 0)):
- s = "We detected an unusual spike of Tor users in %s (%d upscores, %d users).\n" % \
+ s = "We detected an unusual spike of Tor users in %s (%d upscores, %d users):\n" % \
(get_country_name_from_cc(country_code), upscores, users_n)
else:
- s = "We detected %d potential censorship events in %s (users: %d, upscores: %d).\n" % \
+ s = "We detected %d potential censorship events in %s (users: %d, upscores: %d):\n" % \
(downscores, get_country_name_from_cc(country_code), users_n, upscores)
+ # Also give out a link for the appropriate usage graph for a 90-days period.
+ s += get_tor_usage_graph_url_for_cc_and_date(country_code, tss.all_dates, 90)
+
report_file.write(s + "\n")
report_file.close()
More information about the tor-commits
mailing list