[Git][NTPsec/ntpsec][master] 2 commits: Make cv and firiends use the terminal width.
Eric S. Raymond
gitlab at mg.gitlab.com
Sun Nov 27 12:24:36 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
1248f3c8 by Achim Gratz at 2016-11-27T07:04:50-05:00
Make cv and firiends use the terminal width.
- - - - -
6a30402a by Eric S. Raymond at 2016-11-27T07:22:57-05:00
Fix a bug intrpduced in "Make cv and firiends use the terminal width."...
...and clean up some imports.
- - - - -
2 changed files:
- ntpq/ntpq
- pylib/util.py
Changes:
=====================================
ntpq/ntpq
=====================================
--- a/ntpq/ntpq
+++ b/ntpq/ntpq
@@ -443,7 +443,7 @@ usage: help [ command ]
lastcount = 0
else:
lastcount += 1
- if lastcount + len(item) > 78:
+ if lastcount + len(item) > ntp.util.termsize()[1] - 2:
text = text[:-1] + "\n"
text += item
text = text[:-2] + "\n"
=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -6,14 +6,16 @@ from __future__ import print_function
import socket
import sys
import time
-import ntp.ntpc
import re
-from ntp.packet import *
-from ntp.version import *
+import ntp.ntpc
+import ntp.version
+import ntp.ntp_magic
+import ntp.ntp_control
def stdversion():
- return "%s-%s-%s %s" % (VERSION, VCS_TICK, VCS_BASENAME, VCS_DATE)
+ return "%s-%s-%s %s" % (ntp.version.VERSION, ntp.version.VCS_TICK,
+ ntp.version.VCS_BASENAME, ntp.version.VCS_DATE)
def rfc3339(t):
"RFC3339 string from Unix time, including fractional second."
@@ -181,11 +183,11 @@ class PeerSummary:
elif name == "hpoll":
hpoll = value
if hpoll < 0:
- hpoll = NTP_MINPOLL
+ hpoll = ntp.ntp_magic.NTP_MINPOLL
elif name == "ppoll":
ppoll = value
if ppoll < 0:
- ppoll = NTP_MINPOLL
+ ppoll = ntp.ntp_magic.NTP_MINPOLL
elif name == "reach":
# Shipped as hex, displayed in octal
reach = value
@@ -205,16 +207,16 @@ class PeerSummary:
srcport = value
elif name == "reftime":
reftime = value # l_fp timestamp
- if hmode == MODE_BCLIENT:
+ if hmode == ntp.ntp_magic.MODE_BCLIENT:
# broadcastclient or multicastclient
ptype = 'b'
- elif hmode == MODE_BROADCAST:
+ elif hmode == ntp.ntp_magic.MODE_BROADCAST:
# broadcast or multicast server
if srcadr.startswith("224."): # IANA multicast address prefix
ptype = 'M'
else:
ptype = 'B'
- elif hmode == MODE_CLIENT:
+ elif hmode == ntp.ntp_magic.MODE_CLIENT:
if srchost and '(' in srchost:
ptype = 'l' # local refclock
elif dstadr_refid == "POOL":
@@ -223,9 +225,9 @@ class PeerSummary:
ptype = 'a' # manycastclient
else:
ptype = 'u' # unicast
- elif hmode == MODE_ACTIVE:
+ elif hmode == ntp.ntp_magic.MODE_ACTIVE:
ptype = 's' # symmetric active
- elif hmode == MODE_PASSIVE:
+ elif hmode == ntp.ntp_magic.MODE_PASSIVE:
ptype = 'S' # symmetric passive
#
@@ -233,10 +235,10 @@ class PeerSummary:
#
line = ""
poll_sec = 1 << min(ppoll, hpoll)
- if self.pktversion > NTP_OLDVERSION:
- c = " x.-+#*o"[CTL_PEER_STATVAL(rstatus) & 0x7]
+ if self.pktversion > ntp.ntp_magic.NTP_OLDVERSION:
+ c = " x.-+#*o"[ntp.ntp_control.CTL_PEER_STATVAL(rstatus) & 0x7]
else:
- c = " .+*"[CTL_PEER_STATVAL(rstatus) & 0x3]
+ c = " .+*"[ntp.ntp_control.CTL_PEER_STATVAL(rstatus) & 0x3]
# Source host or clockname
if srchost != None:
clock_name = srchost
@@ -309,9 +311,9 @@ class MRUSummary:
stats += " %6d" % avgint
else:
stats += " %6.2f" % favgint
- if entry.rs & RES_KOD:
+ if entry.rs & ntp.ntp_magic.RES_KOD:
rscode = 'K'
- elif entry.rs & RES_LIMITED:
+ elif entry.rs & ntp.ntp_magic.RES_LIMITED:
rscode = 'L'
else:
rscode = '.'
@@ -321,7 +323,8 @@ class MRUSummary:
dns = canonicalize_dns(dns)
stats += " %4hx %c %d %d %6d %5s %s" % \
(entry.rs, rscode,
- PKT_MODE(entry.mv), PKT_VERSION(entry.mv),
+ ntp.ntp_magic.PKT_MODE(entry.mv),
+ ntp.ntp_magic.PKT_VERSION(entry.mv),
entry.ct, port[1:], dns)
return stats
except TypeError:
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/c233afea21be10a23316aecb9d5c8771d5746ac1...6a30402a55fa56d578994c5a781971eee675ce57
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161127/4bde34f9/attachment.html>
More information about the vc
mailing list