From 6a72f2e1da85bf4e21e297ee26f3a980909f6ab7 Mon Sep 17 00:00:00 2001 From: Julian Metzler Date: Sat, 6 Mar 2021 21:48:22 +0100 Subject: [PATCH] Add second display setup, rename to .pyw --- run.py => run.pyw | 33 ++++++++++++++++++++++++++++++--- 1 file changed, 30 insertions(+), 3 deletions(-) rename run.py => run.pyw (60%) diff --git a/run.py b/run.pyw similarity index 60% rename from run.py rename to run.pyw index bab99df..8529eec 100644 --- a/run.py +++ b/run.pyw @@ -8,17 +8,25 @@ from vag_zza import VagZza from station_map import * +import sys, os +if sys.executable.endswith("pythonw.exe"): + sys.stdout = open(os.devnull, "w"); + sys.stderr = open(os.path.join(os.getenv("TEMP"), "stderr-"+os.path.basename(sys.argv[0])), "w") + def display_train(zza, train): line = train['Linienname'] via = "" - dest = zza.get_closest_destination(train['Richtungstext']) + if train['Richtungstext'] == "Flughafen": + dest = "Bitte achten Sie auf die Zugbeschilderung" + else: + dest = zza.get_closest_destination(train['Richtungstext']) if line == "U1": + # Standort Maximilianstraße if dest not in ("Langwasser-Süd", "Fürth Hardhöhe"): line = "U11" - # Via für Standort Maximilianstraße if dest in ("Fürth Hardhöhe", "Fürth Klinikum", "Fürth / Stadthalle"): via = "Stadtgrenze - Fürth / Hauptbahnhof" elif dest in ("Fürth / Hauptbahnhof", "Jakobinenstraße"): @@ -30,6 +38,18 @@ def display_train(zza, train): elif dest in ("Scharfreiterring", "Langwasser-Süd"): via = "Plärrer - Hauptbahnhof - Messe" + if line == "U2": + # Standort Rennweg + if dest not in ("Bitte achten Sie auf die Zugbeschilderung", "Röthenbach"): + line = "U21" + + if dest in ("Hauptbahnhof", "Plärrer"): + via = "Rathenauplatz" + elif dest in ("St. Leonhard", "Schweinau"): + via = "Rathenauplatz - Hauptbahnhof - Plärrer" + elif dest in ("Hohe Marter", "Röthenbach"): + via = "Rothenburgerstraße - Schweinau" + if dest == "": line = "Sonderzug" dest = "Bitte achten Sie auf die Zugbeschilderung" @@ -44,6 +64,7 @@ def main(): parser = argparse.ArgumentParser() parser.add_argument("-p", "--port", type=str, required=True, help="Serial port for display") parser.add_argument("-s", "--station", type=str, required=True, help="Station name to display departures of") + parser.add_argument("-pl", "--platform", type=int, required=True, help="Which platform the display is on") args = parser.parse_args() api = VagApi() @@ -55,7 +76,13 @@ def main(): station_id = api.get_station_info(args.station)[0]['VGNKennung'] departures = api.get_departures(station_id, products=["Ubahn"]) - train = departures[0] + if len(departures) == 0: + train = { + "Linienname": "", + "Richtungstext": f"Betriebsschluß Gleis {args.platform}" + } + else: + train = departures[0] zza = VagZza(args.port) pprint(train)