Skip to main content

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


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.11.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

delegator.py-0.0.11-py2-none-any.whl (6.0 kB view details)

Uploaded Python 2

File details

Details for the file delegator.py-0.0.11.tar.gz.

File metadata

File hashes

Hashes for delegator.py-0.0.11.tar.gz
Algorithm Hash digest
SHA256 7bfa29ae222d2754c7a897d593e43cb5f85e60e5b438177bb4e12f2442318542
MD5 6daa3e38ec46702dfe94379e542fafcb
BLAKE2b-256 9dc7d98e7a9094b37277dfb02e1512f2108d52f7b4828b2ec1c26e0a09d7df2b

See more details on using hashes here.

File details

Details for the file delegator.py-0.0.11-py2-none-any.whl.

File metadata

File hashes

Hashes for delegator.py-0.0.11-py2-none-any.whl
Algorithm Hash digest
SHA256 131415cc97844bb9557c6a95b20d32165fb3392273e01b923467a5c16b8db28e
MD5 b607ed5d383784c33bd0175862a5fe47
BLAKE2b-256 4dd84f36329b60beb9e3342fd7fb1f746d783963ae2148be34c8202c112db171

See more details on using hashes here.

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