From dd701ae428bfe19f440a129e7c3a9f18f1b7ebdb Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Sun, 31 Mar 2019 12:49:11 -0400 Subject: [PATCH] custom error message if not wharton student --- penn/wharton.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/penn/wharton.py b/penn/wharton.py index 6f6f23d..79182ae 100644 --- a/penn/wharton.py +++ b/penn/wharton.py @@ -54,6 +54,10 @@ def book_reservation(self, sessionid, roomid, start, end): format = "%Y-%m-%dT%H:%M:%S-{}".format(self.get_dst_gmt_timezone()) booking_url = "{}/reserve/{}/{}/?d={}".format(BASE_URL, roomid, start.strftime(format), duration) resp = requests.get(booking_url, cookies={"sessionid": sessionid}) + + if resp.status_code == 403: + return {"success": False, "error": "Your account does not have permission to book Wharton GSRs!"} + resp.raise_for_status() csrfheader = re.search(r"csrftoken=(.*?);", resp.headers["Set-Cookie"]).group(1)