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

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



commit de0a46cbf1dba509d68a429f51ac7763d4658bbc
Author: juga0 <juga@xxxxxxxxxx>
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
 



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