From f1ea6e446f780bde2d0597aae170b496afb1dcc5 Mon Sep 17 00:00:00 2001 From: Karstein Phobic Nyvold Kvistad Date: Sat, 25 Apr 2026 15:10:21 +0200 Subject: [PATCH] fix(watcher): use ASCII-only comments/log strings (IronPython 2.7 syntax error) 0.4.1 used em-dashes (--) in three log strings and one docstring line. IronPython 2.7 (CODESYS scripting host) rejects non-ASCII bytes in a source file unless an explicit encoding declaration (PEP 263) is present: Microsoft.Scripting.SyntaxErrorException: Non-ASCII character '\xe2' in file ...\watcher.py on line 225, but no encoding declared Replaced em-dashes with ASCII '--' and bumped WATCHER_VERSION to 0.4.2. File is now ASCII-clean throughout. Co-Authored-By: Claude Opus 4.7 (1M context) --- src/scripts/watcher.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/scripts/watcher.py b/src/scripts/watcher.py index 042b085..b53cf45 100644 --- a/src/scripts/watcher.py +++ b/src/scripts/watcher.py @@ -25,7 +25,7 @@ IPC_BASE_DIR = r"{IPC_BASE_DIR}" COMMANDS_DIR = os.path.join(IPC_BASE_DIR, "commands") RESULTS_DIR = os.path.join(IPC_BASE_DIR, "results") POLL_INTERVAL = 50 # milliseconds -WATCHER_VERSION = "0.4.1" +WATCHER_VERSION = "0.4.2" # --- Error capture file (written before anything else can fail) --- _ERROR_FILE = os.path.join(IPC_BASE_DIR, "watcher_error.txt") @@ -222,13 +222,13 @@ try: CODESYS injects KeyboardInterrupt into the script when the user clicks "Click here to CANCEL this operation" in the IDE. The - watcher should keep running across that — only an explicit + watcher should keep running across that -- only an explicit terminate.signal or process kill should stop it. """ try: se.system.delay(ms) except KeyboardInterrupt: - _log("KeyboardInterrupt during system.delay() — ignored, watcher continues") + _log("KeyboardInterrupt during system.delay() - ignored, watcher continues") while True: try: @@ -244,7 +244,7 @@ try: if cmd_files: process_command(cmd_files[0]) except KeyboardInterrupt: - _log("KeyboardInterrupt during loop iteration — ignored, watcher continues") + _log("KeyboardInterrupt during loop iteration - ignored, watcher continues") except Exception as e: _log("Loop error: %s\n%s" % (e, traceback.format_exc())) @@ -257,7 +257,7 @@ except KeyboardInterrupt: # Last-resort: a Cancel that fires before the loop is even reached # (e.g. during scriptengine import or directory setup) should still # exit quietly without the CODESYS exception dialog. - _write_error("KeyboardInterrupt outside main loop — exiting quietly") + _write_error("KeyboardInterrupt outside main loop - exiting quietly") print("[WATCHER] Cancelled by user before main loop; exiting.") except Exception as _fatal: _write_error("FATAL: %s\n%s" % (_fatal, traceback.format_exc()))