Skip to content

Commit

Permalink
Merge pull request #110 from pennlabs/gsr-timeouts
Browse files Browse the repository at this point in the history
GSR Reservation Timeouts
  • Loading branch information
joshdoman authored Apr 2, 2019
2 parents dd701ae + 1626502 commit 31ff12c
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion penn/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '1.8.3'
__version__ = '1.8.4'

from .registrar import Registrar
from .directory import Directory
Expand Down
6 changes: 4 additions & 2 deletions penn/studyspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down
6 changes: 4 additions & 2 deletions penn/wharton.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
url='https://github.com/pennlabs/penn-sdk-python',
author='Penn Labs',
author_email='[email protected]',
version='1.8.3',
version='1.8.4',
packages=['penn'],
license='MIT',
package_data={
Expand Down

0 comments on commit 31ff12c

Please sign in to comment.