changeset 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 815e6b61d76e
children 4f9a79f733ff
files adslstats.py
diffstat 1 files changed, 2 insertions(+), 1 deletions(-) [+]
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: