[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
[tor-commits] [sbws/master] Rm bwfile link when writting the file
commit c6a1ace87fb682d03cb7e695b2457ecdebd42a3b
Author: juga0 <juga@xxxxxxxxxx>
Date: Thu Oct 18 21:55:53 2018 +0000
Rm bwfile link when writting the file
---
sbws/lib/v3bwfile.py | 15 +++++++++++++--
1 file changed, 13 insertions(+), 2 deletions(-)
diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py
index 83df447..1ada69e 100644
--- a/sbws/lib/v3bwfile.py
+++ b/sbws/lib/v3bwfile.py
@@ -462,7 +462,7 @@ class V3BWFile(object):
torflow_cap=TORFLOW_BW_MARGIN,
torflow_round_digs=TORFLOW_ROUND_DIG,
secs_recent=None, secs_away=None, min_num=0,
- reverse=False):
+ consensus_path=None, reverse=False):
"""Create V3BWFile class from sbws Results.
:param dict results: see below
@@ -500,6 +500,14 @@ class V3BWFile(object):
bw_lines = cls.bw_torflow_scale(bw_lines_raw, torflow_obs,
torflow_cap, torflow_round_digs)
# log.debug(bw_lines[-1])
+ if consensus_path is not None:
+ statsd, success = cls.measured_progress_stats(bw_lines,
+ consensus_path)
+ # add statistics about progress only when there are not enough
+ # measured relays. Should some stats be added always?
+ if not success:
+ header.add_stats(**statsd)
+ bw_lines = []
else:
bw_lines = cls.bw_kb(bw_lines_raw)
# log.debug(bw_lines[-1])
@@ -887,10 +895,13 @@ class V3BWFile(object):
except FileNotFoundError:
pass
- def write(self, output):
+ def write(self, output, rm_link=False):
if output == '/dev/stdout':
log.info("Writing to stdout is not supported.")
return
+ if not self.is_min_perc and rm_link:
+ self.rm_link(output)
+ return
log.info('Writing v3bw file to %s', output)
# To avoid inconsistent reads, the bandwidth data is written to an
# archive path, then atomically symlinked to 'latest.v3bw'
_______________________________________________
tor-commits mailing list
tor-commits@xxxxxxxxxxxxxxxxxxxx
https://lists.torproject.org/cgi-bin/mailman/listinfo/tor-commits