diff --git a/penn/__init__.py b/penn/__init__.py index e4ecf3a..2309629 100644 --- a/penn/__init__.py +++ b/penn/__init__.py @@ -1,4 +1,4 @@ -__version__ = '1.8.3' +__version__ = '1.8.4' from .registrar import Registrar from .directory import Directory diff --git a/penn/studyspaces.py b/penn/studyspaces.py index 9daa250..38b6d12 100644 --- a/penn/studyspaces.py +++ b/penn/studyspaces.py @@ -239,16 +239,18 @@ def cancel_room(self, booking_id): resp = self._request("POST", "/1.1/space/cancel/{}".format(booking_id)) return resp.json() - def get_reservations(self, email, date): + def get_reservations(self, email, date, timeout=None): """Gets reservations for a given email. :param email: the email of the user who's reservations are to be fetched :type email: str """ try: - resp = self._request("GET", "/1.1/space/bookings?email={}&date={}&limit=100".format(email, date)) + resp = self._request("GET", "/1.1/space/bookings?email={}&date={}&limit=100".format(email, date), timeout=timeout) except resp.exceptions.HTTPError as error: raise APIError("Server Error: {}".format(error)) + except requests.exceptions.ConnectTimeout: + raise APIError("Timeout Error") return resp.json() def get_reservations_for_booking_ids(self, booking_ids): diff --git a/penn/wharton.py b/penn/wharton.py index 79182ae..1f14f62 100644 --- a/penn/wharton.py +++ b/penn/wharton.py @@ -18,15 +18,17 @@ class Wharton(object): >>> s = Wharton() """ - def get_reservations(self, sessionid): + def get_reservations(self, sessionid, timeout=None): """Returns a list of location IDs and names.""" url = "{}{}".format(BASE_URL, "/reservations/") cookies = dict(sessionid=sessionid) try: - resp = requests.get(url, cookies=cookies) + resp = requests.get(url, timeout=timeout, cookies=cookies) except resp.exceptions.HTTPError as error: raise APIError("Server Error: {}".format(error)) + except requests.exceptions.ConnectTimeout: + raise APIError("Timeout Error") html = resp.content.decode("utf8") diff --git a/setup.py b/setup.py index 3a6e6f0..1e57163 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ url='https://github.com/pennlabs/penn-sdk-python', author='Penn Labs', author_email='admin@pennlabs.org', - version='1.8.3', + version='1.8.4', packages=['penn'], license='MIT', package_data={