Skip to main content

Subprocesses for Humans 2.0.

Project description

Delegator is a simple library for dealing with subprocesses, inspired by both envoy and pexpect (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:

>>> 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:

# 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:

>>> c.expect('Password:')
>>> c.send('PASSWORD')
>>> c.block()

Other functions:

>>> 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>

Daemonize anything!

# Turns the subprocess into a daemon.
>>> c.daemonize()

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

Uploaded Source

Built Distribution

delegator.py-0.0.1-py2-none-any.whl (5.3 kB view details)

Uploaded Python 2

File details

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

File metadata

File hashes

Hashes for delegator.py-0.0.1.tar.gz
Algorithm Hash digest
SHA256 9944f8c151415757d3469aa5f5f1242cdc9bb6e351e4035d1793567559e9ecca
MD5 226ab0fe73fbd26fc21fd218ec78b8b6
BLAKE2b-256 02edfb40f9b111f086fbfc72fe856a4f38b7d390c8f75af6eab60eb1a97b4c71

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for delegator.py-0.0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 fdb1483ffc9dd778a80860084cb219bd220b94bf09f44abb0a18095c4de5918c
MD5 3632ef428d11daeabb0fbddf80ddbdb3
BLAKE2b-256 be3fa360a650d264369c4e4fcee4ef29127dba33fc65163ae660e5df93b77de0

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