i3pystatus: fix Exception on empty arrival time

This commit is contained in:
Franzi 2022-03-26 18:18:50 +01:00
parent 9f83f9e908
commit 57c5e442a9
Signed by: kunsi
GPG key ID: 12E3D2136B818350

View file

@ -1,6 +1,6 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
from datetime import datetime from datetime import datetime, timedelta
from requests import get from requests import get
from subprocess import check_output from subprocess import check_output
from sys import exit from sys import exit
@ -52,8 +52,12 @@ try:
else: else:
delay = '' delay = ''
if stop['timetable'].get('actualArrivalTime', 0):
arrival = datetime.fromtimestamp(stop['timetable']['actualArrivalTime']/1000) arrival = datetime.fromtimestamp(stop['timetable']['actualArrivalTime']/1000)
arrival_in = arrival - now arrival_in = arrival - now
else:
arrival = datetime.now()
arrival_in = timedelta()
next_stop = '{} <span color="#999999">[{}]</span> {} ({}{})'.format( next_stop = '{} <span color="#999999">[{}]</span> {} ({}{})'.format(
stop['station']['name'], stop['station']['name'],