NextAstro logo NextAstroDocumentation Open Hub

Python scripting

Protocol and compiled OBS

The public client is a separate standard-library Python package. It communicates with the existing loopback console API. It never imports obs.py, the OBS interpreter, COM drivers, or compiled extension modules from the OBS binary. Student Python and compiled OBS can therefore use different Python versions.

The host is always 127.0.0.1. Only the local console port is configurable. Existing console Origin and CSRF checks are retained: the client obtains /api/bootstrap and includes Origin and X-Console-CSRF on writes. The private bridge credential continues to belong to the existing console transport. No new listener or daemon is installed.

Protocol 1 adds:

Endpoint Contract
GET /api/v1/capabilities student_client.protocol_version=1 and filters
POST /api/v1/student/connect JSON session request; live newline-delimited JSON handover/status response
POST /api/v1/student/{id}/close Finish and release this session
POST /api/v1/student/{id}/cancel Request cancellation of this session
POST /api/v1/commands Existing journal, with action=student_operation and structured session/operation parameters
GET /api/v1/commands/{id} Existing command result, including saved-image metadata

Only the OBS foreground control loop executes operations. HTTP admission does not move equipment. Existing command-ID deduplication applies, and journalled unfinished work becomes interrupted after restart instead of being replayed. There is no arbitrary Python-code, pickle or module-execution endpoint.

The Nuitka build explicitly includes obs_script_sessions, student_operations and nextastro_obs_client. Copy-StudentObsClient stages the readable client, examples and this docs directory in student_python/nextastro_obs_client beside obs.exe, so a normal Python interpreter can import it. This separate import root avoids loading OBS's interpreter-specific DLLs/extensions into student Python. Use student_python on the import path and launch student Python from the student's working directory. The existing compiled publisher includes that distribution in its normal archive. Keep the source checkout as the development copy; changes to OBS runtime code require a new binary build, while student scripts remain Python.

The current Node proxy already forwards /api/v1/* and propagates a closed stream to the private bridge, so these endpoints require no frontend asset rebuild. The OBS executable must still be rebuilt/deployed for the runtime changes. Source tests and simulated localhost transport are separate evidence from a complete Nuitka OBS build and physical-equipment verification.