- Notifications
You must be signed in to change notification settings - Fork90
Subprocesses for Humans 2.0.
License
NotificationsYou must be signed in to change notification settings
amitt001/delegator.py
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
Delegator.py is a simple library for dealing with subprocesses, inspiredby bothenvoy andpexpect (in fact, it depends on it!).
This module features two main functionsdelegator.run()
anddelegator.chain()
. One runs commands, blocking or non-blocking, and the other runs a chain of commands, separated by the standard unix pipe operator:|
.
Basic run functionality:
>>> c= delegator.run('ls')>>>print c.outREADME.rst delegator.py>>> c= delegator.run('long-running-process',block=False)>>> c.pid35199>>> c.block()>>> c.return_code0
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># Adjust environment variables for the command (existing will be overwritten).>>> c= delegator.chain('env | grep NEWENV',env={'NEWENV':'FOO_BAR'})>>> c.outNEWENV=FOO_BAR
$ pip install delegator.py
✨🍰✨
About
Subprocesses for Humans 2.0.
Topics
Resources
License
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Packages0
No packages published
Uh oh!
There was an error while loading.Please reload this page.