0
0
Fork 0
Codesys-MCP-SP21-plus/src/scripts/open_project.py
Luke e374519fe1 Initial release: MCP server for CODESYS with persistent UI instance
v0.3.0 returning-watcher architecture — background thread polls for commands
and marshals execution onto the CODESYS UI thread, keeping the IDE fully
responsive between operations. File-based IPC with atomic writes, async mutex
command serialization, headless fallback, and 35 passing tests.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-08 18:59:16 +10:00

19 lines
847 B
Python

import sys, scriptengine as script_engine, os, traceback
try:
project = ensure_project_open(PROJECT_FILE_PATH)
# Get name from object if possible, otherwise use path basename
proj_name = "Unknown"
try:
if project: proj_name = project.get_name() or os.path.basename(PROJECT_FILE_PATH)
else: proj_name = os.path.basename(PROJECT_FILE_PATH) + " (ensure_project_open returned None?)"
except Exception:
proj_name = os.path.basename(PROJECT_FILE_PATH) + " (name retrieval failed)"
print("Project Opened: %s" % proj_name)
print("SCRIPT_SUCCESS: Project opened successfully.")
sys.exit(0)
except Exception as e:
error_message = "Error opening project %s: %s" % (PROJECT_FILE_PATH, e)
print(error_message)
traceback.print_exc()
print("SCRIPT_ERROR: %s" % error_message); sys.exit(1)