something else

This commit is contained in:
Jack Robison 2018-07-29 00:01:53 -04:00
parent dc5ed393d6
commit d31db3e5f5
No known key found for this signature in database
GPG key ID: DF25C68FE0239BB2

View file

@ -51,7 +51,8 @@ class RootDevice(object):
try: try:
root = flatten_keys(etree_to_dict(ElementTree.fromstring(xml_string)), "{%s}" % DEVICE)[ROOT] root = flatten_keys(etree_to_dict(ElementTree.fromstring(xml_string)), "{%s}" % DEVICE)[ROOT]
except Exception as err: except Exception as err:
log.exception("failed to decode xml: %s\n%s", err, xml_string) if xml_string:
log.exception("failed to decode xml: %s\n%s", err, xml_string)
root = {} root = {}
self.spec_version = root.get(SPEC_VERSION) self.spec_version = root.get(SPEC_VERSION)
self.url_base = root.get("URLBase") self.url_base = root.get("URLBase")
@ -81,10 +82,9 @@ class Gateway(object):
log.info("querying %s", self.location) log.info("querying %s", self.location)
response = yield treq.get(self.location) response = yield treq.get(self.location)
response_xml = yield response.content() response_xml = yield response.content()
if response_xml: self._device = RootDevice(response_xml)
self._device = RootDevice(response_xml) if not self._device.devices or not self._device.services:
if not self._device.devices or not self._device.services: log.error("failed to parse device: \n%s", response_xml)
log.error("failed to parse device: \n%s", response_xml)
@property @property
def services(self): def services(self):