[Git][NTPsec/ntpsec][master] ntpviz: Fix for PEP8, adjust index header for days or hours.

Gary E. Miller gitlab at mg.gitlab.com
Wed Jun 20 22:20:12 UTC 2018


Gary E. Miller pushed to branch master at NTPsec / ntpsec


Commits:
af1c2c2b by Gary E. Miller at 2018-06-20T22:07:27Z
ntpviz: Fix for PEP8, adjust index header for days or hours.

Some people want to run 3 hour reports, then this looks better.

- - - - -


1 changed file:

- ntpclients/ntpviz.py


Changes:

=====================================
ntpclients/ntpviz.py
=====================================
@@ -65,8 +65,8 @@ if sys.version_info[0] == 2:
     sys.setdefaultencoding('utf8')
 
     def open(file, mode='r', buffering=-1, encoding=None, errors=None):
-        return codecs.open(filename=file, mode=mode, encoding=encoding,
-            errors=errors, buffering=buffering)
+        return(codecs.open(filename=file, mode=mode, encoding=encoding,
+               errors=errors, buffering=buffering))
 
 # believe it or not, Python has no way to make a simple constant!
 MS_PER_S = 1e3          # milliseconds per second
@@ -1719,9 +1719,15 @@ dd {
         index_header += '<b>Start Time:</b> %s UTC<br>\n' \
                         '<b>End Time:</b> %s UTC<br>\n' \
             % (start_time, end_time)
-        index_header += '<b>Report Period:</b> %1.1f days <br>\n' \
-            % (float(stats.period) /
-                float(ntp.statfiles.NTPStats.SecondsInDay))
+        if (1 > stats.period):
+            # less than a day, report hours
+            index_header += ('<b>Report Period:</b> %1.1f hours <br>\n' %
+                             (float(stats.period) / (24 * 60)))
+        else:
+            # more than a day, report days
+            index_header += ('<b>Report Period:</b> %1.1f days <br>\n' %
+                             (float(stats.period) /
+                              ntp.statfiles.NTPStats.SecondsInDay))
 
     if args.clip:
         index_header += """\



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/af1c2c2bf3fe42d225f17c68975a421742e54abb

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/af1c2c2bf3fe42d225f17c68975a421742e54abb
You're receiving this email because of your account on gitlab.com.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20180620/9c58481c/attachment.html>


More information about the vc mailing list