Get chipset value only if XML key exists

This commit is contained in:
Dominik Heidler 2016-07-26 22:20:59 +02:00
parent da42ef018c
commit d940526f79
1 changed files with 5 additions and 1 deletions

View File

@ -251,7 +251,6 @@ def parse_nodewatcher_xml(xml):
or len(tree.xpath("/data/interface_data/%s" % CONFIG["vpn_netif_aux"])) > 0),
},
"hardware": {
#"name": tree.xpath("/data/system_data/model/text()")[0],
"cpu": tree.xpath("/data/system_data/cpu/text()")[0]
},
"software": {
@ -276,6 +275,11 @@ def parse_nodewatcher_xml(xml):
router_update["hardware"]["name"] = "Legacy"
router_update["hardware"]["name"] = tree.xpath("/data/system_data/model/text()")[0]
# data.system_data.chipset
with suppress(IndexError):
router_update["hardware"]["chipset"] = "Unknown"
router_update["hardware"]["chipset"] = tree.xpath("/data/system_data/chipset/text()")[0]
# data.system_data.description
with suppress(IndexError):
router_update["description"] = tree.xpath("/data/system_data/description/text()")[0]