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
147 stars 46 forks source link

current stats errors out if DB is empty or agency data missing #112

Closed answerquest closed 6 years ago

answerquest commented 6 years ago
stats GET call
readTableDB: Loaded agency, 0 records
ERROR:tornado.application:Uncaught exception GET /API/stats (::1)
HTTPServerRequest(protocol='http', host='localhost:5000', method='GET', uri='/API/stats', version='HTTP/1.1', remote_ip='::1')
Traceback (most recent call last):
  File "/mnt/STUFF/py36/lib/python3.6/site-packages/tornado/web.py", line 1590, in _execute
    result = method(*self.path_args, **self.path_kwargs)
  File "GTFSManager.py", line 630, in get
    stats = GTFSstats()
  File "<string>", line 263, in GTFSstats
  File "/mnt/STUFF/py36/lib/python3.6/site-packages/pandas/core/generic.py", line 4376, in __getattr__
    return object.__getattribute__(self, name)
AttributeError: 'DataFrame' object has no attribute 'agency_name'
ERROR:tornado.access:500 GET /API/stats (::1) 8.61ms

Have to handle if agency table has no length.

answerquest commented 6 years ago

handled with a check for length of agency dataframe:

agencyDF = readTableDB('agency')
if len(agencyDF):
    ...
    content += 'Agency: {}<br>'.format( ', '.join(agencyList) )
else:
    content += 'Agency: none found.<br>'
answerquest commented 6 years ago

fixed with v3.0.0