necst.web.progress_manager

Managed progress-monitor lifecycle helpers for the NECST Operator Console.

The operator console may open a progress monitor in two different situations:

  • a progress.py web server is already running outside the console;

  • the console starts its own progress.py server for operator convenience.

Only the second case is owned by this console process. Therefore console shutdown must stop only the process that the console launched, and must leave an external progress monitor untouched.

class ProgressMonitorState(url, running=False, owned_by_console=False, pid=None, status='unknown', message='', health=<factory>, stdout_path=None, stderr_path=None, command=<factory>, started_at=None, returncode=None)[source]

Bases: object

Small JSON-serialisable snapshot of progress-monitor ownership.

Parameters:
  • url (str) –

  • running (bool) –

  • owned_by_console (bool) –

  • pid (Optional[int]) –

  • status (str) –

  • message (str) –

  • health (Dict[str, Any]) –

  • stdout_path (Optional[str]) –

  • stderr_path (Optional[str]) –

  • command (List[str]) –

  • started_at (Optional[float]) –

  • returncode (Optional[int]) –

url: str
running: bool = False
owned_by_console: bool = False
pid: Optional[int] = None
status: str = 'unknown'
message: str = ''
health: Dict[str, Any]
stdout_path: Optional[str] = None
stderr_path: Optional[str] = None
command: List[str]
started_at: Optional[float] = None
returncode: Optional[int] = None
to_dict()[source]
Return type:

Dict[str, Any]

class ProgressMonitorManager(*, progress_script, progress_root, host, port, url=None, log_dir=None, refresh_ms=500, no_ros=False, quiet=True, python_executable=None)[source]

Bases: object

Start, detect, and stop a progress.py web server when appropriate.

Parameters:
  • progress_script (Path) –

  • progress_root (Path) –

  • host (str) –

  • port (int) –

  • url (Optional[str]) –

  • log_dir (Optional[Path]) –

  • refresh_ms (int) –

  • no_ros (bool) –

  • quiet (bool) –

  • python_executable (Optional[str]) –

check_health(*, timeout_sec=0.25)[source]

Return (ok, payload, message) from /api/health.

Parameters:

timeout_sec (float) –

Return type:

Tuple[bool, Dict[str, Any], str]

launch()[source]

Launch progress.py if no external or owned server is already healthy.

Return type:

Tuple[bool, str, Dict[str, Any]]

stop_if_owned(*, timeout_sec=2.0)[source]

Stop only the progress monitor started by this console.

Parameters:

timeout_sec (float) –

Return type:

Tuple[bool, str, Dict[str, Any]]

status(*, check_external=False)[source]

Return current monitor state without sending telescope commands.

Parameters:

check_external (bool) –

Return type:

ProgressMonitorState