duct.py

Duct is a library for running child processes. Duct makes it easy to build pipelines and redirect IO like a shell. At the same time, Duct helps you write correct, portable code: whitespace is never significant, errors from child processes get reported by default, and a variety of gotchas, bugs, and platform inconsistencies are handled for you the Right Way™.
Examples
Run a command without capturing any output. Here "hi" is printed directly to the terminal:
>>> from duct import cmd
>>> cmd("echo", "hi").run()
hi
Output(status=0, stdout=None, stderr=None)
Capture the standard output of a command. Here "hi" is returned as a string:
>>> cmd("echo", "hi").read()
'hi'
Capture the standard output of a pipeline:
>>> cmd("echo", "hi").pipe(cmd("sed", "s/i/o/")).read()
'ho'
Merge standard error into standard output and read both incrementally:
>>> big_cmd = cmd("bash", "-c", "echo out && echo err 1>&2")
>>> reader = big_cmd.stderr_to_stdout().reader()
>>> with reader:
... reader.readlines()
[b'out\n', b'err\n']
Children that exit with a non-zero status raise an exception by default:
>>> cmd("false").run()
Traceback (most recent call last):
...
duct.StatusError: Expression cmd('false') returned non-zero exit status: Output(status=1, stdout=None, stderr=None)
>>> cmd("false").unchecked().run()
Output(status=1, stdout=None, stderr=None)
Metadata
Release files for duct 1.0.1
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 |
|---|---|---|---|---|
| duct-1.0.1.tar.gz | 17.2 kB | Without provenance | Details for duct-1.0.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| duct-1.0.1-py3-none-any.whl | Python 3 | none | any | Details for duct-1.0.1-py3-none-any.whl |
Total release size: 35.1 kB
Release files / duct-1.0.1.tar.gz
| Download URL | duct-1.0.1.tar.gz |
|---|---|
| Size | 17.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a46839355f82585e64f348ac6401f1ec21ab19c186e661d161d4e9ceb3a240d7
|
|
BLAKE2b-256 checksum How to use checksums |
0368505d551c5c7e6ba31b0e176861ea9f87fed45c6357e42e0f3cb436f30ec1
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Release files / duct-1.0.1-py3-none-any.whl
| Download URL | duct-1.0.1-py3-none-any.whl |
|---|---|
| Size | 17.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ce8a93bd4b081b0244cd71c337edc4d6df78dc6d20b42da283e984780a5e9b1e
|
|
BLAKE2b-256 checksum How to use checksums |
f9b95e71b1f3149916e73523b43e150e33ddd6ed4da38b96ee0a746f08471881
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.14.0
|
Security for duct 1.0.1
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.