[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[tor-commits] [sbws/master] Write bw file only when there is a min percentage



commit 544936cd81abf4de58c84ad4d490fa3ff0e96064
Author: juga0 <juga@xxxxxxxxxx>
Date:   Tue Oct 16 15:01:30 2018 +0000

    Write bw file only when there is a min percentage
---
 sbws/core/generate.py | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/sbws/core/generate.py b/sbws/core/generate.py
index 6a6226b..885569a 100644
--- a/sbws/core/generate.py
+++ b/sbws/core/generate.py
@@ -1,7 +1,7 @@
 from sbws.globals import (fail_hard, SBWS_SCALE_CONSTANT, TORFLOW_SCALING,
                           SBWS_SCALING, TORFLOW_BW_MARGIN, TORFLOW_ROUND_DIG,
                           DAY_SECS, NUM_MIN_RESULTS)
-from sbws.lib.v3bwfile import V3BWFile
+from sbws.lib.v3bwfile import V3BWFile, is_min_percent_measured
 from sbws.lib.resultdump import load_recent_results_in_datadir
 from argparse import ArgumentDefaultsHelpFormatter
 import os
@@ -99,7 +99,14 @@ def main(args, conf):
                                     secs_recent=args.secs_recent,
                                     secs_away=args.secs_away,
                                     min_num=args.min_num)
+
     output = args.output or \
         conf.getpath('paths', 'v3bw_fname').format(now_fname())
-    bw_file.write(output)
+    # Check percentage of measured relays.
+    consensus_path = os.path.join(conf.getpath('tor', 'datadir'),
+                                  "cached-consensus")
+    if is_min_percent_measured(consensus_path):
+        bw_file.write(output)
+    else:
+        bw_file.rm_link(output)
     bw_file.info_stats



_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits