routertools: Parse gateway quality differently to catch wrong data

Since old routers send defective gateway data, some routers got
values like "false6" for quality. This is now caught and false
removed.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
This commit is contained in:
Adrian Schmutzler 2018-02-04 21:38:17 +01:00
parent 7091cc5054
commit f8ba13268a
1 changed files with 7 additions and 1 deletions

View File

@ -808,12 +808,18 @@ def parse_nodewatcher_xml(xml):
if (gw_mac and len(gw_mac)>12): # Throw away headline
gw = {
"mac": gw_mac.lower(),
"quality": evalxpathint(gw,"link_quality/text()"),
"quality": evalxpath(gw,"link_quality/text()"),
"nexthop": evalxpath(gw,"nexthop/text()",None),
"netif": evalxpath(gw,"outgoing_interface/text()",None),
"gw_class": evalxpath(gw,"gw_class/text()",None),
"selected": evalxpathbool(gw,"selected/text()")
}
if gw["quality"].startswith("false"):
gw["quality"] = gw["quality"][5:]
if gw["quality"]:
gw["quality"] = int(gw["quality"])
else:
gw["quality"] = 0
if gw["netif"]=="false":
tmp = gw["gw_class"].split(None,1)
gw["netif"] = tmp[0]