Mercurial > ~darius > hgwebdir.cgi > adslstats
diff adslstats.py @ 36:5dbc310f1eca
Fix uptime parser broken by previous commit.
Add comment about it while I'm here.
author | Daniel O'Connor <darius@dons.net.au> |
---|---|
date | Tue, 17 Nov 2020 15:47:56 +1030 |
parents | b79c03810bbe |
children | 4f9a79f733ff |
line wrap: on
line diff
--- a/adslstats.py Sat Nov 14 15:05:07 2020 +1030 +++ b/adslstats.py Tue Nov 17 15:47:56 2020 +1030 @@ -200,7 +200,8 @@ uptime = re.findall('([0-9]+)', list(bs.findAll('label', text = 'DSL Uptime')[0].fetchNextSiblings()[0].strings)[0]) uptime.reverse() # End up with an array of seconds, minutes, hours, etc mults = [1, 60, 60 * 60, 24 * 60 * 60] - if len(uptime) != len(mults): + # Basic sanity check of the number of elements, should be at least 1 + if len(uptime) == 0 or len(uptime) > len(mults): print('Unexpected number of uptime elements (%s)' % str(uptime)) stats.uptime = None else: