[Git][NTPsec/ntpsec][ntp.util-codacy] 2 commits: Codacy Python codestyle: follow nits

James Browning gitlab at mg.gitlab.com
Tue Oct 13 17:47:12 UTC 2020



James Browning pushed to branch ntp.util-codacy at NTPsec / ntpsec


Commits:
94d6d405 by James Browning at 2020-10-13T10:36:03-07:00
Codacy Python codestyle: follow nits

- - - - -
ab50348f by James Browning at 2020-10-13T10:45:54-07:00
Codacy Python codestyle: docformatter with a hammer.

- - - - -


8 changed files:

- ntpclients/ntpdig.py
- ntpclients/ntpkeygen.py
- ntpclients/ntploggps.py
- ntpclients/ntplogtemp.py
- ntpclients/ntpmon.py
- ntpclients/ntpq.py
- ntpclients/ntptrace.py
- ntpclients/ntpviz.py


Changes:

=====================================
ntpclients/ntpdig.py
=====================================
@@ -78,7 +78,7 @@ def read_append(s, packets, packet, sockaddr):
 
 
 def queryhost(server, concurrent, timeout=5, port=123):
-    "Query IP addresses associated with a specified host."
+    """Query IP addresses associated with a specified host."""
     try:
         iptuples = socket.getaddrinfo(server, port,
                                       af, socket.SOCK_DGRAM,
@@ -138,7 +138,7 @@ def queryhost(server, concurrent, timeout=5, port=123):
 
 
 def clock_select(packets):
-    "Select the pick-of-the-litter clock from the samples we've got."
+    """Select the pick-of-the-litter clock from the samples we've got."""
     # This is a slightly simplified version of the filter ntpdate used
     NTP_INFIN = 15          # max stratum, infinity a la Bellman-Ford
 
@@ -192,7 +192,7 @@ def clock_select(packets):
 
 
 def report(packet, json):
-    "Report on the SNTP packet selected for display, and its adjustment."
+    """Report on the SNTP packet selected for display, and its adjustment."""
     say = sys.stdout.write
 
     packet.posixize()


=====================================
ntpclients/ntpkeygen.py
=====================================
@@ -57,7 +57,7 @@ KEYSIZE = 16    # maximum key size
 
 
 def gen_keys(ident, groupname):
-    "Generate semi-random AES keys for versions of ntpd with CMAC support."
+    """Generate semi-random AES keys for versions of ntpd with CMAC support."""
     with fheader("AES", ident, groupname) as wp:
         for i in range(1, NUMKEYS+1):
             key = gen_key(KEYSIZE, True)
@@ -74,7 +74,7 @@ def fheader(fileid,     # file name id
             ulink,      # linkname
             owner       # owner name
             ):
-    "Generate file header and link"
+    """Generate file header and link."""
     try:
         filename = "ntpkey_%s_%s.%u" % (fileid, owner, int(time.time()))
         orig_umask = os.umask(stat.S_IWGRP | stat.S_IRWXO)


=====================================
ntpclients/ntploggps.py
=====================================
@@ -46,9 +46,9 @@ except ImportError as e:
 
 
 class logfile_header_class(logging.handlers.TimedRotatingFileHandler):
-    'A class to modify the file logging handler.'
+    """A class to modify the file logging handler."""
     def doRollover(self):
-        'function to add header to new file on rotation.'
+        """function to add header to new file on rotation."""
         if str is bytes:
             super(logfile_header_class, self).doRollover()
         else:
@@ -57,7 +57,7 @@ class logfile_header_class(logging.handlers.TimedRotatingFileHandler):
 
 
 def logging_setup():
-    "Create logging object"
+    """Create logging object."""
     logFormat = logging.Formatter('%(message)s')
     # Create logger for gpsd
     Logger = logging.getLogger()
@@ -170,7 +170,7 @@ class GpsPoller(threading.Thread):
 
     @property
     def time(self):
-        "Return the gpsd time fix"
+        """Return the gpsd time fix."""
         t = self.gpsd.fix.time
         if isinstance(t, int):
             return t


=====================================
ntpclients/ntplogtemp.py
=====================================
@@ -33,9 +33,9 @@ import time
 
 
 class logfile_header_class(logging.handlers.TimedRotatingFileHandler):
-    'A class to modify the file logging handler.'
+    """A class to modify the file logging handler."""
     def doRollover(self):
-        'function to add header to new file on rotation.'
+        """function to add header to new file on rotation."""
         if str is bytes:
             super(logfile_header_class, self).doRollover()
         else:
@@ -44,10 +44,7 @@ class logfile_header_class(logging.handlers.TimedRotatingFileHandler):
 
 
 def run_binary(cmd):
-    """\
-Run a binary
-Return output if good, None if bad
-"""
+    """\ Run a binary Return output if good, None if bad."""
 
     try:
         # sadly subprocess.check_output() is not in Python 2.6
@@ -72,7 +69,7 @@ Return output if good, None if bad
 
 
 class CpuTemp:
-    "Sensors on the CPU Core"
+    """Sensors on the CPU Core."""
     has_sensors = False
 
     def __init__(self):
@@ -85,7 +82,7 @@ class CpuTemp:
         self._pattern = re.compile('^\s+temp\d+_input:\s+([\d\.]+).*$')
 
     def get_data(self):
-        "Collects the data and return the output as an array"
+        """Collects the data and return the output as an array."""
         if not self.has_sensors:
             return None
 
@@ -113,7 +110,7 @@ class CpuTemp:
 
 
 class SmartCtl:
-    "Sensor on the Hard Drive"
+    """Sensor on the Hard Drive."""
     _drives = []
     has_smartctl = False
 
@@ -129,7 +126,7 @@ class SmartCtl:
             self._drives = sorted(self._drives)
 
     def get_data(self):
-        "Collects the data and return the output as an array"
+        """Collects the data and return the output as an array."""
         if not self.has_smartctl:
             return None
 
@@ -150,13 +147,12 @@ class SmartCtl:
 
 
 class Temper:
-    """\
-    Reads 'temper-poll -c' for room temperature data.
+    """\ Reads 'temper-poll -c' for room temperature data.
 
     Before you can use this class you must have a TEMPer USB thermometer
-    plugged in, and the temper-python package must be installed and configured.
-    See their documentation for that procedure.
-"""
+    plugged in, and the temper-python package must be installed and
+    configured. See their documentation for that procedure.
+    """
     has_temper = False
 
     def __init__(self):
@@ -166,7 +162,7 @@ class Temper:
             self.has_temper = True
 
     def get_data(self):
-        "Collects the data and return the output as an array"
+        """Collects the data and return the output as an array."""
         if not self.has_temper:
             return None
 
@@ -194,7 +190,7 @@ class Temper:
 
 
 class ZoneTemp:
-    "Zone sensors"
+    """Zone sensors."""
 
     def __init__(self):
         base_dir = '/sys/class/thermal/thermal_zone?/'
@@ -203,7 +199,7 @@ class ZoneTemp:
             self.zones.append(child)
 
     def get_data(self):
-        "Collects the data and return the output as an array"
+        """Collects the data and return the output as an array."""
         _zone = 0
         _data = []
         for zone in self.zones:
@@ -249,7 +245,7 @@ args = parser.parse_args()
 
 
 def logging_setup():
-    "Create logging object"
+    """Create logging object."""
     logFormat = logging.Formatter('%(message)s')
     # Create logger for cpuTemp
     tempLogger = logging.getLogger()
@@ -275,14 +271,14 @@ def logging_setup():
 
 
 def logData(log, data):
-    "log the data"
+    """log the data."""
     if data is not None:
         for _item in data:
             log.info(_item)
 
 
 def log_data():
-    "Write all temperature readings to one file"
+    """Write all temperature readings to one file."""
     # Create objects
     cpu = CpuTemp()
     zone = ZoneTemp()


=====================================
ntpclients/ntpmon.py
=====================================
@@ -2,8 +2,7 @@
 # -*- coding: utf-8 -*-
 
 # SPDX-License-Identifier: BSD-2-Clause
-'''\
-Any keystroke causes a poll and update. Keystroke commands:
+"""\ Any keystroke causes a poll and update. Keystroke commands:
 
 'a': Change peer display to apeers mode, showing association IDs.
 'd': Toggle detail mode (some peer will be reverse-video highlighted when on).
@@ -23,7 +22,7 @@ Any keystroke causes a poll and update. Keystroke commands:
 '+': Increase debugging level.  Output goes to ntpmon.log
 '-': Decrease debugging level.
 '?': Display helpscreen.
-'''
+"""
 
 from __future__ import print_function, division
 
@@ -71,12 +70,12 @@ stdscr = None
 
 
 def iso8601(t):
-    "ISO8601 string from Unix time."
+    """ISO8601 string from Unix time."""
     return time.strftime("%Y-%m-%dT%H:%M:%S", time.localtime(t))
 
 
 def statline(_peerlist, _mrulist, nyquist):
-    "Generate a status line"
+    """Generate a status line."""
     # We don't use stdversion here because the presence of a date is confusing
     leader = sysvars['version'][0]
     leader = re.sub(r" \([^\)]*\)", "", leader)
@@ -91,7 +90,7 @@ def statline(_peerlist, _mrulist, nyquist):
 
 
 def peer_detail(variables, showunits=False):
-    "Show the things a peer summary doesn't, cooked slightly differently"
+    """Show the things a peer summary doesn't, cooked slightly differently."""
     # All of an rv display except refid, reach, delay, offset, jitter.
     # One of the goals here is to emit field values at fixed positions
     # on the 2D display, so that changes in the details are easier to spot.
@@ -160,7 +159,7 @@ filtdisp   = %(filtdisp)s
 
 
 class Fatal(Exception):
-    "Unrecoverable error."
+    """Unrecoverable error."""
 
     def __init__(self, msg):
         Exception.__init__(self)
@@ -172,7 +171,7 @@ class Fatal(Exception):
 
 class OutputContext:
     def __enter__(self):
-        "Begin critical region."
+        """Begin critical region."""
         if sys.version_info[0] < 3 and not disableunicode:
             # This appears to only be needed under python 2, it is only
             # activated when we already have UTF-8. Otherwise we drop


=====================================
ntpclients/ntpq.py
=====================================
@@ -56,7 +56,7 @@ NTP_FLOAT = 0xa   # Float value
 
 
 class Ntpq(cmd.Cmd):
-    "ntpq command interpreter"
+    """ntpq command interpreter."""
 
     def __init__(self, session):
         cmd.Cmd.__init__(self)
@@ -91,7 +91,7 @@ class Ntpq(cmd.Cmd):
                 for x in dir(self.__class__)]
 
     def emptyline(self):
