chrisys / train-departure-display

A replica, near real-time, miniature UK railway station train departure sign based upon a Raspberry Pi Zero and 256x64 SPI OLED display
245 stars 76 forks source link

Fix for rare crash when update happens as a train is leaving #95

Closed CalamityJames closed 1 year ago

CalamityJames commented 1 year ago

Was working on this repo for another feature addition with a friend, so had the refreshTime set to 30 seconds, and every now and again the display would crash out with a KeyError on lt7:et.

File "/home/james/train-departure-display/src/trains.py", line 35, in prepareLocationName
    expected_time = location["lt7:et"]
KeyError: 'lt7:et'

Did some delving into the API docs and it seems that the API either returns an estimated time, or an actual time, hence the crash when it couldn't find the 'et' key.

image

This PR should fix that, I've watched it happen in the last few minutes and the display didn't crash!

CalamityJames commented 1 year ago

Superseded by #96