[tor-commits] [sbws/master] Create generator_started line only when it is known

pastly at torproject.org pastly at torproject.org
Wed Jul 11 15:05:40 UTC 2018


commit de0a46cbf1dba509d68a429f51ac7763d4658bbc
Author: juga0 <juga at riseup.net>
Date:   Mon Jun 25 16:13:25 2018 +0000

    Create generator_started line only when it is known
---
 sbws/lib/v3bwfile.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/sbws/lib/v3bwfile.py b/sbws/lib/v3bwfile.py
index fb9e3d3..1d7ec61 100644
--- a/sbws/lib/v3bwfile.py
+++ b/sbws/lib/v3bwfile.py
@@ -76,14 +76,14 @@ def read_started_ts(conf):
     try:
         filepath = conf['paths']['started_filepath']
     except TypeError:
-        return ''
+        return None
     try:
         with FileLock(filepath):
             with open(filepath, 'r') as fd:
                 generator_started = fd.read()
     except FileNotFoundError as e:
         log.warn('File %s not found.%s', filepath, e)
-        return ''
+        return None
     return generator_started
 
 
@@ -229,7 +229,8 @@ class V3BWHeader(object):
         timestamp = str(latest_bandwidth)
         kwargs['latest_bandwidth'] = unixts_to_isodt_str(latest_bandwidth)
         kwargs['earliest_bandwidth'] = unixts_to_isodt_str(earliest_bandwidth)
-        kwargs['generator_started'] = generator_started
+        if generator_started is not None:
+            kwargs['generator_started'] = generator_started
         h = cls(timestamp, **kwargs)
         return h
 





More information about the tor-commits mailing list