Skip to content

timetable_helper.get_timetable() throws error #7

@paurf

Description

@paurf

I try to use your code as shown in the demonstration. Is it still maintained?

When I run

from deutsche_bahn_api.api_authentication import ApiAuthentication
from deutsche_bahn_api.station_helper import StationHelper
from deutsche_bahn_api.timetable_helper import TimetableHelper

CLIENT_ID = 
CLIENT_API = 

api = ApiAuthentication(CLIENT_ID, CLIENT_API)
print(api.test_credentials())

station_helper = StationHelper()
found_stations = station_helper.find_stations_by_name("Ulm Hbf")

station = found_stations[0]

print(found_stations)
print(type(found_stations))

timetable_helper = TimetableHelper(station, CLIENT_API)
trains_in_this_hour = timetable_helper.get_timetable()

print(type(trains_in_this_hour))
print(trains_in_this_hour)

I get

True
[Station(EVA_NR=8000170, DS100='TU', IFOPT='de:08421:1008', NAME='Ulm Hbf', Verkehr='FV', Laenge='9,982227', Breite='48,399437', Betreiber_Name='DB Station und Service AG', Betreiber_Nr=6323, Status='')]
<class 'list'>
Traceback (most recent call last):
  File "/home/pi/python/bahn_api/main.py", line 20, in <module>
    trains_in_this_hour = timetable_helper.get_timetable()
  File "/home/pi/.local/lib/python3.9/site-packages/deutsche_bahn_api/timetable_helper.py", line 49, in get_timetable
    trains = elementTree.fromstringlist(self.get_timetable_xml(hour))
  File "/home/pi/.local/lib/python3.9/site-packages/deutsche_bahn_api/timetable_helper.py", line 35, in get_timetable_xml
    headers=self.api_authentication.get_headers()
AttributeError: 'str' object has no attribute 'get_headers'

It seems something might have changed in the API?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions