Subprocesses for Humans 2.0.
Project description
Delegator.py — Subprocesses for Humans 2.0
=======================================
.. image:: https://img.shields.io/pypi/v/delegator.py.svg
:target: https://pypi-hypernode.com/pypi/delegator.py
.. image:: https://img.shields.io/pypi/l/delegator.py.svg
:target: https://pypi-hypernode.com/pypi/delegator.py
.. image:: https://img.shields.io/pypi/wheel/delegator.py.svg
:target: https://pypi-hypernode.com/pypi/delegator.py
.. image:: https://img.shields.io/pypi/pyversions/delegator.py.svg
:target: https://pypi-hypernode.com/pypi/delegator.py
.. image:: https://img.shields.io/badge/SayThanks.io-☼-1EAEDB.svg
:target: https://saythanks.io/to/kennethreitz
**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, separated 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.1.0.tar.gz
(4.5 kB
view details)
Built Distribution
File details
Details for the file delegator.py-0.1.0.tar.gz
.
File metadata
- Download URL: delegator.py-0.1.0.tar.gz
- Upload date:
- Size: 4.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2d46966a7f484d271b09e2646eae1e9acadc4fdf2cb760c142f073e81c927d8d |
|
MD5 | c2469ba9acdb55113283c32b5e9a3e11 |
|
BLAKE2b-256 | c43e655436f6f41b92bb318af6d7d8cff32349b42f300822fa52b88dffe6d60c |
File details
Details for the file delegator.py-0.1.0-py3-none-any.whl
.
File metadata
- Download URL: delegator.py-0.1.0-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 58f3ea6fe36680e1d828e2e66e52844b826f186409dfee4436e42351b0e699fe |
|
MD5 | fd4d41bd9d29b8e2d01608120cce7659 |
|
BLAKE2b-256 | f8655e934900286a82fe9d7b6dd2f2888d2fab0f18eb96c75515c41a4286204e |