Fixed station monitor to be compatible with the backend. i tired, i eeps.

This commit is contained in:
mia 2026-06-07 22:14:24 +02:00
parent ee6082bf25
commit 45e177125c

View file

@ -15,7 +15,6 @@ from prompt_toolkit.layout.containers import Window, VSplit, HSplit
from prompt_toolkit.layout.controls import BufferControl
from prompt_toolkit.key_binding import KeyBindings
import threading
import time
def run_station_monitor(hafas: backend.HafasClient | None = None):
@ -71,36 +70,37 @@ def run_station_monitor(hafas: backend.HafasClient | None = None):
user_input = userinputBuffer.text.strip()
if user_input:
if not user_input:
app_state = "MONITOR"
return
app_state = "RESULTS"
results = hafas.getStationNames(user_input)
if not results:
arrivalBuffer.text = f"Keine Stationen gefunden für: {user_input}"
departureBuffer.text= ""
userinputBuffer.text=""
departureBuffer.text = ""
userinputBuffer.text = ""
app_state = "MONITOR"
return
else:
station_name = results[0][1]
station_id = results[0][0]
station_name = results[0][0]
station_id = results[0][1]
arrivals = hafas.getArrDep(station_id, arrdep="ARR", count=3)
arrivalBuffer.text = f"Ankünfte für {station_name}:\n"
for arrival in arrivals:
arrivalBuffer.insert_text(f"\n {arrival}")
departures = hafas.getArrDep(station_id, arrdep="DEP", count=3)
departureBuffer.text = f"Abfahrten für {station_name}:\n"
for departure in departures:
departureBuffer.insert_text(f"\n {departure}")
arrivals = hafas.getArrDep(station_id, arrdep="ARR", count=5)
arrivalBuffer.text = (
f"Ankünfte für {station_name}:\n"
+ "\n".join(f" {arrival["departure_time"]} {arrival["line"]} --> {arrival["name"]}" for arrival in arrivals)
)
departures = hafas.getArrDep(station_id, arrdep="DEP", count=5)
departureBuffer.text = (
f"Abfahrten für {station_name}:\n"
+ "\n".join(f" {departure["departure_time"]} {departure["line"]} --> {departure["name"]}" for departure in departures)
)
userinputBuffer.text = ""
else:
app_state = "MONITOR"
@keyB.add("c-q")
def exit_(event):