← Files NGS Analysis WorkbenchARCHIVED FILE

mcp/ngs_workbench_daemon/remote_controller.py

712 Bytes · Sep 30, 2026 · 23:20 UTC

↓ Download file

"""Run one detached approved controller and publish its terminal receipt."""

from __future__ import annotations

import json
import subprocess
import sys
from pathlib import Path
from typing import Any


def run(request: dict[str, Any]) -> None:
    with Path(request["log"]).open("ab") as output:
        result = subprocess.run(
            request["argv"],
            cwd=request["run_dir"],
            stdout=output,
            stderr=subprocess.STDOUT,
            check=False,
        )
    temporary = Path(request["exit"] + ".tmp")
    temporary.write_text(str(result.returncode), encoding="utf-8")
    temporary.replace(request["exit"])


if __name__ == "__main__":
    run(json.loads(sys.argv[1]))

SHA-256: 302efd8345b5c3ed30e6a1b04eda6b25db793bb8a814d3569d258177f47b7ee4