From 99446845f2a1520bb63ff82599bb6a93e1089a3c Mon Sep 17 00:00:00 2001 From: Rob Holland Date: Tue, 25 Feb 2025 08:20:25 +0000 Subject: [PATCH 1/2] Ensure that the python runs on 3.4 --- thirdparty/train_api.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/thirdparty/train_api.py b/thirdparty/train_api.py index e881c5a..ffe8d6d 100644 --- a/thirdparty/train_api.py +++ b/thirdparty/train_api.py @@ -44,7 +44,9 @@ class TrainServer(BaseHTTPRequestHandler): # Helper to format datetime def format_datetime(year, month, day, hour, minute): - return f"{year:04d}-{month:02d}-{day:02d}T{hour:02d}:{minute:02d}" + return "{year:04d}-{month:02d}-{day:02d}T{hour:02d}:{minute:02d}".format( + year=year, month=month, day=day, hour=hour, minute=minute + ) # Generate outbound journeys year, month, day, hour, minute = out_datetime @@ -60,13 +62,14 @@ class TrainServer(BaseHTTPRequestHandler): # Journey takes 2h15m-2h45m (135-165 minutes) duration = 135 + random.randint(0, 30) + print(duration) arr_hour = adj_hour + (duration // 60) arr_minute = (adj_minute + (duration % 60)) % 60 arr_day = adj_day + (arr_hour // 24) arr_hour = arr_hour % 24 journey = { - "id": f"T{random.randint(1000, 9999)}", + "id": "T%s".format(random.randint(1000, 9999)), "type": "outbound", "departure": origin, "arrival": destination, @@ -99,7 +102,7 @@ class TrainServer(BaseHTTPRequestHandler): arr_hour = arr_hour % 24 journey = { - "id": f"T{random.randint(1000, 9999)}", + "id": "T%s".format(random.randint(1000, 9999)), "type": "return", "departure": destination, "arrival": origin, From be3289710526e54f53e8bfc299285ff061d82be5 Mon Sep 17 00:00:00 2001 From: Rob Holland Date: Tue, 25 Feb 2025 08:21:18 +0000 Subject: [PATCH 2/2] Remove debug aid. --- thirdparty/train_api.py | 1 - 1 file changed, 1 deletion(-) diff --git a/thirdparty/train_api.py b/thirdparty/train_api.py index ffe8d6d..ca6c2ae 100644 --- a/thirdparty/train_api.py +++ b/thirdparty/train_api.py @@ -62,7 +62,6 @@ class TrainServer(BaseHTTPRequestHandler): # Journey takes 2h15m-2h45m (135-165 minutes) duration = 135 + random.randint(0, 30) - print(duration) arr_hour = adj_hour + (duration // 60) arr_minute = (adj_minute + (duration % 60)) % 60 arr_day = adj_day + (arr_hour // 24)