[tor-commits] [sbws/master] new: v3bwfile: Set relays exclusion KeyValues
juga at torproject.org
juga at torproject.org
Thu Mar 21 18:30:42 UTC 2019
commit 5fd38798a8070818d0b521b56b5ca50943af4ca7
Author: juga0 <juga at riseup.net>
Date: Tue Mar 12 10:53:08 2019 +0000
new: v3bwfile: Set relays exclusion KeyValues
Part of #28565.
---
sbws/lib/v3bwfile.py | 15 +++++++++++++++
1 file changed, 15 insertions(+)
diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py
index 411d324..2c1e745 100644
--- a/sbws/lib/v3bwfile.py
+++ b/sbws/lib/v3bwfile.py
@@ -438,6 +438,11 @@ class V3BWHeader(object):
[setattr(self, k, str(v)) for k, v in kwargs.items()
if k in STATS_KEYVALUES]
+ def add_relays_excluded_counters(self, exclusion_dict):
+ log.debug("Adding relays excluded counters.")
+ for k, v in exclusion_dict.items():
+ setattr(self, k, str(v))
+
class V3BWLine(object):
"""
@@ -761,12 +766,22 @@ class V3BWFile(object):
number_consensus_relays = cls.read_number_consensus_relays(
consensus_path)
state = State(state_fpath)
+
+ # Initiliaze exclusion counts dictionary with 0
+ exclusion_dict = dict(
+ [(k, 0) for k in BW_HEADER_KEYVALUES_RECENT_MEASUREMENTS_EXCLUDED]
+ )
for fp, values in results.items():
# log.debug("Relay fp %s", fp)
line, reason = V3BWLine.from_results(values, secs_recent,
secs_away, min_num)
if line is not None:
bw_lines_raw.append(line)
+ else:
+ exclusion_dict[reason] = exclusion_dict.get(reason, 0) + 1
+ # Add the headers with the number of excluded relays by reason
+ header.add_relays_excluded_counters(exclusion_dict)
+
if not bw_lines_raw:
log.info("After applying restrictions to the raw results, "
"there is not any. Scaling can not be applied.")
More information about the tor-commits
mailing list