summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Friesel <derf@finalrewind.org>2021-03-28 21:44:11 +0200
committerDaniel Friesel <derf@finalrewind.org>2021-03-28 21:44:11 +0200
commita7438499c9445da4fb80877c7e867d121b7b65fe (patch)
tree24c1c32d119842870581c406b1f99946176636f0
parenta7021a0d80743f3c7221c7fa07912d3ee12be99c (diff)
lookup-server: handle missing timestamps
-rwxr-xr-xbin/lookup-server13
1 files changed, 11 insertions, 2 deletions
diff --git a/bin/lookup-server b/bin/lookup-server
index 8d26dbe..6e33724 100755
--- a/bin/lookup-server
+++ b/bin/lookup-server
@@ -35,7 +35,10 @@ def set_coarse_location(train):
for i, stopover in enumerate(stopovers):
if stopover["departure"]:
- stopover["departure"] = dateutil.parser.parse(stopover["departure"])
+ try:
+ stopover["departure"] = dateutil.parser.parse(stopover["departure"])
+ except TypeError:
+ return
# start with origin. (planned)arrival is always null in a previousStopovers list
departure = stopover["departure"]
@@ -70,7 +73,13 @@ def set_coarse_location(train):
train["stop"]["location"]["longitude"],
),
)
- train_times = (stopovers[-1]["departure"], dateutil.parser.parse(train["when"]))
+ try:
+ train_times = (
+ stopovers[-1]["departure"],
+ dateutil.parser.parse(train["when"]),
+ )
+ except TypeError:
+ return
if not train_times[0]:
return