-        "Called when an empty line is entered in response to the prompt."
+        """Called when an empty line is entered in response to the prompt."""
         pass
 
     def precmd(self, line):
@@ -102,7 +102,8 @@ class Ntpq(cmd.Cmd):
         return line
 
     def default(self, line):
-        "Called on an input line when the command prefix is not recognized."
+        """Called on an input line when the command prefix is not
+        recognized."""
         cmd, arg, line = self.parseline(line)
         try:
             dotext = 'do_'+cmd
@@ -264,7 +265,7 @@ usage: help [ command ]
             pass
 
     def __assoc_valid(self, line, required=False):
-        "Process a numeric associd or index."
+        """Process a numeric associd or index."""
         # FIXME: This does a useless call to __dogetassoc() when associd == 0
         # No big deal most of the time.  Just a useless packet exchange.
         if not line:
@@ -303,7 +304,7 @@ usage: help [ command ]
                 return associd
 
     def __assoc_range_valid(self, line):
-        "Try to get a range of assoc IDs."
+        """Try to get a range of assoc IDs."""
         tokens = line.split()
         if len(tokens) < 2:
             return ()
@@ -316,7 +317,7 @@ usage: help [ command ]
         return range(lo, hi+1)
 
     def printvars(self, variables, dtype, quiet):
