Commit 3c1cc3c8 authored by Hal Murray's avatar Hal Murray
Browse files

Fix ntpq -c direct -c mrulist to output seconds

Problem was that int/int gives an int on python 2 but float on python 3
parent af86651f
Pipeline #14729097 failed with stages
in 67 minutes and 36 seconds
......@@ -1150,9 +1150,7 @@ class MRUSummary:
else:
# direct mode doesn't have a reference time
MJD_1970 = 40587 # MJD for 1 Jan 1970, Unix epoch
days = int(last) / 86400
seconds = last - days*86400
lstint = int(seconds)
days, lstint = divmod(int(last), 86400)
stats = "%5d %5d" % (days + MJD_1970, lstint)
first = ntp.ntpc.lfptofloat(entry.first)
active = float(last - first)
......
......@@ -895,7 +895,7 @@ class TestPylibUtilMethods(unittest.TestCase):
fakesockmod.gai_returns = [("fam", "type", "proto",
"foo.bar.com", "1.2.3.4")]
self.assertEqual(cls.summary(ent),
"64730 0 0 400 K 7 2"
"64730 23296 0 400 K 7 2"
" 1 42 1.2.3.4")
# Test summary, second options
mycache._cache = {}
......@@ -909,7 +909,7 @@ class TestPylibUtilMethods(unittest.TestCase):
"foo.bar.com", ("1.2.3.4", 42))]]
cdns_jig_returns = ["foo.com"]
self.assertEqual(cls.summary(ent),
"64730 0 4.00 20 L 7 2 65"
"64730 23808 4.00 20 L 7 2 65"
" 42 foo.com")
# Test summary, third options
mycache._cache = {}
......@@ -918,7 +918,7 @@ class TestPylibUtilMethods(unittest.TestCase):
fakesockmod.gai_error_count = 1
cdns_jig_returns = ["foobarbaz" * 5] # 45 chars, will be cropped
self.assertEqual(cls.summary(ent),
"64730 0 256 0 . 7 2 2 42"
"64730 23808 256 0 . 7 2 2 42"
" 1.2.3.4 (foobarbazfoobarbazfoobarbazfoob")
# Test summary, wide
mycache._cache = {}
......@@ -926,7 +926,7 @@ class TestPylibUtilMethods(unittest.TestCase):
fakesockmod.gai_error_count = 1
cdns_jig_returns = ["foobarbaz" * 5] # 45 chars, will be cropped
self.assertEqual(cls.summary(ent),
"64730 0 256 0 . 7 2 2"
"64730 23808 256 0 . 7 2 2"
" 42 1.2.3.4 "
"(foobarbazfoobarbazfoobarbazfoobarbazfoobarbaz)")
finally:
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment