doorUpdater: Actually check for errors in response xml

This commit is contained in:
Adam Goldsmith 2018-05-11 19:04:12 -04:00
parent 82e9a9b037
commit f3556f74a4

View File

@ -5,6 +5,7 @@ import csv
from io import StringIO
import urllib3
from hashlib import md5
from xml.etree import ElementTree as ET
import os
from passwords import *
@ -116,7 +117,9 @@ def doRequest(ip, params=None, files=None):
auth=requests.auth.HTTPDigestAuth(DOOR_USERNAME, DOOR_PASSWORD),
timeout=10,
verify=False) # ignore insecure SSL
if r.status_code != 200:
xml = ET.XML(r.text)
if r.status_code != 200 \
or len(xml.findall("{http://www.hidglobal.com/VertX}Error")) > 0:
print("Door Updating Error: ", r.status_code, r.reason)
print(r.text)
sys.exit(1)