-        "Dump variables in raw (actually, semi-cooked) mode."
+        """Dump variables in raw (actually, semi-cooked) mode."""
         if self.rawmode:
             if not quiet:
                 self.say("status=0x%04x,\n" % self.session.rstatus)
@@ -337,7 +338,7 @@ usage: help [ command ]
         self.say(text)
 
     def __dolist(self, varlist, associd, op, type, quiet=False):
-        "List variables associated with a specified peer."
+        """List variables associated with a specified peer."""
         try:
             variables = self.session.readvar(associd, varlist, op, raw=True)
         except ntp.packet.ControlException as e:
@@ -365,7 +366,7 @@ usage: help [ command ]
     # Unexposed helper tables and functions end here
 
     def do_units(self, _unused):
-        "toggle unit display"
+        """toggle unit display."""
         self.showunits = not self.showunits
 
     def help_units(self):
@@ -375,12 +376,12 @@ usage: units
 """)
 
     def do_EOF(self, _unused):
-        "exit ntpq"
+        """exit ntpq."""
         self.say("\n")
         return True
 
     def do_timeout(self, line):
-        "set the primary receive time out"
+        """set the primary receive time out."""
         if line:
             try:
                 self.session.primary_timeout = int(line)
@@ -395,7 +396,7 @@ usage: timeout [ msec ]
 """)
 
     def collect_display(self, associd, variables, decodestatus):
-        "Query and display a collection of variables from the system."
+        """Query and display a collection of variables from the system."""
         try:
             queried = self.session.readvar(associd,
                                            [v[0] for v in variables],
@@ -480,7 +481,7 @@ usage: timeout [ msec ]
             self.warn("display interrupted")
 
     def do_delay(self, line):
-        "set the delay added to encryption time stamps"
+        """set the delay added to encryption time stamps."""
         if not line:
             self.say("delay %d ms\n" % self.auth_delay)
         else:
@@ -498,7 +499,7 @@ usage: delay [ msec ]
 """)
 
     def do_host(self, line):
-        "specify the host whose NTP server we talk to"
+        """specify the host whose NTP server we talk to."""
         if not line:
             if self.session.havehost():
                 self.say("current host is %s\n" % self.session.hostname)
@@ -532,7 +533,7 @@ usage: host [-4|-6] [hostname]
 """)
 
     def do_poll(self, line):
-        "poll an NTP server in client mode `n' times"
+        """poll an NTP server in client mode `n' times."""
         # And it's not in the C version, so we're off the hook here
         self.warn("WARNING: poll not implemented yet")
 
@@ -543,7 +544,7 @@ usage: poll [n] [verbose]
 """)
 
     def do_passwd(self, line):
-        "specify a password to use for authenticated requests"
+        """specify a password to use for authenticated requests."""
         try:
             self.session.password()
         except ntp.packet.ControlException as e:
@@ -558,7 +559,7 @@ usage: passwd []
 """)
 
     def do_hostnames(self, line):
-        "specify whether hostnames or net numbers are printed"
+        """specify whether hostnames or net numbers are printed."""
         if not line:
             pass
         elif line == "yes":
@@ -588,7 +589,7 @@ usage: hostnames [yes|no|hostname|hostnum]
 """)
 
     def do_debug(self, line):
-        "set/change debugging level"
+        """set/change debugging level."""
         if not line:
             pass
         elif line == "more":
@@ -607,8 +608,10 @@ usage: hostnames [yes|no|hostname|hostnum]
         self.say("debug level is %d\n" % 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:
             self.say(repr(self.logfp.name) + "\n")
             return
@@ -631,7 +634,7 @@ usage: debug [no|more|less|n]
 """)
 
     def do_exit(self, line):
-        "exit ntpq"
+        """exit ntpq."""
         return True
 
     def help_exit(self):
@@ -648,7 +651,7 @@ usage: quit
 """)
 
     def do_keyid(self, line):
-        "set keyid to use for authenticated requests"
+        """set keyid to use for authenticated requests."""
         if line:
             try:
                 self.session.keyid = int(line)
@@ -666,7 +669,7 @@ usage: keyid [key#]
 """)
 
     def do_version(self, line):
-        "print version number"
+        """print version number."""
         self.say(version + "\n")
 
     def help_version(self):
@@ -676,7 +679,7 @@ usage: version
 """)
 
     def do_direct(self, line):
-        "toggle direct mode output"
+        """toggle direct mode output."""
         self.directmode = not self.directmode
         if self.directmode:
             self.say("Direct mode is on\n")
@@ -690,7 +693,7 @@ usage: direct
 """)
 
     def do_raw(self, line):
-        "do raw mode variable output"
+        """do raw mode variable output."""
         self.rawmode = True
         self.say("Output set to raw\n")
 
@@ -701,7 +704,7 @@ usage: raw
 """)
 
     def do_cooked(self, line):
-        "do cooked mode variable output"
+        """do cooked mode variable output."""
         self.rawmode = False
         self.say("Output set to cooked\n")
 
@@ -712,7 +715,7 @@ usage: cooked
 """)
 
     def do_authenticate(self, line):
-        "always authenticate requests to this server"
+        """always authenticate requests to this server."""
         if not line:
             pass
         elif line == "yes":
@@ -733,7 +736,7 @@ usage: authenticate [yes|no]
 """)
 
     def do_ntpversion(self, line):
-        "set the NTP version number to use for requests"
+        """set the NTP version number to use for requests."""
         if not line:
             pass
         else:
@@ -757,7 +760,7 @@ usage: ntpversion [version number]
 """)
 
     def do_keytype(self, line):
-        "set key type to use for authenticated requests"
+        """set key type to use for authenticated requests."""
         if not line:
             self.say("Keytype: %s\n" % self.session.keytype)
         elif line.upper() in ['AES', 'AES128CMAC']:
@@ -775,7 +778,8 @@ usage: keytype [digest-name]
 """)
 
     def do_associations(self, line):
-        "print list of association IDs and statuses for the server's peers"
+        """print list of association IDs and statuses for the server's
+        peers."""
         if self.__dogetassoc():
             self.__printassoc(showall=True)
 
@@ -786,7 +790,7 @@ usage: associations
 """)
 
     def do_passociations(self, line):
-        "print list of associations returned by last associations command"
+        """print list of associations returned by last associations command."""
         self.__printassoc(showall=True)
 
     def help_passociations(self):
@@ -796,7 +800,7 @@ usage: passociations
 """)
 
     def do_lassociations(self, line):
-        "print list of associations including all client information"
+        """print list of associations including all client information."""
         if self.__dogetassoc():
             self.__printassoc(showall=True)
 
@@ -807,9 +811,8 @@ usage: lassociations
 """)
 
     def do_lpassociations(self, line):
-        """\
-print last obtained list of associations, including client information
-"""
+        """\ print last obtained list of associations, including client
+        information."""
         self.__printassoc(showall=True)
 
     def help_lpassociations(self):
@@ -820,7 +823,7 @@ usage: lpassociations
 """)
 
     def do_addvars(self, line):
-        "add variables to the variable list or change their values"
+        """add variables to the variable list or change their values."""
         if not line:
             self.warn("usage: addvars name[=value][,...]\n")
             return
@@ -839,7 +842,7 @@ usage: addvars name[=value][,...]
 """)
 
     def do_rmvars(self, line):
-        "remove variables from the variable list"
+        """remove variables from the variable list."""
         if not line:
             self.warn("usage: rmvars name[,...]\n")
             return
@@ -857,7 +860,7 @@ usage: rmvars name[,...]
 """)
 
     def do_clearvars(self, line):
-        "remove all variables from the variable list"
+        """remove all variables from the variable list."""
         self.uservars.clear()
 
     def help_clearvars(self):
@@ -867,7 +870,7 @@ usage: clearvars
 """)
 
     def do_showvars(self, line):
-        "print variables on the variable list"
+        """print variables on the variable list."""
         if not self.uservars:
             self.say("No variables on list.\n")
         for (name, value) in self.uservars.items():
@@ -883,7 +886,7 @@ usage: showvars
 """)
 
     def do_readlist(self, line):
-        "read the system or peer variables included in the variable list"
+        """read the system or peer variables included in the variable list."""
         associd = self.__assoc_valid(line)
         if associd >= 0:
             qtype = ntp.ntpc.TYPE_SYS if associd == 0 else ntp.ntpc.TYPE_PEER
@@ -897,7 +900,7 @@ usage: readlist [assocID]
 """)
 
     def do_rl(self, line):
-        "read the system or peer variables included in the variable list"
+        """read the system or peer variables included in the variable list."""
         self.do_readlist(line)
 
     def help_rl(self):
@@ -907,7 +910,7 @@ usage: rl [assocID]
 """)
 
     def do_writelist(self, line):
-        "write the system or peer variables included in the variable list"
+        """write the system or peer variables included in the variable list."""
         pass
 
     def help_writelist(self):
@@ -917,7 +920,7 @@ usage: writelist [ assocID ]
 """)
 
     def do_readvar(self, line):
-        "read system or peer variables"
+        """read system or peer variables."""
         associd = self.__assoc_valid(line)
         if associd >= 0:
             qtype = ntp.ntpc.TYPE_SYS if associd == 0 else ntp.ntpc.TYPE_PEER
@@ -931,7 +934,7 @@ usage: readvar [assocID] [varname1] [varname2] [varname3]
 """)
 
     def do_rv(self, line):
-        "read system or peer variables"
+        """read system or peer variables."""
         self.do_readvar(line)
 
     def help_rv(self):
@@ -941,7 +944,7 @@ usage: rv [assocID] [varname1] [varname2] [varname3]
 """)
 
     def do_writevar(self, line):
-        "write system or peer variables"
+        """write system or peer variables."""
         pass
 
     def help_writevar(self):
@@ -951,7 +954,7 @@ usage: writevar assocID name=value,[...]
 """)
 
     def do_mreadlist(self, line):
-        "read the peer variables in the variable list for multiple peers"
+        """read the peer variables in the variable list for multiple peers."""
         if not line:
             self.warn("usage: mreadlist assocIDlow assocIDhigh\n")
             return
@@ -973,7 +976,7 @@ usage: mreadlist assocIDlow assocIDhigh
 """)
 
     def do_mrl(self, line):
-        "read the peer variables in the variable list for multiple peers"
+        """read the peer variables in the variable list for multiple peers."""
         if not line:
             self.warn("usage: mrl assocIDlow assocIDhigh")
             return
@@ -986,7 +989,7 @@ usage: mrl assocIDlow assocIDhigh
 """)
 
     def do_mreadvar(self, line):
-        "read peer variables from multiple peers"
+        """read peer variables from multiple peers."""
         if not line:
             self.warn("usage: mreadvar assocIDlow assocIDhigh  "
                       "[ name=value[,...] ]")
@@ -1010,7 +1013,7 @@ usage: mreadvar assocIDlow assocIDhigh [name=value[,...]]
 """)
 
     def do_mrv(self, line):
-        "read peer variables from multiple peers"
+        """read peer variables from multiple peers."""
         if not line:
             self.warn(
                 "usage: mrv assocIDlow assocIDhigh [name=value[,...]]")
@@ -1024,7 +1027,7 @@ usage: mrv assocIDlow assocIDhigh [name=value[,...]]
 """)
 
     def do_clocklist(self, line):
-        "read the clock variables included in the variable list"
+        """read the clock variables included in the variable list."""
         assoc = self.__assoc_valid(line)
         if assoc >= 0:
             self.__dolist(self.uservars.keys(),
@@ -1038,7 +1041,7 @@ usage: clocklist [assocID]
 """)
 
     def do_cl(self, line):
-        "read the clock variables included in the variable list"
+        """read the clock variables included in the variable list."""
         self.do_clocklist(line)
 
     def help_cl(self):
@@ -1048,7 +1051,7 @@ usage: cl [assocID]
 """)
 
     def do_clockvar(self, line):
-        "read clock variables"
+        """read clock variables."""
         assoc = self.__assoc_valid(line)
         if assoc == 0:
             self.warn("This command requires the association ID of a clock.")
@@ -1063,7 +1066,7 @@ usage: clockvar [assocID] [name=value[,...]]
 """)
 
     def do_cv(self, line):
-        "read clock variables"
+        """read clock variables."""
         self.do_clockvar(line)
 
     def help_cv(self):
@@ -1073,7 +1076,7 @@ usage: cv [ assocID ] [ name=value[,...] ]
 """)
 
     def do_pstats(self, line):
-        "show statistics for a peer"
+        """show statistics for a peer."""
         pstats = (
             ("srcadr", "remote host:          ", NTP_ADD),
             ("dstadr", "local address:        ", NTP_ADD),
@@ -1105,7 +1108,7 @@ usage: pstats assocID
 """)
 
     def do_peers(self, line):
-        "obtain and print a list of the server's peers [IP version]"
+        """obtain and print a list of the server's peers [IP version]"""
         self.__dopeers(showall=True, mode="peers")
 
     def help_peers(self):
@@ -1115,9 +1118,8 @@ usage: peers
 """)
 
     def do_apeers(self, line):
-        """
-obtain and print a list of the server's peers and their assocIDs [IP version]
-"""
+        """obtain and print a list of the server's peers and their assocIDs [IP
+        version]"""
         self.__dopeers(showall=True, mode="apeers")
 
     def help_apeers(self):
@@ -1128,7 +1130,7 @@ usage: apeers
 """)
 
     def do_lpeers(self, line):
