diff --git a/doorUpdater.py b/doorUpdater.py index 9de0171..cd40662 100644 --- a/doorUpdater.py +++ b/doorUpdater.py @@ -1,3 +1,4 @@ +import sys import requests import csv from io import StringIO @@ -36,6 +37,10 @@ def getMembershipworksData(): "eml": MEMBERSHIPWORKS_USERNAME, "org": "10000", "pwd": MEMBERSHIPWORKS_PASSWORD}) + if r.status_code != 200 or 'SF' not in r.json(): + print("MembershipWorks Login Error: ", r.status_code, r.reason) + print(r.text) + sys.exit(1) SFtoken = r.json()['SF'] # get list of member/staff IDs @@ -44,6 +49,10 @@ def getMembershipworksData(): "lbl": "5ae37979f033bfe8534f8799,5771675edcdf126302a2f6b9", # members and staff "org": "15475", # unknown "var": "_id,nam,ctc"}) + if r.status_code != 200 or 'usr' not in r.json(): + print("MembershipWorks User Listing Error: ", r.status_code, r.reason) + print(r.text) + sys.exit(1) ids = [user['_id'] for user in r.json()['usr']] # get members CSV @@ -54,6 +63,10 @@ def getMembershipworksData(): "mux": "", # unknown "tid": ",".join(ids), # ids of members to get "var": "lvl,xws,xms,xsc,xrs,xfd,xac,phn,eml,lbl,nam"}) # which columns to get + if r.status_code != 200: + print("MembershipWorks CSV Generation Error: ", r.status_code, r.reason) + print(r.text) + sys.exit(1) return r.text @@ -90,8 +103,12 @@ def doRequest(ip, params=None, files=None): params=params, files=files, auth=requests.auth.HTTPDigestAuth(DOOR_USERNAME, DOOR_PASSWORD), + timeout=1, verify=False) # ignore insecure SSL - print(r.text) + if r.status_code != 200: + print("Door Updating Error: ", r.status_code, r.reason) + print(r.text) + sys.exit(1) def updateDoor(doorIP, csv): """Do the update import procedure on a door control"""