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
Loading
Loading
Loading
Loading
Loading
+1 −3
Original line number Original line Diff line number Diff line
@@ -1150,9 +1150,7 @@ class MRUSummary:
        else:
        else:
            # direct mode doesn't have a reference time
            # direct mode doesn't have a reference time
            MJD_1970 = 40587     # MJD for 1 Jan 1970, Unix epoch
            MJD_1970 = 40587     # MJD for 1 Jan 1970, Unix epoch
            days = int(last) / 86400
            days, lstint = divmod(int(last), 86400)
            seconds = last - days*86400
            lstint = int(seconds)
            stats = "%5d %5d" % (days + MJD_1970, lstint)
            stats = "%5d %5d" % (days + MJD_1970, lstint)
        first = ntp.ntpc.lfptofloat(entry.first)
        first = ntp.ntpc.lfptofloat(entry.first)
        active = float(last - first)
        active = float(last - first)
+4 −4
Original line number Original line Diff line number Diff line
@@ -895,7 +895,7 @@ class TestPylibUtilMethods(unittest.TestCase):
            fakesockmod.gai_returns = [("fam", "type", "proto",
            fakesockmod.gai_returns = [("fam", "type", "proto",
                                        "foo.bar.com", "1.2.3.4")]
                                        "foo.bar.com", "1.2.3.4")]
            self.assertEqual(cls.summary(ent),
            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")
                             "      1    42 1.2.3.4")
            # Test summary, second options
            # Test summary, second options
            mycache._cache = {}
            mycache._cache = {}
@@ -909,7 +909,7 @@ class TestPylibUtilMethods(unittest.TestCase):
                                         "foo.bar.com", ("1.2.3.4", 42))]]
                                         "foo.bar.com", ("1.2.3.4", 42))]]
            cdns_jig_returns = ["foo.com"]
            cdns_jig_returns = ["foo.com"]
            self.assertEqual(cls.summary(ent),
            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")
                             "    42 foo.com")
            # Test summary, third options
            # Test summary, third options
            mycache._cache = {}
            mycache._cache = {}
@@ -918,7 +918,7 @@ class TestPylibUtilMethods(unittest.TestCase):
            fakesockmod.gai_error_count = 1
            fakesockmod.gai_error_count = 1
            cdns_jig_returns = ["foobarbaz" * 5]  # 45 chars, will be cropped
            cdns_jig_returns = ["foobarbaz" * 5]  # 45 chars, will be cropped
            self.assertEqual(cls.summary(ent),
            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")
                             " 1.2.3.4 (foobarbazfoobarbazfoobarbazfoob")
            # Test summary, wide
            # Test summary, wide
            mycache._cache = {}
            mycache._cache = {}
@@ -926,7 +926,7 @@ class TestPylibUtilMethods(unittest.TestCase):
            fakesockmod.gai_error_count = 1
            fakesockmod.gai_error_count = 1
            cdns_jig_returns = ["foobarbaz" * 5]  # 45 chars, will be cropped
            cdns_jig_returns = ["foobarbaz" * 5]  # 45 chars, will be cropped
            self.assertEqual(cls.summary(ent),
            self.assertEqual(cls.summary(ent),
                             "64730     0    256    0 . 7 2      2"
                             "64730 23808    256    0 . 7 2      2"
                             "    42 1.2.3.4 "
                             "    42 1.2.3.4 "
                             "(foobarbazfoobarbazfoobarbazfoobarbazfoobarbaz)")
                             "(foobarbazfoobarbazfoobarbazfoobarbazfoobarbaz)")
        finally:
        finally: