Skip to main content

toml version

Project description

NetScript

A lightweight Python utility for running and monitoring scripts (.py, .sh, or any shell command) from a live web dashboard. Built on Flask with no external dependencies beyond the standard library and Flask itself.

features

  • start and stop scripts from a browser UI
  • live log streaming via server-sent events — no page reloads
  • per-line log colorization (errors, warnings, info)
  • status polling every 2 seconds with in-place card updates
  • clean process teardown: SIGTERM with a 5s timeout, SIGKILL fallback
  • works with Python scripts, shell scripts, or any arbitrary command

install

pip install netscript

usage

from pathlib import Path
from process_manager import ProcessManager, ScriptSpec

scripts = {
    "pipeline": ScriptSpec(
        Path("jobs/data_pipeline.py"),
        ["python", "jobs/data_pipeline.py"]
    ),
    "server": ScriptSpec(
        Path("jobs/api_server.py"),
        ["python", "jobs/api_server.py", "--port", "8080"]
    ),
    "backup": ScriptSpec(
        Path("jobs/backup.sh"),
        ["bash", "jobs/backup.sh"]
    ),
}

manager = ProcessManager(job_root=Path("jobs"), scripts=scripts)
app = manager.create_flask_app()

if __name__ == "__main__":
    app.run(host="0.0.0.0", port=5000)

Then open http://localhost:5000 in your browser.

dynamic commands

If the command needs to be constructed at runtime (e.g. pulling config from a file or environment), pass a callable instead of a list:

import os

def build_cmd():
    return ["python", "worker.py", "--env", os.environ["APP_ENV"]]

scripts = {
    "worker": ScriptSpec(Path("worker.py"), build_cmd)
}

The callable is invoked each time the script is started.

log files

Each script writes stdout and stderr to a .log file next to the script file. For a script at jobs/data_pipeline.py, the log is written to jobs/data_pipeline.log. Logs persist across restarts and can be tailed directly from the terminal:

tail -f jobs/data_pipeline.log

api endpoints

The Flask app exposes a small REST API alongside the dashboard UI.

method path description
GET / dashboard UI
GET /api/status JSON status of all scripts
POST /api/start/<key> start a script by key
POST /api/stop/<key> stop a script by key
GET /api/log/<key> last 200 lines of log
GET /api/log/<key>/stream SSE stream of new log lines

Example status response:

{
  "pipeline": { "label": "data_pipeline.py", "status": "running", "pid": 12345 },
  "server":   { "label": "api_server.py",    "status": "stopped", "pid": null }
}

notes

  • processes that daemonize themselves (fork and detach) will not be tracked correctly — this tool is intended for foreground processes
  • the dashboard does not persist state across server restarts; any running processes will be orphaned if the Flask server exits
  • for always-on services, consider systemd instead; this tool is best suited for on-demand or development workloads

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

netscript-2.1.tar.gz (11.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

netscript-2.1-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file netscript-2.1.tar.gz.

File metadata

  • Download URL: netscript-2.1.tar.gz
  • Upload date:
  • Size: 11.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for netscript-2.1.tar.gz
Algorithm Hash digest
SHA256 1d3115fc975761fae55340280d8a64bf6181d0ae624f07117ea3f5d12532cfa4
MD5 1801612493de8b1c0f1abe53cbc79bb5
BLAKE2b-256 1b266bdbc8961b05b74d4e3fe200479a73878a6ef3c912c4d651a23c16720205

See more details on using hashes here.

File details

Details for the file netscript-2.1-py3-none-any.whl.

File metadata

  • Download URL: netscript-2.1-py3-none-any.whl
  • Upload date:
  • Size: 11.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for netscript-2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 38b1ddf7fc7ccccb043480f0ccb313d20217fee16f484e1d2ff913e97fbedcd8
MD5 5147cef91a10ff1dc4ce5b561ed67f35
BLAKE2b-256 368b3d37650a90ae74ae196340c4878a486648070421dfcdf02c56303a5308c2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page