A Python wrapper library for subprocess module.
Project description
subprocrunner
Summary
A Python wrapper library for subprocess module.
Examples
Execute a command
- Sample Code:
from subprocrunner import SubprocessRunner runner = SubprocessRunner("echo test") print("command: {:s}".format(runner.command)) print("return code: {:d}".format(runner.run())) print("stdout: {:s}".format(runner.stdout)) runner = SubprocessRunner("ls __not_exist_dir__") print("command: {:s}".format(runner.command)) print("return code: {:d}".format(runner.run())) print("stderr: {:s}".format(runner.stderr))
- Output:
command: echo test return code: 0 stdout: test command: ls __not_exist_dir__ return code: 2 stderr: ls: cannot access '__not_exist_dir__': No such file or directory
Get execution command history
- Sample Code:
from subprocrunner import SubprocessRunner SubprocessRunner.clear_history() SubprocessRunner.is_save_history = True SubprocessRunner("echo hoge").run() SubprocessRunner("echo foo").run() print("\n".join(SubprocessRunner.get_history()))
- Output:
echo hoge echo foo
Get a command information
>>> from subprocrunner import Which
>>> which = Which("ls")
>>> which.is_exist()
True
>>> which.abspath()
'/usr/bin/ls'
Installation
pip install subprocrunner
Dependencies
Python 2.7+ or 3.3+
Test dependencies
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
subprocrunner-0.8.5.tar.gz
(7.5 kB
view hashes)
Built Distribution
Close
Hashes for subprocrunner-0.8.5-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8798da754ea962abef3e45c10bbb541ca28eb7c5eb882e0038cf5144efb5daf4 |
|
MD5 | 10b1cb8bdb5f63951e01a8fac7fce66e |
|
BLAKE2b-256 | 0b904bc81bfb9edd833b55b76f59fb5457eb067728a20f2c4c1938fa774c65c2 |