changeset 24:806b1ed7f1b5

Get units right for speeds.
author Daniel O'Connor <darius@dons.net.au>
date Sat, 17 Jun 2017 16:52:20 +0930
parents 4b6c811e77df
children 7571c101a4ee
files adslstats.py
diffstat 1 files changed, 5 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/adslstats.py	Sat Jun 17 15:59:23 2017 +0930
+++ b/adslstats.py	Sat Jun 17 16:52:20 2017 +0930
@@ -155,17 +155,18 @@
         return False
 
     # Helper function to extract data
-    def getvals(bs, text):
+    def getvals(bs, text, mult = 1):
         subs = bs.findAll('label', text = text)[0].fetchNextSiblings()[0].strings
-        return map(lambda s: float(s.split()[0]), subs)
+        tmp = map(lambda s: float(s.split()[0]), subs)
+        return map(lambda s: s * mult, tmp)
 
     if map(None, bs.findAll('label', text = 'DSL Status')[0].fetchNextSiblings()[0].strings)[0] == 'Up':
         stats.linkup = True
     else:
         stats.linkup = False
 
-    stats.upstreammax, stats.downstreammax = getvals(bs, 'Maximum Line rate')
-    stats.upstream, stats.downstream = getvals(bs, 'Line Rate')
+    stats.upstreammax, stats.downstreammax = getvals(bs, 'Maximum Line rate', 1e3)
+    stats.upstream, stats.downstream = getvals(bs, 'Line Rate', 1e3)
     stats.uppower, stats.downpower = getvals(bs, 'Output Power')
     stats.nmup, stats.nmdown = getvals(bs, 'Noise Margin')