WRI-Cities / static-GTFS-manager

GUI interface for creating, editing, exporting of static GTFS data for a public transit authority
GNU General Public License v3.0
148 stars 46 forks source link

Impossible to delete route #150

Closed mzzntn closed 5 years ago

mzzntn commented 5 years ago

Operating system

Mac OS through docker

Python version

3.7.3

static-GTFS-manager

3.4.3

Problem description

When i try to delete a route, this error comes out "Error at backend, please debug."

deleteByKey GET call readTableDB: table:trips, column:route_id, value:"S.T.C001" readTableDB: Loaded trips, 12 records deleteID: Deleting 12 trips first under route_id="S.T.C001" Deleted 1 rows with trip_id="S.T.C001012" in table: trips
lookup for stop_times: stop_times_lookup.json Found chunk for id S.T.C001012: None ERROR:tornado.application:Uncaught exception GET /API/deleteByKey?pw=program&key=route_id&value=S.T.C001 (172.17.0.1) HTTPServerRequest(protocol='http', host='localhost:5000', method='GET', uri='/API/deleteByKey?pw=program&key=route_id&value=S.T.C001', version='HTTP/1.1', remote_ip='172.17.0.1') Traceback (most recent call last): File "/root/.local/lib/python3.6/site-packages/tornado/web.py", line 1590, in _execute result = method(*self.path_args, **self.path_kwargs) File "GTFSManager.py", line 1193, in get returnMessage = deleteID(column,value) File "", line 1487, in deleteID File "", line 1487, in File "", line 1506, in deleteID File "", line 1544, in deleteInTable TypeError: must be str, not NoneType ERROR:tornado.access:500 GET /API/deleteByKey?pw=program&key=route_id&value=S.T.C001 (172.17.0.1) 390.87ms

Expected Action

The route should be deleted

answerquest commented 5 years ago

Hi @mzzntn , thanks for posting this bug.
Can you clarify if: the trip_id "S.T.C001012" was not having any entries in stop_times (timings) yet; it was only in the trips table?
If so, then I'm guessing the program would have gone into stop_times table to delete the trip_id's entries but errored out due to not finding anything.

mzzntn commented 5 years ago

Hello @answerquest you are completely right.

The route S.T.C001 (recently changed in ArancioneD), contains several trips (16), but the only one that contains stop_times is the S.T.C001001.

Screenshot 2019-08-29 at 16 04 16

I think that the problem is due to the fact that i have first inserted all the trips, complete the stop_times table of the first trip only then saved and closed the program.

As you can see also the S.T.C001002 is empty, but for whatever reason it stops at the trip S.T.C001012.

Screenshot 2019-08-29 at 16 13 56

answerquest commented 5 years ago

Okk @mzzntn I've reproduced the error successfully at my end.

Working on it!

answerquest commented 5 years ago

Fixed! Inserted these lines in deleteInTable function:

# intervention : if no chunks found, skip. Ref: https://github.com/WRI-Cities/static-GTFS-manager/issues/150
if h5Files == [None]:
    returnMessage = '{}={} is not present in any {} chunk.<br>'.format(key,value,tablename)
    logmessage(returnMessage)
    return returnMessage

@mzzntn Pls download latest code and check. Only the GTFSserverfunctions.py file has changed for this bug's fix so you could copy over just that.

mzzntn commented 5 years ago

It works !!

Thanks @answerquest you have done and are continuing to do an amazing work with this project.