Skip to main content

Subprocess utils

Project description

Pipes

Subprocess utils

Status

Source Shields
Project license release
Publishers pypi
Downloads pypi_downloads
Raised issues pulls

Installing

To install the package from pypi:

pip install simple_pipes

Alternatively, you can clone the repo and build the package locally.

Usage

Pass a command in exec form:

from simple_pipes import pipe_call, pipe_capture

pipe_call(["echo", "Hello"])

This is equivalent to:

import subprocess

subprocess.Popen(["echo", "Hello"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

Changing directory before execxution:

pipe_call(["echo", "Hello"], cwd=".")

If you're running a command does not terminate, such as starting a server, the program will remain attached.

To detach the running process on a given string output:

wrapper = pipe_call(["echo", "Hello"], break_str="Hello"):

You must keep the wrapper object in scope or the detached process will be terminated in garbage collection.

Often you want to run a process until it terminates and capture the entire output:

output = pipe_capture(["echo", "Hello"], cwd=".")

print(output)

>> Hello

Docs

Additional details are available in the full documentation.

To generate the documentation locally:

multi-job docs

Tests

Unit tests and behaviour tests are written with the pytest framework.

To run tests:

multi-job tests

Additionally, an html report will be saved to the local directory.

Contributing

Please read CONTRIBUTING.md for details on our code of conduct, and the process for submitting pull requests.

Versioning

SemVer is used for versioning. For a list of versions available, see the tags on this repository.

Bump2version is used to version and tag changes. For example:

bump2version patch

Releases are made on every major change.

Author

See also the list of contributors who participated in this project.

License

This project is licensed under the MIT License - see the LICENSE.md file for details

Acknowledgments

None yet!

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

simple_pipes-0.3.1.tar.gz (4.2 kB view hashes)

Uploaded Source

Built Distribution

simple_pipes-0.3.1-py2-none-any.whl (4.2 kB view hashes)

Uploaded Python 2

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page