vingerha/gtfs2

Cannot delete data source

Closed this issue · 2 comments

Describe the bug
I setup a data source from the UK GTFS data for England. It downloaded a 557Meg file, but only created a 188K sqlite. So, I assume something has failed (there's no journal.) I tried creating a stop, but it comes up blank and no sensors are available. I therefore removed those stops (I created one on a person and one for my home) and then proceeded to remove the source. When I go I get an error. In the logs it shows it was not able to find the file.

Steps/data to reproduce the behavior, e.g.

image

image

The Log shows

image

Release used
Which gtfs2 release and HA type (HAOS/Container)
GTFS 0.4.0
HA 2024.3.1 Core Container on Kubernetes w 3 gigs free space. (Maybe this is problem?)

Additional
Please add logs if helpful

From screenshot above

Logger: custom_components.gtfs2.config_flow
Source: custom_components/gtfs2/config_flow.py:174
integration: GTFS 2 (General Transit Feed Specification) ([documentation](https://github.com/vingerha/gtfs2/wiki), [issues](https://github.com/vingerha/gtfs2/issues))
First occurred: 15:26:45 (5 occurrences)
Last logged: 15:38:41

Error while deleting : {FileNotFoundError(2, 'No such file or directory')}

File sizes.

pbulteel@lasst263701:~/homeassistant/gtfs2$ ls -lh
total 557M
-rw-r--r-- 1 nobody nogroup 188K Mar 19 22:39 England.sqlite
-rw-r--r-- 1 nobody nogroup 633K Mar 19 22:39 England_temp_out.zip
-rw-r--r-- 1 nobody nogroup 557M Mar 19 22:39 England_temp.zip

HA logs - before this error occurred

2024-03-20 08:13:56.979 ERROR (MainThread) [custom_components.gtfs2.gtfs_helper] The given GTFS zipfile was not found
2024-03-20 08:13:56.981 ERROR (MainThread) [custom_components.gtfs2.coordinator] Unexpected error fetching 65ecea53fb800bf584ca958e7a4b817f data: 'str' object has no attribute 'engine'
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 318, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gtfs2/coordinator.py", line 211, in _async_update_data
    self._data["local_stops_next_departures"] = 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 784, in get_local_stops_next_departures
    result = schedule.engine.connect().execute(
             ^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'engine'
2024-03-20 08:13:57.003 ERROR (MainThread) [homeassistant.components.sensor] Error while setting up gtfs2 platform for sensor
Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 318, in _async_refresh
    self.data = await self._async_update_data()
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/gtfs2/coordinator.py", line 211, in _async_update_data
    self._data["local_stops_next_departures"] = 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 784, in get_local_stops_next_departures
    result = schedule.engine.connect().execute(
             ^^^^^^^^^^^^^^^
AttributeError: 'str' object has no attribute 'engine'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity_platform.py", line 350, in _async_setup_platform
    await asyncio.shield(awaitable)
  File "/config/custom_components/gtfs2/sensor.py", line 77, in async_setup_entry
    await coordinator.async_config_entry_first_refresh()
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 290, in async_config_entry_first_refresh
    raise ex
homeassistant.exceptions.ConfigEntryNotReady: 'str' object has no attribute 'engine'

Hi, I have no access to this source anylonger but reading the 500M+ size... I looked at my table and whatever I tested months ago failed for the 'whole of england'.
Sadly I cannot reproduce this 1-2-3 so you will need to remove it manually from the config/gtfs2 folder
However, before you remove it, can you please let me know which files are present in that folder so I can try to pre-empt on this?

Added. when I examined the UK sources back then, I found others with a smaller coverage, not sure if that would work for you though.

EDIT, I just noticed you sent me the "ls -l" above so I will have a look to fix it....still no solution for your source though

I found the issue, fixed it in a next release (you can test in release (hacs) 'main' if you want)...closing it for now