Replacement for pexpect
Project description
Import the main class:
from processcontroller import ProcessController
Create a new instance:
process_controller = ProcessController()
Run a subprogram:
process_controller.run(command, options)
The command parameter must be an array like:
['/usr/bin/python', 'file.py']
options is a bit more complexe:
Currently, it supports two keys, ‘when’ and ‘echo’.
when:
This key is used to listen to events occuring on the STDOUT of the subprogram The value have to be an array of events The “event” is in fact a match for some pattern:
'when': [ ['^SomeRegex.*$', callback], ['^An other one.$', cb] ]The callbacks will be called with two arguments: the ProcessController instance, and the matched string:
def callback(processcontroller, string)You can automates user inputs in your callback when required by the subprogram using the send function of your ProcessController instance:
def cb(p, s): c.send('some input')
echo:
This key is a boolean that defaults to False. When set to True, the ProcessController will print the input sent to your subprogram where it has been asked
Don’t forget that you have to create a new instance a ProcessController everytime you want to execute a new subprogram
Please feel free to read the tests and code for a better understanding
ENJOY
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
Built Distribution
File details
Details for the file processcontroller-0.0.1.tar.gz
.
File metadata
- Download URL: processcontroller-0.0.1.tar.gz
- Upload date:
- Size: 2.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 74290b77edec0197fc0a58bfb903305719c143c1a9b39c623478988c8fc0b896 |
|
MD5 | 192a73f63e2b9a0de71dda5eb794a2c8 |
|
BLAKE2b-256 | ec871a8891afe0c3af35abecf82787c1d2a51a17bdbcd7a77759759a5c5b3ccc |
File details
Details for the file processcontroller-0.0.1-py3-none-any.whl
.
File metadata
- Download URL: processcontroller-0.0.1-py3-none-any.whl
- Upload date:
- Size: 3.8 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.1
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | df83f9b5b3889884ee112e426f6ba7b240c669f3cade01cb9e31d9979933d64b |
|
MD5 | 3d107a1b5eb64b609639235c9412bb19 |
|
BLAKE2b-256 | dcd94b4ff734045e4b6ae70e4eb6891999a7d98f33e78449459428c58683a47c |