From f8857b3015e1544a39cda04268586e87f5dceb06 Mon Sep 17 00:00:00 2001 From: Nahuel Lofeudo Date: Sat, 24 Jun 2023 05:26:52 +0100 Subject: [PATCH] Add debug info for when a bus's headsign isnt found. --- gtfs_client.py | 9 ++++++++- main.py | 5 ----- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/gtfs_client.py b/gtfs_client.py index 7f6837d..bad1b83 100644 --- a/gtfs_client.py +++ b/gtfs_client.py @@ -8,6 +8,7 @@ import pandas as pd import queue import refresh_feed import requests +import sys import time import threading import traceback @@ -242,7 +243,13 @@ class GTFSClient(): Look up a destination string in Trips from the route and direction """ trips = self.feed.trips - return trips[(trips["route_id"] == route_id) & (trips["direction_id"] == direction_id)].head(1)["trip_headsign"].item() + destination = trips[(trips["route_id"] == route_id) & (trips["direction_id"] == direction_id)].head(1)["trip_headsign"].item() + # For some reason destination sometimes isn't a string. Try to find out why + if not destination.__class__ == str: + sys.stderr.write("Destination not found for route " + str(route_id) + ", direction " + str(direction_id) + "\n") + destination = "---- ?????? ----" + + return destination def __poll_gtfsr_deltas(self) -> list[map, set]: diff --git a/main.py b/main.py index 9ee431a..35b8067 100755 --- a/main.py +++ b/main.py @@ -47,11 +47,6 @@ def write_entry(line: int, time_color: Color = COLOR_LCD_AMBER, text_color: Color = COLOR_LCD_AMBER): """ Draws on the screen buffer an entry corresponding to an arrival time. """ - # For some reason destination sometimes isn't a strint. Try to find out why - if not destination.__class__ == str: - print("Destination is not a string. Class: " + str(destination.__class__) + ". Value: " + str(destination)) - destination = "---- ?????? ----" - # Step 1: Render the fragments route_img = font.render(route[0:4], True, text_color) destination_img = font.render(destination[0:21], True, text_color)