[Git][NTPsec/ntpsec][wip-ntpq-peers-display] Fixes for f8unit and docs.
Ian Bruene
gitlab at mg.gitlab.com
Mon Mar 27 18:51:15 UTC 2017
Ian Bruene pushed to branch wip-ntpq-peers-display at NTPsec / ntpsec
Commits:
f6744ec3 by Ian Bruene at 2017-03-27T13:50:40-05:00
Fixes for f8unit and docs.
- - - - -
2 changed files:
- docs/includes/ntpmon-body.txt
- pylib/util.py
Changes:
=====================================
docs/includes/ntpmon-body.txt
=====================================
--- a/docs/includes/ntpmon-body.txt
+++ b/docs/includes/ntpmon-body.txt
@@ -65,7 +65,7 @@ q:: Cleanly terminate the program.
s:: Toggle display of only reachable hosts (default is all hosts).
-u:: Toggle display of units for time values.
+u:: Toggle display of units for time values. (default is off)
w:: Toggle wide mode.
=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -102,16 +102,17 @@ def f8unit(f, startingunit, strip=False):
unitget = startingunit + unitsmoved
if (0 <= unitget < len(UNITS)):
unit = UNITS[unitget]
- if abs(f).is_integer():
+ af = abs(f)
+ if af.is_integer():
rendered = ("%6d" % f) + unit
- elif abs(f) >= 100.0: # xxx.xx
+ elif af >= 100.0: # xxx.xx
rendered = ("%6.2f" % f) + unit
- elif abs(f) >= 10.0: # xx.xxx
+ elif af >= 10.0: # xx.xxx
rendered = ("%6.3f" % f) + unit
- elif abs(f) >= 1.0: # x.xxxx
+ elif af >= 1.0: # x.xxxx
rendered = ("%6.4f" % f) + unit
else: # zero, if it weren't then scaleforunit would have moved it up
- rendered = "0ns" # This is *simple*, and asking for trouble
+ rendered = "0ns"
else: # Out of units so revert to the original. Ugly but there are very
rendered = repr(oldf) + UNITS[startingunit] # few options here.
if strip:
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/f6744ec36bebb409cb9d63d9e24590636f80640b
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170327/651197ca/attachment.html>
More information about the vc
mailing list