[Git][NTPsec/ntpsec][wip-ntpq-peers-display] Added partial unit display for ntpq 'rv' command.

Ian Bruene gitlab at mg.gitlab.com
Sun Mar 26 18:15:48 UTC 2017


Ian Bruene pushed to branch wip-ntpq-peers-display at NTPsec / ntpsec


Commits:
b4ba91cf by Ian Bruene at 2017-03-26T12:55:54-05:00
Added partial unit display for ntpq 'rv' command.

This does not display units for unit/s variables yet, and there may still be
a few other missing variables.

- - - - -


2 changed files:

- ntpclients/ntpq
- pylib/util.py


Changes:

=====================================
ntpclients/ntpq
=====================================
--- a/ntpclients/ntpq
+++ b/ntpclients/ntpq
@@ -406,7 +406,7 @@ usage: help [ command ]
                 self.say("status=%04x %s,\n"
                          % (self.session.rstatus,
                             ntp.ntpc.statustoa(dtype, self.session.rstatus)))
-            text = ntp.util.cook(variables)
+            text = ntp.util.cook(variables, self.showunits)
         text = text.replace("'", '"')
         self.say(text)
 


=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -285,7 +285,7 @@ class PeerStatusWord:
                 % self.__dict__)
 
 
-def cook(variables):
+def cook(variables, showunits=False):
     "Cooked-mode variable display."
     width = ntp.util.termsize().width - 2
     text = ""
@@ -331,6 +331,15 @@ def cook(variables):
                     if (1 << i) & value:
                         item += tstflagnames[i] + " "
                 item = item[:-1]
+        elif name in ("rootdelay", "rootdisp", "offset", "sys_jitter",
+                      "clk_jitter", "leapsmearoffset", "authdelay",
+                      "koffset", "kmaxerr", "kesterr", "kprecis",
+                      "kppsjitter", "fuzz", "clk_wander_threshold",
+                      "tick"):
+            if showunits:
+                item += f8unit(value, UNIT_MS, True)
+            else:
+                item += repr(value)
         else:
             item += repr(value)
         item += ", "



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/b4ba91cf9cb9aeed91ad8761b1e0db94708782f2
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.ntpsec.org/pipermail/vc/attachments/20170326/5c9150d6/attachment.html>


More information about the vc mailing list