Running commands through a system shell
Look at envoy first. envoy.run(command) waits for completion before returning output, which is not what you need when wrapping long running tools, where output needed as soon as it appears, shellrun.run(command) does not intercept output - there is a separate command for that.
>>> import shellrun
>>> r = shellrun.run('uptime')
04:06:37 up 2 min, 1 user, load average: 0.20, 0.19, 0.08
>>> r.output
>>> r.success
True
>>> r.retcode
0
To capture output envoy-style, use run_capture. stdout and stderr are merged, because that’s how users see it:
>>> r = shellrun.run_capture('uptime')
>>> r.output
' 04:07:16 up 2 min, 1 user, load average: 0.11, 0.17, 0.08\n'
>>> r.success
True
>>> r.retcode
0
Quick comparison of result objects:
envoy.Response |
shellrun.Result |
|---|---|
.command |
.command |
.status_code |
.retcode |
.success |
|
.output |
|
.std_out |
|
.std_err |
Example of .success usage:
from shellrun import run_capture
r = run_capture('ls -la')
if r.success:
print(r.output)
else:
print("Error: '%s' exit code %s" % (r.command, r.retcode))
print(" ...")
# print last three lines of output
for line in r.output.splitlines()[-3:]:
print(" %s" % line)
Metadata
Release files for shellrun 3.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 |
|---|---|---|---|---|
| shellrun-3.1.zip | 3.9 kB | Without provenance | Details for shellrun-3.1.zip |
Release files / shellrun-3.1.zip
| Download URL | shellrun-3.1.zip |
|---|---|
| Size | 3.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
b05503518f2d3d07d605a4be094b48ad9fbbaa5ff8263255b946f9624e2d5c47
|
|
BLAKE2b-256 checksum How to use checksums |
9179716905a6f94044a4ef5a4c1a894d83edeed1250edd693997e1296b0e38b9
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for shellrun 3.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.