From 57c5e442a9d6a041842d69bd75e932b862b7c4dd Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Sat, 26 Mar 2022 18:18:50 +0100 Subject: [PATCH] i3pystatus: fix Exception on empty arrival time --- .config/i3pystatus/ice-status.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.config/i3pystatus/ice-status.py b/.config/i3pystatus/ice-status.py index 1f41417..195dbff 100755 --- a/.config/i3pystatus/ice-status.py +++ b/.config/i3pystatus/ice-status.py @@ -1,6 +1,6 @@ #!/usr/bin/env python3 -from datetime import datetime +from datetime import datetime, timedelta from requests import get from subprocess import check_output from sys import exit @@ -52,8 +52,12 @@ try: else: delay = '' - arrival = datetime.fromtimestamp(stop['timetable']['actualArrivalTime']/1000) - arrival_in = arrival - now + if stop['timetable'].get('actualArrivalTime', 0): + arrival = datetime.fromtimestamp(stop['timetable']['actualArrivalTime']/1000) + arrival_in = arrival - now + else: + arrival = datetime.now() + arrival_in = timedelta() next_stop = '{} [{}] {} ({}{})'.format( stop['station']['name'],