Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
.pyc
4 changes: 4 additions & 0 deletions app.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ def eval(cmd, input=None):
return shuttle.eval(cmd['args'])
elif cmd['service'] == 'W': ## Weather
return weather.eval(input)
elif cmd['service'] == 'M': ## David Morin's Office Hours
return morin.eval(cmd['args'])
else:
return "ERROR 42: service not recognized"

Expand All @@ -33,6 +35,8 @@ def special(incoming):
body = laundry.special
elif incoming.upper() == "WEATHER":
body = weather.special
elif incoming.upper() == "MORIN":
body = morin.special
elif incoming.upper() == "DEMO":
## welcome/instructions
body = 'Thanks for using Harvard Now!\n'
Expand Down
Binary file removed app.pyc
Binary file not shown.
7 changes: 6 additions & 1 deletion data.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,5 +141,10 @@
{'service': 'S', 'args':{'endpoint': 'route', 'routeid': '4007272' , 'label': 'Barry\'s Corner Shuttle Route'}, 'tags':["BARRY'S",'BARRY', 'CORNER', 'SHUTTLE', 'ROUTE']},
{'service': 'S', 'args':{'endpoint': 'route', 'routeid': '4007610' , 'label': 'Quad Stadium Express Shuttle Route'}, 'tags':['QUAD', 'STADIUM', 'EXPRESS', 'SHUTTLE', 'ROUTE']},
{'service': 'S', 'args':{'endpoint': 'route', 'routeid': '4007650' , 'label': 'Allston Campus Express Shuttle Route'}, 'tags':['ALLSTON', 'CAMPUS', 'EXPRESS', 'SHUTTLE', 'ROUTE']},
{'service': 'W', 'args':{}, 'tags':['WEATHER']}
{'service': 'W', 'args':{}, 'tags':['WEATHER']},
{'service': 'M', 'args':{'dayofweek': 'Monday'}, 'tags':['MONDAY', 'OFFICE', 'HOURS', 'DAVID', 'MORIN']},
{'service': 'M', 'args':{'dayofweek': 'Tuesday'}, 'tags':['TUESDAY', 'OFFICE', 'HOURS', 'DAVID', 'MORIN']},
{'service': 'M', 'args':{'dayofweek': 'Wednesday'}, 'tags':['WEDNESDAY', 'OFFICE', 'HOURS', 'DAVID', 'MORIN']},
{'service': 'M', 'args':{'dayofweek': 'Thursday'}, 'tags':['THURSDAY', 'OFFICE', 'HOURS', 'DAVID', 'MORIN']},
{'service': 'M', 'args':{'dayofweek': 'Friday'}, 'tags':['FRIDAY', 'OFFICE', 'HOURS', 'DAVID', 'MORIN']}
]
Binary file removed data.pyc
Binary file not shown.
1 change: 1 addition & 0 deletions services/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from laundry import laundry
from shuttle import shuttle
from weather import weather
from morin import morin
Binary file removed services/__init__.pyc
Binary file not shown.
Binary file removed services/laundry/__init__.pyc
Binary file not shown.
Binary file removed services/laundry/data.pyc
Binary file not shown.
Binary file removed services/laundry/laundry.pyc
Binary file not shown.
Empty file added services/morin/__init__.py
Empty file.
52 changes: 52 additions & 0 deletions services/morin/morin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import urllib2, urllib
import re
from bs4 import BeautifulSoup

#############################
## David Morin ##
## Office Hours Function ##
#############################

def getHours(dayofweek):
url = 'http://www.people.fas.harvard.edu/~djmorin/office_hours.htm'
hdr = {'User-Agent': 'Chrome'}
req = urllib2.Request(url,headers=hdr)
website = urllib2.urlopen(req)
soup = BeautifulSoup(website.read(), 'html.parser')

ohResult = ''

try:
ohTable = soup.find('table', {'id': 'AutoNumber1'})

for ohRow in ohTable.find_all('tr'):
ohCols = ohRow.findAll('td')
if ohCols[0].find('font').text == dayofweek:
ohResult = ohCols[1].text
break

ohTitle = soup.find('p').find('b').find('font').text

except Exception, e:
print str(e)

if ohResult == '':
return "Could not find office hour data. Are you sure you gave a proper day of week?"

body = ohTitle + '\n' + dayofweek + ': ' + ohResult

return body

def makeSpecial():
s = "Gets David Morin's office hours."
return s

############################
## Top-Level ##
############################

## return description of function
special = makeSpecial()

def eval(cmd):
return getHours(cmd['dayofweek'])
Binary file removed services/shuttle/__init__.pyc
Binary file not shown.
Binary file removed services/shuttle/api.pyc
Binary file not shown.
Binary file removed services/shuttle/shuttle.pyc
Binary file not shown.
Binary file removed services/weather/__init__.pyc
Binary file not shown.
Binary file removed services/weather/weather.pyc
Binary file not shown.