[Git][NTPsec/ntpsec][master] pyntpq checkpoint before tackling a hairball.
Eric S. Raymond
gitlab at mg.gitlab.com
Tue Oct 18 15:17:33 UTC 2016
Eric S. Raymond pushed to branch master at NTPsec / ntpsec
Commits:
d1423b04 by Eric S. Raymond at 2016-10-18T11:15:53-04:00
pyntpq checkpoint before tackling a hairball.
- - - - -
2 changed files:
- ntpq/pyntpq
- pylib/packet.py
Changes:
=====================================
ntpq/pyntpq
=====================================
--- a/ntpq/pyntpq
+++ b/ntpq/pyntpq
@@ -290,14 +290,18 @@ usage: help [ command ]
if len(self.peers) == 0:
if self.chosts:
- sys.stdout.write("server=%s ", self.session.name);
- sys.stdout.write("No association IDs returned\n");
- return False;
+ sys.stdout.write("server=%s ", self.session.name)
+ sys.stdout.write("No association IDs returned\n")
+ return False
if self.debug:
- sys.stderr.write("\n%d associations total\n" % len(self.peers));
- #sortassoc();
- return True;
+ sys.stderr.write("\n%d associations total\n" % len(self.peers))
+ #sortassoc()
+ return True
+
+ def __doprintpeers(self, variables, varlist, associd, af):
+ print(variables)
+ return True
def __dogetpeers(self, varlist, associd, af):
try:
@@ -305,24 +309,29 @@ usage: help [ command ]
except Mode6Exception as e:
print(e.message)
return False
- print(variables)
- return True
+ if not variables:
+ if len(self.chosts) > 1:
+ sys.stderr.write("server=%s ", self.session.name)
+ sys.stderr.write("***No information returned for association %d\n" \
+ % associd)
+ return False;
+ return self.__doprintpeers(variables, varlist, associd, af);
def __dopeers(self, showall, af, varlist):
af = socket.AF_INET6 if "-6" in af else socket.AF_INET
if not self.__dogetassoc():
- return;
+ return
maxhostlen = 0
#for host in self.chosts:
# if getnetnum(chosts[u].name, &netnum, fullname, af):
- # name_or_num = nntohost(&netnum);
- # sl = len(name_or_num);
- # maxhostlen = max(maxhostlen, sl);
+ # name_or_num = nntohost(&netnum)
+ # sl = len(name_or_num)
+ # maxhostlen = max(maxhostlen, sl)
if len(self.chosts) > 1:
- sys.stdout.write("%-*.*s " % (maxhostlen, maxhostlen,
- "server (local)"))
+ sys.stdout.write("%-*.*s " % \
+ (maxhostlen, maxhostlen, "server (local)"))
sys.stdout.write(varlist[0])
- sys.stdout.write(("=" * (maxhostlen + 78)) + "\n");
+ sys.stdout.write(("=" * (maxhostlen + 78)) + "\n")
for peer in self.peers:
if not showall and \
not (CTL_PEER_STATVAL(peer.status)
@@ -331,7 +340,7 @@ usage: help [ command ]
sys.stderr.write(stderr, "eliding [%d]\n" % peer.associd)
continue
if not self.__dogetpeers(varlist[1:], peer.associd, af):
- return;
+ return
# Unexposed helper tables and functions end here
@@ -882,7 +891,7 @@ usage: cv [ assocID ] [ name=value[,...] ]
sys.stderr.write("Unknown associd.\n")
return
self.collect_display(associd=associd,
- variables=pstats, decodestatus=True);
+ variables=pstats, decodestatus=True)
def help_pstats(self):
sys.stdout.write("""\
=====================================
pylib/packet.py
=====================================
--- a/pylib/packet.py
+++ b/pylib/packet.py
@@ -171,7 +171,7 @@ SERR_INCOMPLETE = "***Response from server was incomplete\n"
SERR_TOOMUCH = "***Buffer size exceeded for returned data\n"
SERR_SELECT = "***Select call failed\n"
SERR_NOHOST = "***No host open, use `host' command\n"
-SERR_BADLENGTH = "***Response length shuld have been a multiple of 4"
+SERR_BADLENGTH = "***Response length should have been a multiple of 4"
def dump_hex_printable(xdata):
"Dump a packet in hex, in a familiar hex format"
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/d1423b04f9568709447ca160123c25bf22ee0b13
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ntpsec.org/pipermail/vc/attachments/20161018/414ce0b3/attachment.html>
More information about the vc
mailing list