VirtualTerm
A simple Python library for creating and interacting with virtual terminals
VirtualTerm is a Python library designed for creating and managing virtual terminal sessions programmatically. It allows users to run interactive shell commands, handle command timeouts, and monitor output streams within isolated terminal environments. This library is particularly useful for developers building automation tools, testing environments, or managing interactive shell-based workflows.
import asyncio
from virtual_term import VirtualTerm
async def main():
with await VirtualTerm.spawn() as term:
term.write(b"sudo apt-get upgrade\n")
await asyncio.sleep(1)
print((await term.read_new_output()).decode())
term.write(b"y\n") # Respond with 'y' to confirm upgrade
result = await term.wait_for_last_command()
print(result.output.decode())
assert result.return_code == 0
asyncio.run(main())
Installation
Install with pip:
pip install virtual-term
Development
VirtualTerm uses Rye for dependency management and development workflows. To get started with development, ensure you have Rye installed, then clone the repository and set up the environment:
git clone https://github.com/MatthewScholefield/virtual-term.git
cd virtual-term
rye sync
rye run pre-commit install
# Run tests
rye test
Metadata
Release files for virtual-term 2.0.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| virtual_term-2.0.2.tar.gz | 7.2 kB | Without provenance | Details for virtual_term-2.0.2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| virtual_term-2.0.2-py3-none-any.whl | Python 3 | none | any | Details for virtual_term-2.0.2-py3-none-any.whl |
Total release size: 14.3 kB
Release files / virtual_term-2.0.2.tar.gz
| Download URL | virtual_term-2.0.2.tar.gz |
|---|---|
| Size | 7.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f41ef6df0d3d5fba6cfcae40db20c0b634d187556fb8a95f1a35df1b235da66d
|
|
BLAKE2b-256 checksum How to use checksums |
9a7058a09b0fac9361405e29eb3bfd0e2e70d817b0c8524f9bbfd3506d1b8ce1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|
Release files / virtual_term-2.0.2-py3-none-any.whl
| Download URL | virtual_term-2.0.2-py3-none-any.whl |
|---|---|
| Size | 7.0 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e35bf87b6c11372107815ee1027caac875fba876272214bfd079728e63e04a42
|
|
BLAKE2b-256 checksum How to use checksums |
0de6cf3b90ac1e600f81e99c0f7085d122810c1a133dd6eb4217ab18b9b9d4ac
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.1 CPython/3.13.1
|
Security for virtual-term 2.0.2
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.