vingerha / gtfs2

Support GTFS in Home Assistant GUI-only
https://github.com/vingerha/gtfs2
MIT License
65 stars 4 forks source link

GTFS zip files not working? #67

Closed huggenknubbel closed 2 months ago

huggenknubbel commented 2 months ago

Describe the bug tried it with two gtfs zip files. first with lvb.zip and second with mdv.zip. with the first, the zip import runs fine. but if i want to create an sensor with a stop described like here, there were no data and no sensor created. If im set the radius higher, i can't save beceause there are to many stops in the radius. So it found some stops but shows nothing

So i tried the mdv.zip But can't import them breceause:

AttributeError: 'str' object has no attribute 'engine'
2024-04-29 10:28:31.922 WARNING (SyncWorker_4) [custom_components.gtfs2.gtfs_helper] Cannot use this datasource as still unpacking: mdv
2024-04-29 10:28:31.928 ERROR (MainThread) [aiohttp.server] Error handling request
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_protocol.py", line 452, in _handle_request
    resp = await request_handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_app.py", line 543, in _handle
    resp = await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/site-packages/aiohttp/web_middlewares.py", line 114, in impl
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/security_filter.py", line 92, in security_filter_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/forwarded.py", line 83, in forwarded_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/request_context.py", line 26, in request_context_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/ban.py", line 88, in ban_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/auth.py", line 236, in auth_middleware
    return await handler(request)
           ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/headers.py", line 32, in headers_middleware
    response = await handler(request)
               ^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/http.py", line 73, in handle
    result = await handler(request, **request.match_info)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/decorators.py", line 71, in with_admin
    return await func(self, request, *args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/config/config_entries.py", line 222, in post
    return await super().post(request, flow_id)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/components/http/data_validator.py", line 73, in wrapper
    result = await method(view, request, data, *args, **kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/helpers/data_entry_flow.py", line 122, in post
    result = await self._flow_mgr.async_configure(flow_id, data)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 356, in async_configure
    result = await self._async_configure(flow_id, user_input)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 402, in _async_configure
    result = await self._async_handle_step(
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/src/homeassistant/homeassistant/data_entry_flow.py", line 506, in _async_handle_step
    result: _FlowResultT = await getattr(flow, method)(user_input)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gtfs2/config_flow.py", line 133, in async_step_local_stops
    stop_limit = await _check_stop_list(self, self._user_inputs)
                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gtfs2/config_flow.py", line 500, in _check_stop_list
    count_stops = await self.hass.async_add_executor_job(
                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.12/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gtfs2/gtfs_helper.py", line 725, in get_local_stop_list
    result = schedule.engine.connect().execute(
             ^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'engine'

Release used Core 2024.4.4 Supervisor 2024.04.0 GTFS: 0.4.5

Additional

vingerha commented 2 months ago

On the first one, I have no clue, it seems indeed to extract fine but I also donot see a thing created. Probably the data is not good...I can check later this week

The second one, the error is related to the situation where the data is still being etxracted. I will add a check to avoid this. But.... on the second one there is also this error with me and although I can open it via my laptop, the app below cannot.

2024-04-29 13:04:33.787 DEBUG (SyncWorker_4) [custom_components.gtfs2.gtfs_helper] Getting gtfs with data: {'extract_from': 'url', 'file': 'leipzig2', 'url': 'https://www.mdv.de/site/uploads/gtfs_mdv.zip'}
2024-04-29 13:04:33.788 DEBUG (SyncWorker_4) [custom_components.gtfs2.gtfs_helper] Checking if extracting: leipzig2
Process Process-2:
Traceback (most recent call last):
  File "/usr/local/lib/python3.12/multiprocessing/process.py", line 314, in _bootstrap
    self.run()
  File "/usr/local/lib/python3.12/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
  File "/config/custom_components/gtfs2/gtfs_helper.py", line 426, in extract_from_zip
    clean = remove_from_zip(remove_file,gtfs_dir, file[:-4])
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gtfs2/gtfs_helper.py", line 439, in remove_from_zip
    zin = zipfile.ZipFile (f"{os.path.join(gtfs_dir, tempfile)}", 'r')
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gtfs2/zip_file.py", line 1262, in __init__
    self._RealGetContents()
  File "/config/custom_components/gtfs2/zip_file.py", line 1329, in _RealGetContents
    raise BadZipFile("File is not a zip file")
custom_components.gtfs2.zip_file.BadZipFile: File is not a zip file

via the link in the doc (gtfs.pro) I found this one... not sure if this is better or not https://gtfs.pro/en/germany/Mitteldeutscher-Verkehrsverbund/mdv

vingerha commented 2 months ago

Tried the 2nd one for this zone below, give me multiple responses... image

vingerha commented 2 months ago

And please use 0.4.5.2 to avoid hitting the limit

huggenknubbel commented 2 months ago

thanks, i will give them a try!

vingerha commented 2 months ago

Closing as not reproducable with given sources via gtfs.pro