Make updates more resilient
All checks were successful
docker-image / docker (push) Successful in 9m58s
All checks were successful
docker-image / docker (push) Successful in 9m58s
This commit is contained in:
parent
58f5f5cd4b
commit
3ac33f18b3
1 changed files with 8 additions and 8 deletions
|
@ -16,6 +16,7 @@ from buba.bubacmd import BubaCmd
|
||||||
class DBFAnimation(BubaAnimation):
|
class DBFAnimation(BubaAnimation):
|
||||||
def __init__(self, buba: BubaCmd, ds100="AHST", station="Holstenstraße", count=3):
|
def __init__(self, buba: BubaCmd, ds100="AHST", station="Holstenstraße", count=3):
|
||||||
super().__init__(buba)
|
super().__init__(buba)
|
||||||
|
self.dbi = DBInfoscreen("trains.xatlabs.com")
|
||||||
self.ds100 = ds100
|
self.ds100 = ds100
|
||||||
self.station = station
|
self.station = station
|
||||||
self.trains = []
|
self.trains = []
|
||||||
|
@ -26,14 +27,16 @@ class DBFAnimation(BubaAnimation):
|
||||||
return f"<{type(self).__name__}, {self.ds100}>"
|
return f"<{type(self).__name__}, {self.ds100}>"
|
||||||
|
|
||||||
def fetch(self):
|
def fetch(self):
|
||||||
dbi = DBInfoscreen("trains.xatlabs.com")
|
trains = self.dbi.calc_real_times(self.dbi.get_trains(self.ds100)) # Station
|
||||||
trains = dbi.calc_real_times(dbi.get_trains(self.ds100)) # Station
|
# trains = [t for t in trains] # if t['platform'] == "1"] # platform gleis
|
||||||
trains = [t for t in trains] # if t['platform'] == "1"] # platform gleis
|
trains.sort(key=self.dbi.time_sort)
|
||||||
trains.sort(key=dbi.time_sort)
|
|
||||||
self.trains = trains
|
self.trains = trains
|
||||||
|
|
||||||
def update(self):
|
def update(self):
|
||||||
self.fetch()
|
try:
|
||||||
|
self.fetch()
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
sleep(60)
|
sleep(60)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
|
@ -65,9 +68,6 @@ class DBFAnimation(BubaAnimation):
|
||||||
# Recalculate the timedelta
|
# Recalculate the timedelta
|
||||||
return BubaAnimation.countdown(datetime.datetime.combine(dep_date, dep_time))
|
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
|
@staticmethod
|
||||||
def short_station(station: str) -> str:
|
def short_station(station: str) -> str:
|
||||||
station = station.strip()
|
station = station.strip()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue