Need help from a python wizard

Hal Murray hmurray at megapathdsl.net
Mon Dec 4 22:28:33 UTC 2017


The direct mode of ntpq mrulist is broken.

The direct mode is a hack to print out the info as it is collected rather 
than collecting everything then sorting the list and printing it out.  The 
idea is to avoid using lots of memory.

It's supposed to print out the MJD and seconds this day for the first two 
columns.

It's printing out MJD and 0.  Sample:

58091     0    228    0 . 4 4   1109   123 192.168.1.70
58091     0    228    0 . 4 4   1110   123 192.168.1.36
58091     0    228    0 . 4 4   1110   123 192.168.1.61
58091     0    228    0 . 4 4   1109   123 192.168.1.50
58091     0    228    0 . 4 4   1109   123 192.168.1.82

The code that does that is in pylib/util.py;

        last = ntp.ntpc.lfptofloat(entry.last)
        if self.now:
            lstint = int(self.now - last + 0.5)
            stats = "%7d" % lstint
        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)
            stats = "%5d %5d" % (days + MJD_1970, lstint)

That looks good to me.  I tried it by hand and it did what I expected.  That 
was using:
  Python 2.7.14 (default, Nov  3 2017, 10:55:25) 

It broke somewhere between Sep-20 and Sep-25, give or take a few days or more 
depending on when I pulled, built, and installed.  The last change in that 
area was ages ago.

Any hints?  If not, I'll try bisecting.

Is this mixed up with the python2/python3 stuff?



-- 
These are my opinions.  I hate spam.





More information about the devel mailing list