From 2855e773cd74a2b0a895d96b1d45e06125436826 Mon Sep 17 00:00:00 2001 From: Adam Goldsmith Date: Tue, 2 Jun 2020 22:28:34 -0400 Subject: [PATCH] DoorController: Check for HTTP error before trying to parse XML --- memberPlumbing/hid/DoorController.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/memberPlumbing/hid/DoorController.py b/memberPlumbing/hid/DoorController.py index 5483bab..d81c036 100644 --- a/memberPlumbing/hid/DoorController.py +++ b/memberPlumbing/hid/DoorController.py @@ -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