some logging improvements

This commit is contained in:
Kaaninchen
2026-08-18 20:44:54 +02:00
parent 6006a561b2
commit d46a04af0c
2 changed files with 3 additions and 5 deletions
-2
View File
@@ -135,7 +135,6 @@ def get_random_stop_id() -> str | None:
if stop_name == assigned_station: if stop_name == assigned_station:
stop_ids.clear() stop_ids.clear()
logger(f"Exact match found! Using {stop_name}")
stop_ids[stop_id] = stop_name stop_ids[stop_id] = stop_name
break break
@@ -148,7 +147,6 @@ def get_random_stop_id() -> str | None:
logger(f"No station associated as '{assigned_station}', choosing random from similar named stations") logger(f"No station associated as '{assigned_station}', choosing random from similar named stations")
logger(f"Run `python run main.py stations` to get exact station names") logger(f"Run `python run main.py stations` to get exact station names")
chosen_stop_id, chosen_station = random.choice(list(stop_ids.items())) chosen_stop_id, chosen_station = random.choice(list(stop_ids.items()))
logger(f"Assigned Station: {chosen_station}")
return chosen_stop_id return chosen_stop_id
def get_random_connection(stop_id: str) -> str | None: def get_random_connection(stop_id: str) -> str | None:
+3 -3
View File
@@ -39,7 +39,7 @@ def validate_connection(start_time: str, end_time: str, departure_time_iso: str)
max_wait_time = config.connections.max_wait_time max_wait_time = config.connections.max_wait_time
if max_wait_time: if max_wait_time:
if start_dt > now + timedelta(hours=max_wait_time): if start_dt > now + timedelta(hours=max_wait_time):
logger(f"Connection is way too far in the future: {start_dt} (max_wait_time: {max_wait_time}h)", "error") logger(f"Connection is way too far in the future: {start_dt} (max_wait_time: {max_wait_time}h), retrying...", "error")
return False return False
departure_time_iso_dt = datetime.fromisoformat(departure_time_iso.replace("Z", "+00:00")) departure_time_iso_dt = datetime.fromisoformat(departure_time_iso.replace("Z", "+00:00"))
@@ -49,14 +49,14 @@ def validate_connection(start_time: str, end_time: str, departure_time_iso: str)
min_duration = config.connections.min_duration min_duration = config.connections.min_duration
min_duration_seconds = min_duration * 60 min_duration_seconds = min_duration * 60
if trip_duration < min_duration_seconds: if trip_duration < min_duration_seconds:
logger(f"Connection is with {trip_duration_minutes} minutes too short (configured to {min_duration} minutes or more)", "error") logger(f"Connection is with {trip_duration_minutes} minutes too short (configured to {min_duration} minutes or more), retrying...", "error")
return False return False
max_duration = config.connections.max_duration max_duration = config.connections.max_duration
if max_duration: if max_duration:
max_duration_seconds = max_duration * 60 max_duration_seconds = max_duration * 60
if max_duration_seconds < trip_duration: if max_duration_seconds < trip_duration:
logger(f"Connection is with {trip_duration_minutes} too long (configured to {max_duration} minutes at most)", "error") logger(f"Connection is with {trip_duration_minutes} too long (configured to {max_duration} minutes at most), retrying...", "error")
return False return False
return True return True