Skip to content
This repository has been archived by the owner on Nov 30, 2023. It is now read-only.

ScheduleViewer error: 'GetStartTime' not defined #477

Open
answerquest opened this issue Apr 11, 2019 · 2 comments
Open

ScheduleViewer error: 'GetStartTime' not defined #477

answerquest opened this issue Apr 11, 2019 · 2 comments

Comments

@answerquest
Copy link

I just git-cloned the transitfeed repo and ran ScheduleViewer (after making the api key hotfix mentioned in #467 ). There seems to be an error happening when we click on any route:

Exception happened during processing of request from ('127.0.0.1', 52468)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 290, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 318, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 331, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 652, in __init__
    self.handle()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 340, in handle
    self.handle_one_request()
  File "/usr/lib/python2.7/BaseHTTPServer.py", line 328, in handle_one_request
    method()
  File "/mnt/PERSONAL/TECH/WRI GTFS project/Softwares, tools/transitfeed/schedule_viewer.py", line 115, in do_GET
    return self.handle_json_wrapper_GET(handler, parsed_params)
  File "/mnt/PERSONAL/TECH/WRI GTFS project/Softwares, tools/transitfeed/schedule_viewer.py", line 262, in handle_json_wrapper_GET
    result = handler(parsed_params)
  File "/mnt/PERSONAL/TECH/WRI GTFS project/Softwares, tools/transitfeed/schedule_viewer.py", line 225, in handle_json_GET_routepatterns
    transitfeed.SortListOfTripByTime(trips)
  File "/mnt/PERSONAL/TECH/WRI GTFS project/Softwares, tools/transitfeed/transitfeed/trip.py", line 767, in SortListOfTripByTime
    trips.sort(key=GetStartTime)
NameError: global name 'GetStartTime' is not defined

It looks like a variable/object GetStartTime is being used before being defined. This doesn't seem like a missing module error or so.

@answerquest
Copy link
Author

Note: probably because they're both using the same code, location_editor.py is also having the same issue.

@TonyRoussel
Copy link

for me a quick workaround was to use sorted instead of sort

diff --git a/transitfeed/trip.py b/transitfeed/trip.py
index ae9b374..33ebcf6 100755
--- a/transitfeed/trip.py
+++ b/transitfeed/trip.py
@@ -764,4 +764,4 @@ class Trip(GtfsObjectBase):
 
 
 def SortListOfTripByTime(trips):
-  trips.sort(key=GetStartTime)
+  trips = sorted(trips, key=lambda trip: trip.GetStartTime())

lvancraen pushed a commit to TransitApp/transitfeed that referenced this issue Dec 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants