https://github.com/joellefkowitz/simple-pipes
Subprocess utils.
https://github.com/joellefkowitz/simple-pipes
pipe stdout subprocess
Last synced: 9 months ago
JSON representation
Subprocess utils.
- Host: GitHub
- URL: https://github.com/joellefkowitz/simple-pipes
- Owner: JoelLefkowitz
- License: mit
- Created: 2020-11-10T15:09:58.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2024-05-27T22:09:50.000Z (over 1 year ago)
- Last Synced: 2024-10-10T13:48:45.537Z (about 1 year ago)
- Topics: pipe, stdout, subprocess
- Language: Python
- Homepage:
- Size: 71.3 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
# Simple pipes
Subprocess utils.





## Installing
```bash
pip install simple-pipes
```
## Documentation
Documentation and more detailed examples are hosted on [Github Pages](https://joellefkowitz.github.io/simple-pipes).
### Usage
Pass a command in exec form:
```python
from simple_pipes import pipe_call, pipe_capture
pipe_call(["echo", "Hello"])
```
This is equivalent to:
```python
import subprocess
subprocess.Popen(["echo", "Hello"], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
```
Changing directory before execution:
```python
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:
```python
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:
```python
output = pipe_capture(["echo", "Hello"], cwd=".")
print(output)
>> Hello
```
## Tooling
### Dependencies
To install dependencies:
```bash
yarn install
pip install .[all]
```
### Tests
To run tests:
```bash
thx test
```
### Documentation
To generate the documentation locally:
```bash
thx docs
```
### Linters
To run linters:
```bash
thx lint
```
### Formatters
To run formatters:
```bash
thx format
```
## Contributing
Please read this repository's [Code of Conduct](CODE_OF_CONDUCT.md) which outlines our collaboration standards and the [Changelog](CHANGELOG.md) for details on breaking changes that have been made.
This repository adheres to semantic versioning standards. For more information on semantic versioning visit [SemVer](https://semver.org).
Bump2version is used to version and tag changes. For example:
```bash
bump2version patch
```
### Contributors
- [Joel Lefkowitz](https://github.com/joellefkowitz) - Initial work
## Remarks
Lots of love to the open source community!