Skip to content

Commit

Permalink
Merge pull request #85 from pennlabs/laundry-endpoint
Browse files Browse the repository at this point in the history
Return location in hall response and various fixes
  • Loading branch information
ezwang authored Nov 10, 2017
2 parents 1019505 + 36d1a55 commit 80f1b28
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 13 deletions.
1 change: 0 additions & 1 deletion MANIFEST.in

This file was deleted.

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.6.5'
__version__ = '1.6.6'

from .registrar import Registrar
from .directory import Directory
Expand Down
2 changes: 1 addition & 1 deletion penn/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ def _request(self, url, params=None):
"""Make a signed request to the API, raise any API errors, and
returning a tuple of (data, metadata)
"""
response = get(url, params=params, headers=self.headers, timeout=10)
response = get(url, params=params, headers=self.headers, timeout=20)
if response.status_code != 200:
raise ValueError('Request to {} returned {}'
.format(response.url, response.status_code))
Expand Down
20 changes: 11 additions & 9 deletions penn/laundry.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
import csv
import requests
import pkg_resources
try:
import urllib2
except:
import urllib.parse as urlib2
from bs4 import BeautifulSoup

ALL_URL = 'http://suds.kite.upenn.edu/?location='
Expand Down Expand Up @@ -34,6 +30,7 @@ def __init__(self):
'Saturday', 'Sunday']
self.hall_to_link = {}
self.id_to_hall = {}
self.id_to_location = {}
self.hall_id_list = []
self.create_hall_to_link_mapping()

Expand All @@ -49,9 +46,9 @@ def create_hall_to_link_mapping(self):
hall_id = int(hall_id)
self.hall_to_link[hall_name] = ALL_URL + uuid
self.id_to_hall[hall_id] = hall_name
self.id_to_location[hall_id] = location
self.hall_id_list.append({"hall_name": hall_name, "id": hall_id, "location": location})


@staticmethod
def update_machine_object(cols, machine_object):
if cols[2].getText() == "In use" or cols[2].getText() == "Almost done":
Expand Down Expand Up @@ -118,18 +115,23 @@ def hall_status(self, hall_id):
"""Return the status of each specific washer/dryer in a particular
laundry room.
:param hall_name:
Unescaped string corresponding to the name of the hall hall. This name
:param hall_id:
Integer corresponding to the id of the hall. This id
is returned as part of the all_status call.
>>> english_house = l.hall_status("English%20House")
"""
if hall_id not in self.id_to_hall:
raise ValueError("No hall with id %s exists." % hall_id)

hall_name = self.id_to_hall[hall_id]
machines = self.parse_a_hall((urllib2.unquote(hall_name)))
location = self.id_to_location[hall_id]
machines = self.parse_a_hall(hall_name)

return {
'machines': machines,
'hall_name': hall_name
'hall_name': hall_name,
'location': location
}

def machine_usage(self, hall_no):
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,13 @@
url='https://github.com/pennlabs/penn-sdk-python',
author='Penn Labs',
author_email='[email protected]',
version='1.6.5',
version='1.6.6',
packages=['penn'],
license='MIT',
package_data={
# If any package contains *.txt or *.rst files, include them:
'': ['*.txt', '*.rst'],
'penn': ['data/laundry.csv'],
},
long_description=open('./README.rst').read(),
install_requires=[
Expand Down

0 comments on commit 80f1b28

Please sign in to comment.