i3pystatus: fix Exception on empty arrival time
This commit is contained in:
parent
9f83f9e908
commit
57c5e442a9
1 changed files with 7 additions and 3 deletions
|
@ -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 = ''
|
||||||
|
|
||||||
arrival = datetime.fromtimestamp(stop['timetable']['actualArrivalTime']/1000)
|
if stop['timetable'].get('actualArrivalTime', 0):
|
||||||
arrival_in = arrival - now
|
arrival = datetime.fromtimestamp(stop['timetable']['actualArrivalTime']/1000)
|
||||||
|
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'],
|
||||||
|
|
Loading…
Reference in a new issue