[tor-commits] [metrics-tasks/master] Skip consensuses that don't contain consensus weights (#6232).

karsten at torproject.org karsten at torproject.org
Tue Jul 24 10:11:21 UTC 2012


commit f5a5bad9dac005e416e09a97e4512ac7bf0a667f
Author: Karsten Loesing <karsten.loesing at gmx.net>
Date:   Tue Jul 24 10:57:10 2012 +0200

    Skip consensuses that don't contain consensus weights (#6232).
---
 task-6232/pyentropy.py |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/task-6232/pyentropy.py b/task-6232/pyentropy.py
index 8e28210..e6d3214 100644
--- a/task-6232/pyentropy.py
+++ b/task-6232/pyentropy.py
@@ -116,6 +116,8 @@ def run(file_name):
     guards_no, exits_no = 0, 0
     bw_countries, bw_as = {}, {}
     for router in routers:
+        if not router.bandwidth:
+            continue
         total_bw += router.bandwidth
         if router.is_guard and router.is_exit:
             total_guard_bw += Wgd*router.bandwidth
@@ -137,6 +139,9 @@ def run(file_name):
         else:
             bw_as[router.as_no] = router.bandwidth
     
+    if total_bw == 0:
+        return
+
     entropy, entropy_exit, entropy_guard, entropy_country, entropy_as = 0.0, 0.0, 0.0, 0.0, 0.0
     for router in routers:
         p = float(router.bandwidth) / float(total_bw)



More information about the tor-commits mailing list