This is a very thin layer on top of stdlib’s subprocess module. It is simply for some convenient functions that are needed in many of my projects.
Full documentation could come later but if you really want something that makes using subprocess much easier I would personally try envoy. However, at this time envoy seemed a bit too early in it’s development to use so I created my own very thin layer to satisfy my needs for the time being.
If you’d like something with higher aspirations please check out envoy.
Examples
Simple example:
import subwrap response = subwrap.run(['echo', 'hello']) # Display hello print response.std_out
By default subwrap throws a CommandError if the command being run exits with an exit code that is not zero. To catch default command errors:
import subwrap
try:
response = subwrap.run(['false'])
except subwrap.CommandError, e:
#this is the response, you can do what you want here
response = e.response
However that’s not always useful. You can have subwrap run your own custom exit handle for each subprocess. Just do the following:
import subwrap
def my_exit_handle(response):
if response.return_code == 0:
print "HAPPY DAY!"
else:
print "Not as happy"
# The next line will output "Not as happy" to stdout
response = subwrap.run(['false'], exit_handle=my_exit_handle)
License
MIT License
Metadata
Release files for subwrap 0.1.0
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 | |
|---|---|---|---|---|
| subwrap-0.1.0.tar.gz | 3.3 kB | Without provenance | Details |
Release files / subwrap-0.1.0.tar.gz
| Download URL | subwrap-0.1.0.tar.gz |
|---|---|
| Size | 3.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
85dd73960bbf6c72c509daedd206c9bd33f1e21be7cc6b7a730a4b8c9dac20d8
|
|
BLAKE2b-256 checksum How to use checksums |
1d69cde7fb70a468612dcb5c09cac4a9d9ba2add238ed71faa8207a2e3f5bf81
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Security for subwrap 0.1.0
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.