DoorController: Check for HTTP error before trying to parse XML

This commit is contained in:
Adam Goldsmith 2020-06-02 22:28:34 -04:00
parent ab6d0bdbc4
commit 2855e773cd

View File

@ -124,9 +124,13 @@ class DoorController:
params={"XML": prefix + xml},
auth=requests.auth.HTTPDigestAuth(self.username, self.password),
)
resp_xml = etree.XML(r.content)
if r.status_code != 200:
raise RemoteError(r)
# probably meed to be more sane about this
if r.status_code != 200 or len(resp_xml.findall("{*}Error")) > 0:
resp_xml = etree.XML(r.content)
if len(resp_xml.findall("{*}Error")) > 0:
raise RemoteError(r)
return resp_xml