Make updates more resilient
All checks were successful
docker-image / docker (push) Successful in 9m58s

This commit is contained in:
Stefan Bethke 2025-06-07 17:10:53 +02:00
commit 3ac33f18b3

View file

@ -16,6 +16,7 @@ from buba.bubacmd import BubaCmd
class DBFAnimation(BubaAnimation):
def __init__(self, buba: BubaCmd, ds100="AHST", station="Holstenstraße", count=3):
super().__init__(buba)
self.dbi = DBInfoscreen("trains.xatlabs.com")
self.ds100 = ds100
self.station = station
self.trains = []
@ -26,14 +27,16 @@ class DBFAnimation(BubaAnimation):
return f"<{type(self).__name__}, {self.ds100}>"
def fetch(self):
dbi = DBInfoscreen("trains.xatlabs.com")
trains = dbi.calc_real_times(dbi.get_trains(self.ds100)) # Station
trains = [t for t in trains] # if t['platform'] == "1"] # platform gleis
trains.sort(key=dbi.time_sort)
trains = self.dbi.calc_real_times(self.dbi.get_trains(self.ds100)) # Station
# trains = [t for t in trains] # if t['platform'] == "1"] # platform gleis
trains.sort(key=self.dbi.time_sort)
self.trains = trains
def update(self):
try:
self.fetch()
except Exception:
pass
sleep(60)
@staticmethod
@ -65,9 +68,6 @@ class DBFAnimation(BubaAnimation):
# Recalculate the timedelta
return BubaAnimation.countdown(datetime.datetime.combine(dep_date, dep_time))
# dep_td = datetime.datetime.combine(dep_date, dep_time) - now
# return round(dep_td.total_seconds() / 60)
@staticmethod
def short_station(station: str) -> str:
station = station.strip()