[Git][NTPsec/ntpsec][master] Fix ntpq -c direct -c mrulist to output seconds
Hal Murray
gitlab at mg.gitlab.com
Tue Dec 5 04:45:52 UTC 2017
Hal Murray pushed to branch master at NTPsec / ntpsec
Commits:
3c1cc3c8 by Hal Murray at 2017-12-04T20:43:18-08:00
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
- - - - -
2 changed files:
- pylib/util.py
- tests/pylib/test_util.py
Changes:
=====================================
pylib/util.py
=====================================
--- a/pylib/util.py
+++ b/pylib/util.py
@@ -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)
=====================================
tests/pylib/test_util.py
=====================================
--- a/tests/pylib/test_util.py
+++ b/tests/pylib/test_util.py
@@ -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:
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/3c1cc3c8317faa48ce8e5b8ef7909c16cb04deab
---
View it on GitLab: https://gitlab.com/NTPsec/ntpsec/commit/3c1cc3c8317faa48ce8e5b8ef7909c16cb04deab
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/20171205/97469b24/attachment.html>
More information about the vc
mailing list