diff --git a/mcp/stopp.py b/mcp/stopp.py index ce6c22f7..5f56d8cb 100644 --- a/mcp/stopp.py +++ b/mcp/stopp.py @@ -25,20 +25,9 @@ def ist_gestoppt(): def stopp_setzen(): """Legt an allen Stopp-Pfaden die Not-Aus-Datei an.""" - for p in STOPP_PFADE: - os.makedirs(os.path.dirname(p), exist_ok=True) - try: - with open(p, "w", encoding="utf-8") as f: - f.write("not-aus") - except OSError: - pass + return notaus.setzen(STOPP_PFADE) def stopp_aufheben(): """Entfernt alle Not-Aus-Dateien.""" - for p in STOPP_PFADE: - if os.path.exists(p): - try: - os.remove(p) - except OSError: - pass + notaus.aufheben(STOPP_PFADE) diff --git a/sicht/steuern.py b/sicht/steuern.py index 1a5c7351..487d5532 100644 --- a/sicht/steuern.py +++ b/sicht/steuern.py @@ -3,7 +3,9 @@ Jede Funktion gibt {"ok": bool, "text": Deutsch,...} zurueck und wirft nie. Alles Schwere wird erst im Knopf importiert: ohne Klon, ohne Mac, ohne Laeufer startet das Cockpit trotzdem. - not_aus_setzen / not_aus_loeschen mcp/stopp.py (dieselben Dateien wie der Laeufer) + not_aus_setzen / not_aus_loeschen mcp/stopp.py (dieselben Dateien wie der Laeufer); + setzen geht dann weiter an hand/notaus.py: alle Tische + aussetzen, kein Fenster nach vorn laeufer_starten / laeufer_stoppen betrieb/runner.py --act als Kindprozess, PID in sicht/scratch/laeufer.pid zuschauer_starten / zuschauer_stoppen betrieb/zuschauer_lauf.py als Kindprozess: liest nur, klickt nie @@ -78,6 +80,11 @@ def _stopp(): return _modul_aus_datei("cockpit_stopp", os.path.join(WURZEL, "mcp", "stopp.py")) +def _notaus(): + """Der eine Griff (hand/notaus.py) - Datei, aussetzen, schliessen, hart.""" + return _modul_aus_datei("cockpit_notaus", os.path.join(WURZEL, "hand", "notaus.py")) + + def _antwort(ok, text, **mehr): d = {"ok": bool(ok), "text": text} d.update(mehr) @@ -91,13 +98,27 @@ def _fehler(was, e): # ---- Not-Aus --------------------------------------------------------------------------------- def not_aus_setzen(): + """Die Dateien zuerst (sie wirken sofort), dann der Kanal: alle Tische aussetzen. + + Der Kanal holt kein Fenster nach vorn - der Not-Aus ist scharf, auch wenn die Tische hinten + stehen. Bleibt der Kanal stumm, raeumt `notaus` hart nach (hand/notaus.py).""" try: s = _stopp() s.stopp_setzen() gesetzt = s.ist_gestoppt() - return _antwort(gesetzt, "Not-Aus gesetzt" if gesetzt else "Not-Aus liess sich nicht schreiben") except Exception as e: return _fehler("Not-Aus setzen", e) + text = "Not-Aus gesetzt" if gesetzt else "Not-Aus liess sich nicht schreiben" + try: + bericht = _notaus().notaus() + aus = sum(1 for ok in bericht.get("aussetzen", {}).values() if ok) + if aus: + text += f" - {aus} Tisch(e) ausgesetzt" + if bericht.get("pkill"): + text += f", {len(bericht['pkill'])} Tischprozess(e) hart beendet" + except Exception: + pass # die Datei steht, der Kanal ist die Zugabe + return _antwort(gesetzt, text) def not_aus_loeschen():