Commits (7)
......@@ -57,4 +57,3 @@ for line in lines:
temp = match.group(1)
sys.stdout.write( '%d LM%d %s\n' % (now, index, temp))
index += 1
......@@ -72,4 +72,3 @@ for line in lines:
if match and match.group(1):
temp = match.group(1)
sys.stdout.write( '%d SMART %s\n' % (now, temp))
......@@ -79,14 +79,14 @@ extern const uint32_t tstoushi[128];
#define sTVTOTS(tv, ts) \
do { \
int isneg = 0; \
bool isneg = false; \
long usec; \
(ts)->l_ui = (tv)->tv_sec; \
usec = (tv)->tv_usec; \
if (((tv)->tv_sec < 0) || ((tv)->tv_usec < 0)) { \
usec = -usec; \
(ts)->l_ui = -(ts)->l_ui; \
isneg = 1; \
isneg = true; \
} \
TVUTOTSF(usec, (ts)->l_uf); \
if (isneg) { \
......
......@@ -37,12 +37,12 @@ atolfp(
register unsigned long dec_f;
char *ind;
int ndec;
int isneg;
bool isneg;
static const char *digits = "0123456789";
NTP_REQUIRE(str != NULL);
isneg = 0;
isneg = false;
dec_i = dec_f = 0;
ndec = 0;
cp = str;
......@@ -57,7 +57,7 @@ atolfp(
if (*cp == '-') {
cp++;
isneg = 1;
isneg = true;
}
if (*cp == '+')
......
......@@ -251,7 +251,7 @@ adj_systime(
double quant; /* quantize to multiples of */
double dtemp;
long ticks;
int isneg = 0;
bool isneg = false;
/*
* FIXME: With the legacy Windows port on, this might be removable.
......@@ -276,7 +276,7 @@ adj_systime(
*/
dtemp = now + sys_residual;
if (dtemp < 0) {
isneg = 1;
isneg = true;
dtemp = -dtemp;
}
adjtv.tv_sec = (long)dtemp;
......
......@@ -773,7 +773,7 @@ process_control(
req_count = (int)ntohs(pkt->count);
datanotbinflag = false;
datalinelen = 0;
datasent = 0;
datasent = false;
datapt = rpkt.u.data;
dataend = &rpkt.u.data[CTL_MAX_DATA_LEN];
......
......@@ -61,7 +61,7 @@ volatile u_long alarm_overflow;
u_long current_time; /* seconds since startup */
/*
* Stats. Number of overflows and number of calls to transmit().
* Stats. Time of last reset and number of calls to transmit().
*/
u_long timer_timereset;
u_long timer_xmtcalls;
......
......@@ -811,8 +811,8 @@ nmea_receive(
ZERO(date);
ZERO(gpsw);
sentence = 0;
rc_date = 0;
rc_time = 0;
rc_date = false;
rc_time = false;
/*
* Read the timecode and timestamp, then initialise field
* processing. The <CR><LF> at the NMEA line end is translated
......
......@@ -760,7 +760,7 @@ if __name__ == '__main__':
sys.stderr.write("ntpviz: ERROR: missing temps data\n")
raise SystemExit(1)
if show_temps is not None:
plot = stats.local_temps_gnuplot();
plot = stats.local_temps_gnuplot()
if generate:
gnuplot(plot)
else:
......@@ -1050,7 +1050,7 @@ ntpviz</a>, part of the <a href="https://www.ntpsec.org/">NTPsec project</a>
for (imagename, image) in imagepairs:
if not image:
continue;
continue
div_name = imagename.replace('-', ' ')
index_buffer += "<div>\n<h2>%s:</h2>\n" % div_name
if 'peer-jitter-' == imagename[:12]:
......
......@@ -173,6 +173,6 @@ Host st offset(s) version system processor
for host in hostlist:
scan_host(host, 0)
sys.exit(0);
sys.exit(0)
# end
......@@ -193,4 +193,3 @@ if __name__ == "__main__":
sys.exit(1)
# end
......@@ -175,7 +175,7 @@ SERR_NOHOST = "***No host open, use `host' command\n"
def dump_hex_printable(xdata):
"Dump a packet in hex, in a familiar hex format"
llen = len(xdata)
i = 0;
i = 0
while llen > 0:
rowlen = min(16, llen)
restart = i
......@@ -318,9 +318,9 @@ class ntpq_session:
# If it isn't authenticated we can just send it. Otherwise
# we're going to have to think about it a little.
if not auth and not self.always_auth:
return pkt.send();
return pkt.send()
else:
sys.stderr.write("Authenticated send is not yet implemented\n");
sys.stderr.write("Authenticated send is not yet implemented\n")
return -1
def getresponse(self, opcode, associd, timeo):
"Get a response expected to match a given opcode and associd."
......@@ -331,7 +331,7 @@ class ntpq_session:
# should have had. Note we use one long time out, should reconsider.
fragments = []
self.response = ''
seenlastfrag = False;
seenlastfrag = False
bail = 0
warn = sys.stderr.write
......@@ -364,7 +364,7 @@ class ntpq_session:
warn("%s: timed out, nothing received\n" % self.name)
return SERR_TIMEOUT
if timeo:
warn("%s: timed out with incomplete data\n" % self.name);
warn("%s: timed out with incomplete data\n" % self.name)
if self.debug:
sys.stderr.write("ERR_INCOMPLETE: Received fragments:\n")
for (i, frag) in enumerate(fragments):
......@@ -373,7 +373,7 @@ class ntpq_session:
("not " "", )[seenlastfrag])
return SERR_INCOMPLETE
rawdata = self.sock.recv(4096);
rawdata = self.sock.recv(4096)
if self.debug:
warn("Received %d octets\n" % len(rawdata))
rpkt = control_frag(self)
......@@ -393,7 +393,7 @@ class ntpq_session:
continue
if not rpkt.is_response():
if self.debug:
warn("Received request, wanted response\n");
warn("Received request, wanted response\n")
#continue
# Check opcode and sequence number for a match.
......@@ -449,7 +449,7 @@ class ntpq_session:
if len(fragments) > 0:
last = fragments[-1]
if last.end() > rpkt.offset:
warn("received frag at %d overlaps with %d octet frag at %d\n" % (rpkt.offset, last.count, last.offset));
warn("received frag at %d overlaps with %d octet frag at %d\n" % (rpkt.offset, last.count, last.offset))
continue
if not_earlier and rpkt.end() > not_earlier.offset:
......@@ -483,10 +483,10 @@ class ntpq_session:
"send a request and save the response"
if not self.havehost():
return SERR_NOHOST
done = False;
done = False
while True:
# Ship the request
res = self.sendrequest(opcode, associd, qdata, auth);
res = self.sendrequest(opcode, associd, qdata, auth)
if res is not None:
return res
# Get the response.
......@@ -502,7 +502,7 @@ class ntpq_session:
continue
break
# Return None on success, otherwise an error string
return res;
return res
def readvars(self):
"Read system vars from the host as a dict, or return an error string."
self.doquery(opcode=CTL_OP_READVAR, quiet=True)
......
......@@ -27,7 +27,7 @@ class NTPStats:
# unparseable time 0 and it will be stripped later
return None
# 86400 = 24 * 60 * 60
time = 86400*mjd + second - 3506716800; # warning: 32 bit overflows
time = 86400*mjd + second - 3506716800 # warning: 32 bit overflows
if time < starttime or time > endtime:
return None
return str(time) + " " + split[2]
......@@ -43,7 +43,7 @@ class NTPStats:
self.period = period
# Default to one week before the latest date
if endtime is None and starttime == None:
if endtime is None and starttime is None:
endtime = int(time.time())
starttime = endtime - period
elif starttime is None and endtime is not None:
......@@ -66,7 +66,7 @@ class NTPStats:
for logpart in glob.glob(os.path.join(statsdir, stem) + "*"):
# skip files older than starttime
if starttime > os.path.getmtime(logpart):
continue;
continue
if logpart.endswith("gz"):
lines += gzip.open(logpart).readlines()
else:
......@@ -81,7 +81,7 @@ class NTPStats:
# temps is already in UNIX time
for line in lines:
line = line.strip(' \0\r\n\t')
if line != None:
if line is not None:
split = line.split(None, 2)
if int(split[0]) >= starttime and \
int(split[0]) <= endtime:
......@@ -91,7 +91,7 @@ class NTPStats:
for line in lines:
line = line.strip(' \0\r\n\t')
line = NTPStats.unixize(line,starttime, endtime)
if line != None:
if line is not None:
lines1.append( line)
# Sort by datestamp
......
......@@ -3,6 +3,7 @@
from __future__ import print_function
import socket
import sys
def canonicalize_dns(hostname):
try:
......
......@@ -23,7 +23,7 @@ hyphen and the flag character.
from __future__ import print_function, division
import sys, getopt, re
import sys, getopt, re, os
if __name__ == '__main__':
try:
......@@ -45,7 +45,7 @@ if __name__ == '__main__':
if tick == 0:
try:
with sys.popen("ntpfrob -A") as rp:
with os.popen("ntpfrob -A") as rp:
response = rp.read()
m = re.search("[0-9]+", response)
if m:
......@@ -89,4 +89,3 @@ if __name__ == '__main__':
sys.exit(0)
# end
......@@ -28,7 +28,7 @@ cmd_map = {
def run(cmd, reg):
check = False
if cmd[1] == None:
if cmd[1] is None:
cmd = [cmd[0]]
print("running: ", " ".join(cmd), end="")
......
......@@ -19,5 +19,3 @@ def check_cap(ctx):
pprint("RED", "Warning libcap and headers not installed")
pprint("RED", "Fedora needs libcap-devel")
pprint("RED", "Debian needs libcap-dev")
......@@ -58,4 +58,3 @@ def configure_ssl(ctx):
if ctx.get_define("HAVE_OPENSSL"):
ctx.define("USE_OPENSSL_CRYPTO_RAND", 1, comment="Use OpenSSL pseudo-random number generator")
ctx.define("USE_OPENSSL_HASH", 1, comment="Use OpenSSL for hashing")
......@@ -6,7 +6,7 @@ def check_seccomp(ctx):
if not ctx.options.enable_seccomp:
return
if not sys.platform.startswith("linux"):
return;
return
ctx.check_cc(header_name="seccomp.h", mandatory=False)
......@@ -18,5 +18,3 @@ def check_seccomp(ctx):
pprint("RED", "Warning libseccomp and headers")
pprint("RED", "Fedora needs libseccomp-devel")
pprint("RED", "Debian needs libseccomp-dev")
......@@ -80,4 +80,3 @@ def check_sizeof(*kwargs):
return check_sizeof_cross(*kwargs)
else:
return check_sizeof_host(*kwargs)