# HG changeset patch # User Daniel O'Connor # Date 1497684140 -34200 # Node ID 806b1ed7f1b5432e036fd3c0ec0b1f10f205c01d # Parent 4b6c811e77dfc8f743a67f1013404a461341c855 Get units right for speeds. diff -r 4b6c811e77df -r 806b1ed7f1b5 adslstats.py --- 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')