Add debug info for when a bus's headsign isnt found.

This commit is contained in:
Nahuel Lofeudo 2023-06-24 05:26:52 +01:00
parent 053e1191e0
commit f8857b3015
2 changed files with 8 additions and 6 deletions

View File

@ -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]:

View File

@ -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)