Created
November 12, 2020 02:43
-
-
Save hawkins/b4a8f1625d950c15dd5ec9b6182730a8 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import time | |
from config import config | |
from train_board import TrainBoard | |
from metro_api import MetroApi, MetroApiOnFireException | |
STATION_CODE = config["metro_station_code"] | |
TRAIN_GROUP = config["train_group"] | |
REFRESH_INTERVAL = config["refresh_interval"] | |
def refresh_trains() -> [dict]: | |
try: | |
return MetroApi.fetch_train_predictions(STATION_CODE, TRAIN_GROUP) | |
except MetroApiOnFireException: | |
print("WMATA Api is currently on fire. Trying again later ...") | |
return None | |
train_board = TrainBoard(refresh_trains) | |
while True: | |
train_board.refresh() | |
time.sleep(REFRESH_INTERVAL) | |
# Blink the trains | |
train_board.clear() | |
time.sleep(REFRESH_INTERVAL) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment