diff --git a/buba/animations/dbf.py b/buba/animations/dbf.py index 0b4b816..421da64 100644 --- a/buba/animations/dbf.py +++ b/buba/animations/dbf.py @@ -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): - self.fetch() + 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()