Skip to content

Add remote Python TCP server for controlling the app, view, and operations #118

Description

@trailcode

EzyCad currently supports an in-app Python console for controlling the application, view, sketches, shapes, and operations via an embedded interpreter with pybind11 bindings (ezy., view., Shp, etc.).

This issue tracks adding a remote server mode so the app can act as both a desktop GUI application and a headless/controllable server:

  • Launch with --listen [host:]port (e.g. --listen 8765 or --listen 0.0.0.0:12345) to start a background TCP server.
  • The server accepts Python source code snippets over a simple length-prefixed protocol.
  • Code is executed in the same embedded Python environment (reusing existing bindings and __main__.ezy / view objects).
  • Execution is marshaled safely to the main thread via PythonExecutionQueue + process_pending() (critical because OCCT AIS viewer and ImGui are not thread-safe).
  • Supports both GUI + server (live control of running app) and future full --headless mode.
  • Reference client added in scripts/remote_ezy_client.py.
  • Debug logging and error handling for socket issues on Windows.
  • Early Python interpreter init when server is enabled.
  • Extended Python API (e.g. view.fit_all(), view.screenshot(), camera getters/setters, shape access).

Usage:

  • Build with EZYCAD_ENABLE_PYTHON=ON (already required for console).
  • EzyCad.exe --listen 127.0.0.1:8765 (GUI + server).
  • Connect with client and send code like view.fit_all(), ezy.msg("hello from remote"), shape creation, etc.
  • Blank line to execute.

Related:

  • agents/dev.md updated with testing instructions.
  • See src/python_remote_server.*, updates to main.cpp, python_console.cpp, occt_view.*.

Current status: Functional prototype. Listener works when launched with correct cwd (resources) and after rebuild. Python init shows a benign "platform independent libraries" warning in early force-init path. Client connects once listener is up. Needs testing for full headless, more API exposure, security (localhost by default), and production hardening.

This enables automation, remote control, scripting from external tools, web frontends, etc., while keeping the rich native GUI.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions