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
- Sample Code:
from subprocrunner import SubprocessRunner runner = SubprocessRunner("echo test", dry_run=True) print("command: {:s}".format(runner.command)) print("return code: {:d}".format(runner.run())) print("stdout: {:s}".format(runner.stdout))- Output:
command: echo test return code: 0 stdout:
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.4+
Test dependencies
Release files for subprocrunner 0.12.2
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| subprocrunner-0.12.2.tar.gz | 9.7 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| subprocrunner-0.12.2-py2.py3-none-any.whl | Python 2, Python 3 | none | any | Details |
Total release size: 16.5 kB
Release files / subprocrunner-0.12.2.tar.gz
| Download URL | subprocrunner-0.12.2.tar.gz |
|---|---|
| Size | 9.7 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
717dec789d063cca0569517eea867750adfe00b8300400623b2d75e015da9303
|
|
BLAKE2b-256 checksum How to use checksums |
770838991c200ea80772f48ea0d7e4cd3d50e785353791b7c697d22612f52b11
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
Release files / subprocrunner-0.12.2-py2.py3-none-any.whl
| Download URL | subprocrunner-0.12.2-py2.py3-none-any.whl |
|---|---|
| Size | 6.7 kB |
| Tags | Python 2 Python 3 |
|
SHA-256 checksum How to use checksums |
5aea80c41cfbe8ee046d6e3b8771ac3f5cf7830c59f4c5a200405fadfc43961c
|
|
BLAKE2b-256 checksum How to use checksums |
6b86c6f93af863e9c527b2ff15a72c48793ae893a9ef45161b46d4aa0734e730
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |