subprocess-tee
Project description
subprocess-tee
This package provides an drop-in alternative to subprocess.run
that
captures the output while still printing it in real time, just the way tee
does.
Printing output in real-time while still capturing is important for any tool that executes long running child processes, as you may not want to deprive user from getting instant feedback related to what is happening.
# from subprocess import run
from subprocess_tee import run
result = run("echo 123")
result.stdout == "123\n"
Rich extension
This libary also provides an drop-in replacement for rich Console class, one
that is able to rewire both sys.stdout
and sys.stderr
and avoid the
need too replace bare print()
calls with console.print()
ones.
# from rich.console import Console
from subprocess_tee.rich import ConsoleEx
console = ConsoleEx(redirect=True, record=True)
print("123")
assert "123\n" == console.export_text()
When used in conjuction with our own run()
, this also makes it possible
to use rich to process output produced by subprocesses.
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
File details
Details for the file subprocess-tee-0.1.1.tar.gz
.
File metadata
- Download URL: subprocess-tee-0.1.1.tar.gz
- Upload date:
- Size: 11.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 9ae7b6604c6e786fb58a2e17c16cc91ca721ee5e784b7f207bf8b36fff9af017 |
|
MD5 | 834836f58dfbf2e50a8fc976d67bf0c9 |
|
BLAKE2b-256 | e2d14b1041e1d1a5cadeb7fb43fc0babd2333c8f6cf420923ecccfb335f9ce05 |
File details
Details for the file subprocess_tee-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: subprocess_tee-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 49e797ea70edfab6b69e332be71c53af06598d56325591d37230634564f73178 |
|
MD5 | d66d7a211986e41ca27821d0e45c0444 |
|
BLAKE2b-256 | e51c7f2a00b190e3ea70c77f061f9a7c2befe7f2b136351851ab240d5510a96d |