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
dry run
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'
>>> which
command=ls, is_exist=True, 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.10.0.tar.gz
(8.1 kB
view details)
Built Distribution
File details
Details for the file subprocrunner-0.10.0.tar.gz
.
File metadata
- Download URL: subprocrunner-0.10.0.tar.gz
- Upload date:
- Size: 8.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3942fda928c3cef00eda6c37e47b59800ce3da2173ae3723ee89b44189e6133d |
|
MD5 | 8e2f15c69f846919d862462b3665393e |
|
BLAKE2b-256 | 406ee344515331a57797d6c004d663c92f3535e8b6bdd846878e2b0f5050637d |
File details
Details for the file subprocrunner-0.10.0-py2.py3-none-any.whl
.
File metadata
- Download URL: subprocrunner-0.10.0-py2.py3-none-any.whl
- Upload date:
- Size: 8.2 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | dfe746f2eed468a7a31ce7ee6c206e3f311d038ed4c74aaa10b12cd2eea635fd |
|
MD5 | f170affb9208d0c68fba68b089b62b64 |
|
BLAKE2b-256 | 32139366567594a31860f6ee2d64c18554c3649403d66fcadee6cab4c96e1d2f |