[Git][NTPsec/ntpsec][ntp.util-codacy] Codacy Python codestyle: autopep8 with a hammer.
James Browning
gitlab at mg.gitlab.com
Tue Oct 13 17:52:05 UTC 2020
James Browning pushed to branch ntp.util-codacy at NTPsec / ntpsec
Commits:
3e0cf7bf by James Browning at 2020-10-13T10:49:14-07:00
Codacy Python codestyle: autopep8 with a hammer.
- - - - -
6 changed files:
- ntpclients/ntpdig.py
- ntpclients/ntpkeygen.py
- ntpclients/ntploggps.py
- ntpclients/ntplogtemp.py
- ntpclients/ntpq.py
- ntpclients/ntpviz.py
Changes:
=====================================
ntpclients/ntpdig.py
=====================================
@@ -289,7 +289,7 @@ if __name__ == '__main__':
progname = sys.argv[0]
logfp = sys.stderr
- log = lambda m: logfp.write("ntpdig: %s\n" % m)
+ def log(m): return logfp.write("ntpdig: %s\n" % m)
af = socket.AF_UNSPEC
authkey = None
=====================================
ntpclients/ntpkeygen.py
=====================================
@@ -29,6 +29,7 @@ import stat
try:
import secrets
+
def gen_key(bytes, asciified=True):
if asciified:
result = ''
@@ -39,6 +40,7 @@ try:
return secrets.token_hex(bytes)
except ImportError:
import random
+
def gen_key(bytes, asciified=True):
result = ''
if asciified:
=====================================
ntpclients/ntploggps.py
=====================================
@@ -47,6 +47,7 @@ except ImportError as e:
class logfile_header_class(logging.handlers.TimedRotatingFileHandler):
"""A class to modify the file logging handler."""
+
def doRollover(self):
"""function to add header to new file on rotation."""
if str is bytes:
=====================================
ntpclients/ntplogtemp.py
=====================================
@@ -34,6 +34,7 @@ import time
class logfile_header_class(logging.handlers.TimedRotatingFileHandler):
"""A class to modify the file logging handler."""
+
def doRollover(self):
"""function to add header to new file on rotation."""
if str is bytes:
=====================================
ntpclients/ntpq.py
=====================================
@@ -1282,9 +1282,9 @@ usage: doflake <probability>
self.say("Ctrl-C will stop MRU retrieval and display "
"partial results.\n")
if self.rawmode:
- mruhook = lambda v: self.printvars(variables=v,
- dtype=ntp.ntpc.TYPE_SYS,
- quiet=True)
+ def mruhook(v): return self.printvars(variables=v,
+ dtype=ntp.ntpc.TYPE_SYS,
+ quiet=True)
else:
mruhook = None
try:
@@ -1544,22 +1544,22 @@ usage: authinfo
def do_ntsinfo(self, _line):
"""display NTS authentication counters."""
ntsinfo = (
- ("nts_client_send", "NTS client sends: ", NTP_INT),
- ("nts_client_recv_good", "NTS client recvs good: ", NTP_INT),
- ("nts_client_recv_bad", "NTS client recvs w error: ", NTP_INT),
- ("nts_server_recv_good", "NTS server recvs good: ", NTP_INT),
- ("nts_server_recv_bad", "NTS server recvs w error: ", NTP_INT),
- ("nts_server_send", "NTS server sends: ", NTP_INT),
- ("nts_cookie_make", "NTS make cookies: ", NTP_INT),
- ("nts_cookie_decode", "NTS decode cookies: ", NTP_INT),
- ("nts_cookie_decode_old", "NTS decode cookies old: ", NTP_INT),
- ("nts_cookie_decode_too_old", "NTS decode cookies too old:", NTP_INT),
- ("nts_cookie_decode_error", "NTS decode cookies error: ", NTP_INT),
- ("nts_ke_probes_good", "NTS KE probes good: ", NTP_INT),
- ("nts_ke_probes_bad", "NTS KE probes_bad: ", NTP_INT),
- ("nts_ke_serves_good", "NTS KE serves good: ", NTP_INT),
- ("nts_ke_serves_bad", "NTS KE serves_bad: ", NTP_INT),
- )
+ ("nts_client_send", "NTS client sends: ", NTP_INT),
+ ("nts_client_recv_good", "NTS client recvs good: ", NTP_INT),
+ ("nts_client_recv_bad", "NTS client recvs w error: ", NTP_INT),
+ ("nts_server_recv_good", "NTS server recvs good: ", NTP_INT),
+ ("nts_server_recv_bad", "NTS server recvs w error: ", NTP_INT),
+ ("nts_server_send", "NTS server sends: ", NTP_INT),
+ ("nts_cookie_make", "NTS make cookies: ", NTP_INT),
+ ("nts_cookie_decode", "NTS decode cookies: ", NTP_INT),
+ ("nts_cookie_decode_old", "NTS decode cookies old: ", NTP_INT),
+ ("nts_cookie_decode_too_old", "NTS decode cookies too old:", NTP_INT),
+ ("nts_cookie_decode_error", "NTS decode cookies error: ", NTP_INT),
+ ("nts_ke_probes_good", "NTS KE probes good: ", NTP_INT),
+ ("nts_ke_probes_bad", "NTS KE probes_bad: ", NTP_INT),
+ ("nts_ke_serves_good", "NTS KE serves good: ", NTP_INT),
+ ("nts_ke_serves_bad", "NTS KE serves_bad: ", NTP_INT),
+ )
self.collect_display(associd=0, variables=ntsinfo, decodestatus=False)
def help_ntsinfo(self):
@@ -1571,6 +1571,8 @@ 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."""
iostats = (
=====================================
ntpclients/ntpviz.py
=====================================
@@ -71,7 +71,7 @@ if sys.version_info[0] == 2:
def open(file, mode='r', buffering=-1, encoding=None, errors=None):
"""Redefine open()"""
return(codecs.open(filename=file, mode=mode, encoding=encoding,
- errors=errors, buffering=buffering))
+ errors=errors, buffering=buffering))
# believe it or not, Python has no way to make a simple constant!
MS_PER_S = 1e3 # milliseconds per second
@@ -1546,7 +1546,7 @@ Python by ESR, concept and gnuplot code by Dan Drown.
'pngcairo': '.png',
'png': '.png',
'svg': '.svg',
- }
+ }
if args.terminal in term_map:
args.img_ext = term_map[args.terminal]
else:
@@ -1987,7 +1987,7 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
index_buffer += "<div>\n%s</div>\n" % image['html']
index_buffer += "<br><br>\n"
gnuplot(image['plot'], os.path.join(args.outdir,
- imagename + args.img_ext))
+ imagename + args.img_ext))
index_buffer += "</div>\n"
# dump stats
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/3e0cf7bfe543b600c6e1d5fbf59342dd1020d6ff
--
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/-/commit/3e0cf7bfe543b600c6e1d5fbf59342dd1020d6ff
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/b6d93fc1/attachment-0001.htm>
More information about the vc
mailing list