Cross-platform terminal controllable via Python (and web)
Project description
decterm
Cross-platform terminal you can drive from Python. Run shell commands and get output, with or without a web UI.
- Headless (default): no window, ideal for scripts and servers.
- Web GUI (
gui=True): DecPython-style browser terminal; optional HTTP server for remotesend(). - Server (
port=...): bind host/port and optionalsecretso external clients can POST commands via the standalonesend()function.
Examples
All examples are in the examples/ folder. Run from project root: python examples/headless.py etc.
| File | Covers |
|---|---|
examples/headless.py |
DecTerm(), send(), sends(), close(), context manager |
examples/gui.py |
DecTerm(gui=True), web terminal in browser |
examples/server.py |
DecTerm(host, port, secret), dt.port |
examples/send_remote.py |
send(command, host, port, secret) — run server.py first |
Quick start
pip install decterm
from decterm import DecTerm, send
# Headless
dt = DecTerm()
print(dt.send("dir")) # or "ls" on Unix
print(dt.sends("cd /tmp", "pwd"))
dt.close()
# Web GUI (opens browser)
dt = DecTerm(gui=True)
dt.send("echo Hello")
# Run commands in the browser; then:
dt.close()
# Server: accept remote commands (e.g. port=8765, secret="mykey")
dt = DecTerm(host="0.0.0.0", port=8765, secret="mykey")
# From another machine or script:
r = send("echo hi", host="server-ip", port=8765, secret="mykey")
# r == {'code': 200, 'data': 'hi\n', 'msg': ''}
dt.close()
API (concise)
DecTerm
| Parameter / Method | Description |
|---|---|
DecTerm(gui=False, shell=None, cwd=None, env=None, host='localhost', port=None, secret=None) |
Start a shell. gui=True opens web terminal in browser. host/port/secret start HTTP server; only host='0.0.0.0' accepts non-local requests. |
dt.send(cmd, timeout=30) |
Run one command, return output string. |
dt.sends(*cmds, timeout=30) |
Run several commands in order; returns last command's output. |
dt.port |
Bound port (None if no server). |
dt.close() |
Stop the shell and server. |
Use timeout=None in send() to wait indefinitely.
Standalone send (client)
| Function | Description |
|---|---|
send(command, host='localhost', port=None, secret=None) |
POST command to a DecTerm server. port is required. Returns {'code': 200, 'data': '<output>', 'msg': ''} on success, or {'code': -1, 'data': '', 'msg': '<error>'} on failure. When secret is set, sends timestamp + HMAC for auth. |
Requirements
- Python 3.7+
- Windows, macOS, or Linux
- No extra packages (standard library only; no tkinter required for web GUI).
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file decterm-1.0.1.tar.gz.
File metadata
- Download URL: decterm-1.0.1.tar.gz
- Upload date:
- Size: 15.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
943c75ba4f2bcf2fdea0413ce15704b69adecdfd8cffbb31071af70fd74f538f
|
|
| MD5 |
cb68b2bff5c375e85d026211d62ba5d3
|
|
| BLAKE2b-256 |
4bac750e60cac8e709e8822a4ff4ed47aa03dd306007a723568bffe603836aec
|
File details
Details for the file decterm-1.0.1-py3-none-any.whl.
File metadata
- Download URL: decterm-1.0.1-py3-none-any.whl
- Upload date:
- Size: 13.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fd09f512a2670dbd29c4252b954bd53d58db494350a591e9b497ce94de88f66c
|
|
| MD5 |
30ea62a6b1c5694abcceaba868c162ad
|
|
| BLAKE2b-256 |
4abadd7f4be4e839d7bcbf232071df3d13801bfc07e70e3a778568cf226925d6
|