Subprocesses for Humans 2.0.
Project description
Delegator.py — Subprocesses for Humans 2.0
=======================================
**Delegator.py** is a simple library for dealing with subprocesses, inspired
by both `envoy <https://github.com/kennethreitz/envoy>`_ and `pexpect <http://pexpect.readthedocs.io>`_ (in fact, it depends on it!).
This module features two main functions ``delegator.run()`` and ``delegator.chain()``. One runs commands, blocking or non-blocking, and the other runs a chain of commands, seperated by the standard unix pipe operator: ``|``.
Basic Usage
-----------
Basic run functionality:
.. code:: pycon
>>> c = delegator.run('ls')
>>> print c.out
README.rst delegator.py
>>> c = delegator.run('long-running-process', block=False)
>>> c.pid
35199
>>> c.block()
>>> c.return_code
0
Commands can be passed in as lists as well (e.g. ``['ls', '-lrt']``), for parameterization.
Basic chain functionality:
.. code:: pycon
# Can also be called with ([['fortune'], ['cowsay']]).
# or, delegator.run('fortune').pipe('cowsay')
>>> c = delegator.chain('fortune | cowsay')
>>> print c.out
_______________________________________
/ Our swords shall play the orators for \
| us. |
| |
\ -- Christopher Marlowe /
---------------------------------------
\ ^__^
\ (oo)\_______
(__)\ )\/\
||----w |
|| ||
Expect functionality is built-in too, on non-blocking commands:
.. code:: pycon
>>> c.expect('Password:')
>>> c.send('PASSWORD')
>>> c.block()
Other functions:
.. code:: pycon
>>> c.kill()
>>> c.send('SIGTERM', signal=True)
# Only available when block=True, otherwise, use c.out.
>>> c.err
''
# Direct access to pipes.
>>> c.std_err
<open file '<fdopen>', mode 'rU' at 0x10a5351e0>
Installation
------------
::
$ pip install delegator.py
✨🍰✨
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
delegator.py-0.0.4.tar.gz
(3.6 kB
view details)
Built Distribution
File details
Details for the file delegator.py-0.0.4.tar.gz
.
File metadata
- Download URL: delegator.py-0.0.4.tar.gz
- Upload date:
- Size: 3.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | de386a2d3bf439616fa64d4620f6a2dea8869e77dfe2f10a799fdcc4a4e198ce |
|
MD5 | b7c32a079b1f8d96346f4f7e7d34ccd7 |
|
BLAKE2b-256 | 77d652774fde57a6142d80f309bab84a288f88d2f22e41bb0341049463d5cb7a |
File details
Details for the file delegator.py-0.0.4-py2-none-any.whl
.
File metadata
- Download URL: delegator.py-0.0.4-py2-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 82030ab2c6e1bb41502e692b4c54f617c0dc71c890219ac1639213a0f694b469 |
|
MD5 | d067f1d4d6d477ab5c73095a022168ff |
|
BLAKE2b-256 | 7a0a320c0992a9c81ff2d50e77b0d4a80425c88f6cc7e4dc88be481ade54d127 |