From 9e3b8f9691c7bf661314126753590769ffcbc773 Mon Sep 17 00:00:00 2001 From: Eric Wang Date: Mon, 18 Mar 2019 13:01:19 -0400 Subject: [PATCH] add simple laundry site check --- penn/laundry.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/penn/laundry.py b/penn/laundry.py index 817438e..1053b3c 100644 --- a/penn/laundry.py +++ b/penn/laundry.py @@ -150,6 +150,25 @@ def hall_status(self, hall_id): 'location': location } + def check_is_working(self): + """ Returns True if the wash alert web interface seems to be + working properly, or False otherwise. + + >>> l.check_is_working() + """ + try: + r = requests.post(USAGE_BASE_URL, timeout=60, data={ + "locationid": "5faec7e9-a4aa-47c2-a514-950c03fac460", + "email": "pennappslabs@gmail.com", + "washers": 0, + "dryers": 0, + "locationalert": "OK" + }) + r.raise_for_status() + return "The transaction log for database 'QuantumCoin' is full due to 'LOG_BACKUP'." not in r.text + except requests.exceptions.HTTPError: + return False + def machine_usage(self, hall_no): """Returns the average usage of laundry machines every hour for a given hall.