-        "obtain and print a list of all peers and clients [IP version]"
+        """obtain and print a list of all peers and clients [IP version]"""
         self.__dopeers(showall=True, mode="peers")
 
     def help_lpeers(self):
@@ -1138,9 +1140,8 @@ usage: lpeers
 """)
 
     def do_opeers(self, line):
-        """
-print peer list the old way, with dstadr shown rather than refid [IP version]
-"""
+        """print peer list the old way, with dstadr shown rather than refid [IP
+        version]"""
         self.__dopeers(showall=True, mode="opeers")
 
     def help_opeers(self):
@@ -1151,8 +1152,8 @@ usage: opeers
 """)
 
     def do_lopeers(self, line):
-        """obtain and print a list of all peers and clients showing
-        dstadr [IP version]"""
+        """obtain and print a list of all peers and clients showing dstadr [IP
+        version]"""
         self.__dopeers(showall=True, mode="opeers")
 
     def help_lopeers(self):
@@ -1163,7 +1164,7 @@ usage: lopeers
 """)
 
     def do_hot_config(self, line):
-        "send a remote configuration command to ntpd"
+        """send a remote configuration command to ntpd."""
         try:
             self.session.password()
         except ntp.packet.ControlException as e:
@@ -1198,7 +1199,7 @@ usage: config <configuration command line>
 """)
 
     def do_config_from_file(self, line):
-        "configure ntpd using the configuration filename"
+        """configure ntpd using the configuration filename."""
         try:
             with open(line) as rfp:
                 self.say("%s\n" % self.session.config(rfp.read()))
@@ -1229,9 +1230,9 @@ usage: noflake
     def do_doflake(self, line):
         """Drop some received packets for testing.
 
-        Probabilities 0 and 1 should be certainly accepted
-        and discarded respectively. No default, but 0.1
-        should be a one in ten loss rate.
+        Probabilities 0 and 1 should be certainly accepted and discarded
+        respectively. No default, but 0.1 should be a one in ten loss
+        rate.
         """
         try:
             _ = float(line)
@@ -1252,8 +1253,11 @@ usage: doflake <probability>
 """)
 
     def do_mrulist(self, line):
-        """display the list of most recently seen source addresses,
-           tags mincount=... resall=0x... resany=0x..."""
+        """display the list of most recently seen source addresses, tags
+        mincount=...
+
+        resall=0x... resany=0x...
+        """
         cmdvars = {}
         for item in line.split(" "):
             if not item:
@@ -1340,7 +1344,7 @@ usage: mrulist [tag=value] [tag=value] [tag=value] [tag=value]
 """)
 
     def do_ifstats(self, line):
-        "show statistics for each local address ntpd is using"
+        """show statistics for each local address ntpd is using."""
         try:
             self.session.password()
             entries = self.session.ifstats()
