Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/datalib/proclib
pythonic processes
https://github.com/datalib/proclib
Last synced: 2 months ago
JSON representation
pythonic processes
- Host: GitHub
- URL: https://github.com/datalib/proclib
- Owner: datalib
- License: mit
- Created: 2015-04-14T08:34:32.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-06-12T01:40:02.000Z (over 9 years ago)
- Last Synced: 2024-09-20T11:35:54.732Z (4 months ago)
- Language: Python
- Size: 672 KB
- Stars: 12
- Watchers: 6
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
- starred-awesome - proclib - pythonic processes (Python)
README
.. image:: https://raw.githubusercontent.com/datalib/proclib/master/media/logo-small.png
Proclib is a high level wrapper/abstraction around the standard
library subprocess module, written in Python, with proper piping
support which aims to simplify the usage of Unix utilities right
from Python and help the developer focus on the commands and not
the code which calls the commands... image:: https://travis-ci.org/datalib/proclib.svg?branch=master
:target: https://travis-ci.org/datalib/proclibOverview
--------`proclib.api.spawn(cmd)`
Given a string or list making up commands *cmd*, return
a Response object which is the result of piping the commands,
i.e. they are run in *parallel*. The ``data`` parameter can be
used to configure the data passed in to the initial process.
Usage example::>>> from proclib.api import spawn
>>> r = spawn('yes | head')
>>> r.stdout.read()
'y\ny\ny\ny\ny\ny\ny\ny\ny\ny\n'
>>> r.close()
>>> r.history[0].explain_signal()
{'action': 'kill',
'description': 'write on a pipe with no readers',
'id': 13,
'signal': 'SIGPIPE'}Streaming support is built-in- that is that the stdout of
any process can be streamed lazily instead of read and stored
in memory all in one go. Also, any kind of iterable can be
piped to the process::def gen():
yield 'hi\n'
yield 'ho\n'r = spawn('cat', data=gen())
assert r.out.split() == ['hi', 'ho']