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.7.tar.gz
(7.6 kB
view details)
Built Distribution
File details
Details for the file subprocrunner-0.8.7.tar.gz
.
File metadata
- Download URL: subprocrunner-0.8.7.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 595785a679a178dcf71e489833bcbeee5ee0ad6807f64de599440c7a398bce2a |
|
MD5 | ab5cd88223827ae1ec8dddad14dd9e09 |
|
BLAKE2b-256 | 7a3164e7b189b2a4e8bf872157540636efb7cdd9b84e8e5dd0fc6b8e259790dd |
File details
Details for the file subprocrunner-0.8.7-py2.py3-none-any.whl
.
File metadata
- Download URL: subprocrunner-0.8.7-py2.py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a044e0902feef6264d932d6d0d1f8842d51c9b3fe0d27e425e12faa5853cc0db |
|
MD5 | 3b2cf7324a940fd9868075327c4c56b1 |
|
BLAKE2b-256 | 2e4acddd4a545a84f67942f598da87f08a9492b80a9c067e81eb5ec57db7945b |