exlab_wizard.window#

Window application package. Backend Spec §4.3.2.

Public API:

We deliberately avoid re-exporting the main() function at the package root to keep exlab_wizard.window.main resolving to the submodule (the launcher imports the submodule, not the function).

class exlab_wizard.window.ServerHandshake(*, port, pid, started_at)[source]#

Bases: object

Resolved server.json contents: port / pid / started_at.

Parameters:
pid#
port#
started_at#
exlab_wizard.window.build_window_url(handshake)[source]#

Return the URL the window points at.

Always loopback (Backend §4.1: “binds to 127.0.0.1 only”); the handshake’s port is mandatory.

Parameters:

handshake (ServerHandshake)

Return type:

str

exlab_wizard.window.is_debug_enabled()[source]#

True when EXLAB_DEBUG is set to a truthy string. Backend §15.3.2.

Return type:

bool

exlab_wizard.window.is_pid_alive(pid)[source]#

Cross-platform “is this PID a live process?” check.

Implementation: POSIX os.kill(pid, 0) raises ProcessLookupError if the PID is dead and PermissionError if it’s alive but owned by a different uid (counts as alive for our purposes – if the operator started a previous tray that is now owned by another user, we still don’t want to hijack it). Windows uses OpenProcess via ctypes; we deliberately keep the implementation small and inline because it has no other call sites.

Parameters:

pid (int)

Return type:

bool

exlab_wizard.window.read_server_handshake(state_dir)[source]#

Read and validate <state_dir>/server.json.

Returns the handshake on success, None if the file is missing or malformed. Validation is intentionally minimal – if the file exists, the PID is alive, and the port parses, we proceed; deeper health checks happen on the first HTTP call inside pywebview.

Parameters:

state_dir (Path)

Return type:

ServerHandshake | None

exlab_wizard.window.run_window(handshake, *, create_window=None, start=None)[source]#

Open a single pywebview window pointed at the handshake’s port.

create_window and start are dependency-injection hooks for tests; production code defers to webview.create_window and webview.start. Returns 0 on clean exit.

Parameters:
Return type:

int

Modules

main

exlab-wizard-window console_scripts entry point.

pywebview_app

pywebview-driven native window.