@@ -1365,7 +1369,7 @@ usage: ifstats
 """)
 
     def do_reslist(self, line):
-        "show ntpd access control list"
+        """show ntpd access control list."""
         try:
             self.session.password()
             entries = self.session.reslist()
@@ -1392,7 +1396,7 @@ usage: reslist
 # FIXME: This table should move to ntpd
 #          so the answers track when ntpd is updated
     def do_sysinfo(self, _line):
-        "display system summary"
+        """display system summary."""
         sysinfo = (
             ("peeradr", "system peer:      ", NTP_ADP),
             ("peermode", "system peer mode: ", NTP_MODE),
@@ -1420,7 +1424,7 @@ usage: sysinfo
 # FIXME: This table should move to ntpd
 #          so the answers track when ntpd is updated
     def do_kerninfo(self, _line):
-        "display kernel loop and PPS statistics"
+        """display kernel loop and PPS statistics."""
         kerninfo = (
             ("koffset", "pll offset:          ", NTP_FLOAT),
             ("kfreq", "pll frequency:       ", NTP_FLOAT),
@@ -1450,7 +1454,7 @@ usage: kerninfo
 # FIXME: This table should move to ntpd
 #          so the answers track when ntpd is updated
     def do_sysstats(self, _line):
-        "display system uptime and packet counts"
+        """display system uptime and packet counts."""
         sysstats = (
             ("ss_uptime", "uptime:               ", NTP_INT),
             ("ss_reset", "sysstats reset:       ", NTP_INT),
@@ -1477,7 +1481,7 @@ usage: sysstats
 # FIXME: This table should move to ntpd
 #          so the answers track when ntpd is updated
     def do_monstats(self, _line):
-        "display monitor (mrulist) counters and limits"
+        """display monitor (mrulist) counters and limits."""
         monstats = (
             ("mru_enabled",     "enabled:              ", NTP_INT),
             ("mru_hashslots",   "hash slots in use:    ", NTP_INT),
@@ -1507,7 +1511,7 @@ usage: monstats
 # FIXME: This table should move to ntpd
 #          so the answers track when ntpd is updated
     def do_authinfo(self, _line):
-        "display symmetric authentication counters"
+        """display symmetric authentication counters."""
         authinfo = (
             ("authreset",          "time since reset:    ", NTP_INT),
             ("authkeys",           "stored keys:         ", NTP_INT),
@@ -1538,7 +1542,7 @@ usage: authinfo
 # FIXME: This table should move to ntpd
 #          so the answers track when ntpd is updated
     def do_ntsinfo(self, _line):
-        "display NTS authentication counters"
+        """display NTS authentication counters."""
         ntsinfo = (
    ("nts_client_send",           "NTS client sends:          ", NTP_INT),
    ("nts_client_recv_good",      "NTS client recvs good:     ", NTP_INT),
@@ -1568,7 +1572,7 @@ usage: ntsinfo
 # FIXME: This table should move to ntpd
 #          so the answers track when ntpd is updated
     def do_iostats(self, _line):
-        "display network input and output counters"
+        """display network input and output counters."""
         iostats = (
             ("iostats_reset", "time since reset:     ", NTP_INT),
             ("total_rbuf", "receive buffers:      ", NTP_INT),
@@ -1594,7 +1598,7 @@ usage: iostats
 # FIXME: This table should move to ntpd
 #          so the answers track when ntpd is updated
     def do_timerstats(self, line):
-        "display interval timer counters"
+        """display interval timer counters."""
         timerstats = (
             ("timerstats_reset", "time since reset:  ", NTP_INT),
             ("timer_overruns", "timer overruns:    ", NTP_INT),


=====================================
ntpclients/ntptrace.py
=====================================
@@ -31,7 +31,7 @@ except ImportError as e:
 def get_info(host):
     info3 = ntp_read_vars(0, [], host)
     if info3 is None or 'stratum' not in info3:
-        return Nonw
+        return None
 
     info3['offset'] = round(float(info3['offset']) / 1000, 6)
     info3['syncdistance'] = \


=====================================
ntpclients/ntpviz.py
=====================================
@@ -69,7 +69,7 @@ if sys.version_info[0] == 2:
     sys.setdefaultencoding('utf8')
 
     def open(file, mode='r', buffering=-1, encoding=None, errors=None):
-        "Redefine open()"
+        """Redefine open()"""
         return(codecs.open(filename=file, mode=mode, encoding=encoding,
                errors=errors, buffering=buffering))
 
@@ -103,7 +103,7 @@ refclock_name = {'127.127.20.0': 'NMEA(0)',
 # Gack, python before 3.2 has no defined tzinfo for utc...
 # define our own
 class UTC(datetime.tzinfo):
-    """UTC"""
+    """UTC."""
 
     def utcoffset(self, dt):
         return datetime.timedelta(0)
@@ -132,10 +132,10 @@ if (3 > sys.version_info[0]) and (7 > sys.version_info[1]):
 
 # overload ArgumentParser
 class MyArgumentParser(argparse.ArgumentParser):
-    "class to parse arguments"
+    """class to parse arguments."""
 
     def convert_arg_line_to_args(self, arg_line):
-        '''Make options file more tolerant'''
+        """Make options file more tolerant."""
         # strip out trailing comments
         arg_line = re.sub('\s+#.*$', '', arg_line)
 
@@ -150,7 +150,7 @@ class MyArgumentParser(argparse.ArgumentParser):
 
 
 def print_profile():
-    """called by atexit() on normal exit to print profile data"""
+    """called by atexit() on normal exit to print profile data."""
     pr.disable()
     pr.print_stats('tottime')
     pr.print_stats('cumtime')
@@ -164,7 +164,7 @@ def print_profile():
 #   Mean, Variance, Standard Deviation, Skewness and Kurtosis
 
 class RunningStats(object):
-    "Calculate mean, variance, sigma, skewness and kurtosis"
+    """Calculate mean, variance, sigma, skewness and kurtosis."""
 
     def __init__(self, values):
         self.num = len(values)     # number of samples
@@ -202,7 +202,7 @@ class RunningStats(object):
 
 # class for calced values
 class VizStats(ntp.statfiles.NTPStats):
-    "Class for calculated values"
+    """Class for calculated values."""
 
     percs = {}          # dictionary of percentages
     title = ''          # title
@@ -373,7 +373,7 @@ class VizStats(ntp.statfiles.NTPStats):
 
 
 def gnuplot_fmt(min_val, max_val):
-    "return optimal gnuplot format"
+    """return optimal gnuplot format."""
     span = max_val - min_val
     if 6 <= span:
         fmt = '%.0f'
@@ -392,7 +392,7 @@ def gnuplot_fmt(min_val, max_val):
 # Investigate.
 
 def gnuplot(template, outfile=None):
-    "Run a specified gnuplot program."
+    """Run a specified gnuplot program."""
 
     if not template:
         # silently ignore empty plots
@@ -444,7 +444,7 @@ def gnuplot(template, outfile=None):
 
 
 class NTPViz(ntp.statfiles.NTPStats):
-    "Class for visualizing statistics from a single server."
+    """Class for visualizing statistics from a single server."""
 
     # Python takes single quotes here. Since no % substitution
     Common = """\
@@ -468,7 +468,7 @@ set rmargin 10
                                         endtime=endtime)
 
     def plot_slice(self, rows, item1, item2=None):
-        "slice 0,item1, maybe item2, from rows, ready for gnuplot"
+        """slice 0,item1, maybe item2, from rows, ready for gnuplot."""
         # speed up by only sending gnuplot the data it will actually use
         # WARNING: this is hot code, only modify if you profile
         # since we are looping the data, get the values too
@@ -515,7 +515,7 @@ set rmargin 10
         return (plot_data, values1)
 
     def local_offset_gnuplot(self):
-        "Generate gnuplot code graphing local clock loop statistics"
+        """Generate gnuplot code graphing local clock loop statistics."""
         if not self.loopstats:
             sys.stderr.write("ntpviz: WARNING: no loopstats to graph\n")
             return ''
@@ -578,7 +578,7 @@ file.</p>
         return ret
 
     def local_freq_temps_plot(self):
-        "Generate gnuplot code graphing local frequency and temps"
+        """Generate gnuplot code graphing local frequency and temps."""
         if not self.loopstats:
             sys.stderr.write("ntpviz: WARNING: no loopstats to graph\n")
             return ''
@@ -671,7 +671,7 @@ file, and field 3 from the tempstats log file.</p>
         return ret
 
     def local_temps_gnuplot(self):
-        "Generate gnuplot code graphing local temperature statistics"
+        """Generate gnuplot code graphing local temperature statistics."""
         sitename = self.sitename
         tempsmap = self.tempssplit()
         tempslist = list(tempsmap.keys())
@@ -733,7 +733,7 @@ component of frequency drift.</p>
         return ret
 
     def local_gps_gnuplot(self):
-        "Generate gnuplot code graphing local GPS statistics"
+        """Generate gnuplot code graphing local GPS statistics."""
         sitename = self.sitename
         gpsmap = self.gpssplit()
         gpslist = list(gpsmap.keys())
@@ -793,7 +793,7 @@ plot \\
             plot_template += """\
 '-' using 1:2 title '%s TDOP' with line ls 1, \\
 '-' using 1:3 title '%s nSat' with line ls 2 axis x1y2, \\
-""" % (key,key)
+""" % (key, key)
 
         # strip the trailing ", \\n"
         plot_template = plot_template[:-4] + "\n"
@@ -816,7 +816,7 @@ impossible.</p>
         return ret
 
     def local_error_gnuplot(self):
-        "Plot the local clock frequency error."
+        """Plot the local clock frequency error."""
         if not self.loopstats:
             sys.stderr.write("ntpviz: WARNING: no loopstats to graph\n")
             return ''
@@ -875,7 +875,7 @@ line at 0ppm.  Expected values of 99%-1% percentiles: 0.4ppm</p>
         return ret
 
     def loopstats_gnuplot(self, fld, title, legend, freq):
-        "Generate gnuplot code of a given loopstats field"
+        """Generate gnuplot code of a given loopstats field."""
         if not self.loopstats:
             sys.stderr.write("ntpviz: WARNING: no loopstats to graph\n")
             return ''
@@ -943,16 +943,16 @@ plot \
         return ret
 
     def local_offset_jitter_gnuplot(self):
-        "Generate gnuplot code of local clock loop standard deviation"
+        """Generate gnuplot code of local clock loop standard deviation."""
         return self.loopstats_gnuplot(4, "Local RMS Time Jitter", "Jitter", 0)
 
     def local_offset_stability_gnuplot(self):
-        "Generate gnuplot code graphing local clock stability"
+        """Generate gnuplot code graphing local clock stability."""
         return self.loopstats_gnuplot(5, "Local RMS Frequency Jitter",
                                       "Stability", 1)
 
     def peerstats_gnuplot(self, peerlist, fld, title, ptype):
-        "Plot a specified field from peerstats."
+        """Plot a specified field from peerstats."""
 
         peerdict = self.peersplit()
         if not peerlist:
@@ -1167,17 +1167,17 @@ plot \
         return ret
 
     def peer_offsets_gnuplot(self, peerlist=None):
-        "gnuplot Peer Offsets"
+        """gnuplot Peer Offsets."""
         return self.peerstats_gnuplot(peerlist, 4, "Server Offset",
                                       "offset")
 
     def peer_jitters_gnuplot(self, peerlist=None):
-        "gnuplot Peer Jitters"
+        """gnuplot Peer Jitters."""
         return self.peerstats_gnuplot(peerlist, 7, "Server Jitter",
                                       "jitter")
 
     def local_offset_histogram_gnuplot(self):
-        "Plot a histogram of clock offset values from loopstats."
+        """Plot a histogram of clock offset values from loopstats."""
         if not self.loopstats:
             sys.stderr.write("ntpviz: WARNING: no loopstats to graph\n")
             return ''
@@ -1286,7 +1286,7 @@ plot \
 
 
 def local_offset_multiplot(statlist):
-    "Plot comparative local offsets for a list of NTPViz objects."
+    """Plot comparative local offsets for a list of NTPViz objects."""
 
     out = {}
     out['size'] = args.img_size



View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/370091348d88b5b51c75772dfd73c1efb0a3d932...ab50348f8eb2cdb3dc3afc30ec5be96a812e7433

-- 
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/compare/370091348d88b5b51c75772dfd73c1efb0a3d932...ab50348f8eb2cdb3dc3afc30ec5be96a812e7433
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/20201013/ff947018/attachment-0001.htm>


More information about the vc mailing list