[Git][NTPsec/ntpsec][master] 6 commits: test variables['refid'] exists before using
Gary E. Miller
gitlab at mg.gitlab.com
Tue Aug 8 21:36:04 UTC 2017
Gary E. Miller pushed to branch master at NTPsec / ntpsec
Commits:
e34ddf30 by Gary E. Miller at 2017-08-08T14:09:58-07:00
test variables['refid'] exists before using
- - - - -
5523d495 by Gary E. Miller at 2017-08-08T14:17:33-07:00
ntpmon: pep8 tweaks
- - - - -
bbcce02d by Gary E. Miller at 2017-08-08T14:18:57-07:00
ntpq: sort imports
- - - - -
0711e860 by Gary E. Miller at 2017-08-08T14:31:20-07:00
ntpq: pep8 cleanup
- - - - -
60a4c848 by Gary E. Miller at 2017-08-08T14:33:17-07:00
ntpdig: fix pep8 nit
- - - - -
3cce9ac5 by Gary E. Miller at 2017-08-08T14:34:18-07:00
ntpkeygen: fix pep8 nit
- - - - -
4 changed files:
- ntpclients/ntpdig
- ntpclients/ntpkeygen
- ntpclients/ntpmon
- ntpclients/ntpq
Changes:
=====================================
ntpclients/ntpdig
=====================================
--- a/ntpclients/ntpdig
+++ b/ntpclients/ntpdig
@@ -432,7 +432,8 @@ if __name__ == '__main__':
print("rec-org t21: %f xmt-dst t34: %f"
% (pkt.t2() - pkt.t1(), pkt.t3() - pkt.t4()))
offset = pkt.adjust()
- adjusted = step and (not slew or (slew and (abs(offset) > steplimit)))
+ adjusted = (step and
+ (not slew or (slew and (abs(offset) > steplimit))))
report(pkt, json)
# If we can step but we cannot slew, then step.
# If we can step or slew and |offset| > steplimit, then step.
=====================================
ntpclients/ntpkeygen
=====================================
--- a/ntpclients/ntpkeygen
+++ b/ntpclients/ntpkeygen
@@ -56,7 +56,7 @@ def gen_md5(id, groupname):
def fheader(file, # file name id
ulink, # linkname
owner # owner name
- ):
+ ):
try:
filename = "ntpkey_%s_%s.%u" % (file, owner, int(time.time()))
orig_umask = os.umask(stat.S_IWGRP | stat.S_IRWXO)
=====================================
ntpclients/ntpmon
=====================================
--- a/ntpclients/ntpmon
+++ b/ntpclients/ntpmon
@@ -129,7 +129,8 @@ srcadr=%(srcadr)s, srcport=%(srcport)d, dstadr=%(dstadr)s, dstport=%(dstport)s
leap=%(leap)s\treftime=%(reftime)s\trootdelay=%(rootdelay)s
stratum=%(stratum)2d\trec=%(rec)s\trootdisp=%(rootdisp)s
precision=%(precision)3d\txmt=%(xmt)s\tdispersion=%(dispersion)s
-unreach=%(unreach)d, hmode=%(hmode)d, pmode=%(pmode)d, hpoll=%(hpoll)d, ppoll=%(ppoll)d, headway=%(headway)s, flash=%(flash)s, keyid=%(keyid)s
+unreach=%(unreach)d, hmode=%(hmode)d, pmode=%(pmode)d, hpoll=%(hpoll)d, \
+ppoll=%(ppoll)d, headway=%(headway)s, flash=%(flash)s, keyid=%(keyid)s
filtdelay = %(filtdelay)s
filtoffset = %(filtoffset)s
filtdisp = %(filtdisp)s
@@ -243,11 +244,10 @@ if __name__ == '__main__':
try:
initphase = False
for (i, peer) in enumerate(peers):
- if (not showall
- and not (
- ntp.control.CTL_PEER_STATVAL(peer.status)
- & (ntp.control.CTL_PST_CONFIG |
- ntp.control.CTL_PST_REACH))):
+ if (not showall and not (
+ ntp.control.CTL_PEER_STATVAL(peer.status) &
+ (ntp.control.CTL_PST_CONFIG |
+ ntp.control.CTL_PST_REACH))):
continue
try:
variables = session.readvar(peer.associd,
@@ -271,7 +271,8 @@ if __name__ == '__main__':
peer.associd)
data = unicode(data).encode('UTF-8')
stdscr.addstr(data, hilite)
- if 'INIT' in variables['refid']:
+ if (('refid' in variables and
+ 'INIT' in variables['refid'])):
initphase = True
# Now the MRU report
=====================================
ntpclients/ntpq
=====================================
--- a/ntpclients/ntpq
+++ b/ntpclients/ntpq
@@ -12,22 +12,22 @@
# SPDX-License-Identifier: BSD-2-clause
from __future__ import print_function, division
-import os
-import sys
-import getopt
import cmd
+import getopt
+import hashlib
+import os
import re
import resource
-import time
import socket
-import hashlib
+import sys
+import time
try:
+ import ntp.control
+ import ntp.ntpc
import ntp.packet
import ntp.util
- import ntp.ntpc
import ntp.version
- import ntp.control
except ImportError as e:
sys.stderr.write(
"ntpq: can't find Python NTP library -- check PYTHONPATH.\n")
@@ -278,9 +278,9 @@ usage: help [ command ]
"===========================================================\n")
for (i, peer) in enumerate(self.peers):
statval = ntp.control.CTL_PEER_STATVAL(peer.status)
- if ((not showall
- and (statval & (ntp.control.CTL_PST_CONFIG
- | ntp.control.CTL_PST_REACH)) == 0)):
+ if ((not showall and
+ (statval & (ntp.control.CTL_PST_CONFIG |
+ ntp.control.CTL_PST_REACH)) == 0)):
continue
sw = ntp.util.PeerStatusWord(peer.status)
display = "%3d %5u %04x %3.3s %4s %4.4s %9.9s %11s %2lu" \
@@ -311,10 +311,10 @@ usage: help [ command ]
self.say("=" * (maxhostlen + 1))
self.say(("=" * report.width()) + "\n")
for peer in self.peers:
- if ((not showall
- and not (ntp.control.CTL_PEER_STATVAL(peer.status)
- & (ntp.control.CTL_PST_CONFIG
- | ntp.control.CTL_PST_REACH)))):
+ if ((not showall and
+ not (ntp.control.CTL_PEER_STATVAL(peer.status) &
+ (ntp.control.CTL_PST_CONFIG |
+ ntp.control.CTL_PST_REACH)))):
if self.debug:
self.warn("eliding [%d]\n" % peer.associd)
continue
@@ -372,8 +372,8 @@ usage: help [ command ]
except:
self.warn("Invalid associd literal.\n")
return -1
- if ((associd != 0
- and associd not in [peer.associd for peer in self.peers])):
+ if ((associd != 0 and
+ associd not in [peer.associd for peer in self.peers])):
self.warn("Unknown associd.\n")
return -1
else:
@@ -589,8 +589,8 @@ usage: delay [ msec ]
session.ai_family = socket.AF_INET6
tokens.pop(0)
try:
- if ((tokens
- and self.session.openhost(tokens[0], session.ai_family))):
+ if ((tokens and
+ self.session.openhost(tokens[0], session.ai_family))):
print("current host set to %s" % self.session.hostname)
elif self.session.havehost():
print("current host remains %s" % self.session.hostname)
@@ -670,7 +670,8 @@ usage: hostnames [yes|no]
print("debug level is %d" % self.debug)
def do_logfile(self, line):
- "view/change logfile. \"<stderr>\" will log to stderr instead of a file"
+ """view/change logfile. \"<stderr>\" will log to stderr
+ instead of a file"""
if not line:
print(repr(self.logfp.name))
return
@@ -801,8 +802,8 @@ usage: authenticate [yes|no]
else:
try:
newversion = int(line)
- if ((newversion >= ntp.magic.NTP_OLDVERSION
- and newversion <= ntp.magic.NTP_VERSION)):
+ if ((newversion >= ntp.magic.NTP_OLDVERSION and
+ newversion <= ntp.magic.NTP_VERSION)):
self.pktversion = newversion
else:
print("versions %d to %d, please"
@@ -1701,10 +1702,10 @@ if __name__ == '__main__':
if len(arguments) == 0:
interpreter.chosts.append((DEFHOST, session.ai_family))
- if ((len(interpreter.ccmds) == 0
- and not interpreter.interactive
- and os.isatty(0)
- and os.isatty(1)
+ if ((len(interpreter.ccmds) == 0 and
+ not interpreter.interactive and
+ os.isatty(0) and
+ os.isatty(1)
)):
interpreter.interactive = True
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/6b8b487063901604a9f4cdab557bb9d28a45950e...3cce9ac5d23373d0b169f2e002f2d98beaae4ee0
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/compare/6b8b487063901604a9f4cdab557bb9d28a45950e...3cce9ac5d23373d0b169f2e002f2d98beaae4ee0
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/20170808/b845ef5c/attachment.html>
More information about the vc
mailing list