Skip to content

Commit

Permalink
Fixed some bugs so that IVR actually works
Browse files Browse the repository at this point in the history
  • Loading branch information
nealf committed Jun 21, 2016
1 parent 191d2f0 commit ecd529f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
4 changes: 2 additions & 2 deletions bt_text/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,8 @@ def handle_voice_call():

@app.route('/voice', methods=['POST'])
def handle_voice_input():

data = request.form['Body']
print(request.form['Digits'])
data = request.form['Digits']
rt_code = int(data)
times = bt_api.get_times_for_stop_code(stopCode=rt_code, requestShortNames=False)

Expand Down
16 changes: 10 additions & 6 deletions bt_text/bt_request/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def get_buses_for_stop_code(stopCode):

route_short_names = []
route_names = []
routes = {}

# pudb.set_trace()

Expand All @@ -192,10 +193,12 @@ def get_buses_for_stop_code(stopCode):
route_short_names.append(child.text)
for child in resp["xml"].iter('RouteName'):
route_names.append(child.text)
for child in resp["xml"].iter('ScheduledRoutes'):
routes[child.find('RouteShortName').text] = child.find('RouteName').text
else:
success = False

return { "success": success, "status_code": resp["status_code"], "route_short_names": route_short_names, "route_names": route_names }
return { "success": success, "status_code": resp["status_code"], "route_short_names": route_short_names, "route_names": route_names, "routes": routes }


def get_times_for_stop_code(stopCode, requestShortNames):
Expand All @@ -204,10 +207,8 @@ def get_times_for_stop_code(stopCode, requestShortNames):
times = []
success = buses_resp["success"]
if buses_resp["status_code"] != None and buses_resp["status_code"] == 200 and success == True:
if requestShortNames == True:
buses = buses_resp["route_short_names"]
else:
buses = buses_resp[route_names]
buses = buses_resp["route_short_names"]
print(buses_resp["routes"])

numTimesToReturn = 1

Expand All @@ -218,7 +219,10 @@ def get_times_for_stop_code(stopCode, requestShortNames):
next_deps = get_next_departure_times_for_route_and_stop_code(route, stopCode, numTimesToReturn)

if next_deps["status_code"] != None and next_deps["status_code"] == 200:
times.append( (route, next_deps["times"] ) )
if requestShortNames == True:
times.append( (route, next_deps["times"] ) )
else:
times.append( (buses_resp["routes"][route], next_deps["times"] ) )
else:
success = False
break
Expand Down

1 comment on commit ecd529f

@nealf
Copy link
Member Author

@nealf nealf commented on ecd529f Jun 23, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Closed #4

Please sign in to comment.