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.6.tar.gz
(7.6 kB
view details)
Built Distribution
File details
Details for the file subprocrunner-0.8.6.tar.gz
.
File metadata
- Download URL: subprocrunner-0.8.6.tar.gz
- Upload date:
- Size: 7.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 29831549afd5dfd8d61fa5086239ca3180f128c0da63afd5741ec9c1fe336e13 |
|
MD5 | 6e2c354320b72d6a33ac888268742ed4 |
|
BLAKE2b-256 | 4cfd3b7512e6914d70e434ec43fdebaa82dc14446ec2ecd5d7f9ee34a4f0e669 |
File details
Details for the file subprocrunner-0.8.6-py2.py3-none-any.whl
.
File metadata
- Download URL: subprocrunner-0.8.6-py2.py3-none-any.whl
- Upload date:
- Size: 7.8 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d333b6e8195111ac72f77d1ded00b1f16a5a735e80168644541e235a2e1c4a94 |
|
MD5 | a3dd939e5312c7591472ae0fda0fd65b |
|
BLAKE2b-256 | d836e3eed88331d300f36bda8eba04ea3ca57de8fdf1b75a10c58f9dfe6df10d |