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
- 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
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.12.1.tar.gz
(8.6 kB
view details)
Built Distribution
File details
Details for the file subprocrunner-0.12.1.tar.gz
.
File metadata
- Download URL: subprocrunner-0.12.1.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ea5bd52c917c6371c7d09ec2bc11480f15fd186c97487873bf92afa4af6e8cd3 |
|
MD5 | cfdeeac98360a29c7bcf0130ff9ff1fc |
|
BLAKE2b-256 | 09d920a171de9aeb72eb0ae9bcf408953af60731469f136a9b75cd5c5a46e9e2 |
File details
Details for the file subprocrunner-0.12.1-py2.py3-none-any.whl
.
File metadata
- Download URL: subprocrunner-0.12.1-py2.py3-none-any.whl
- Upload date:
- Size: 8.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | fa9341032ea5fe4a17144fd92eb1fdcbf85b8e1a7b66bfc7d0e74f0f7446779b |
|
MD5 | f021bbcc628b384b807a54f56315f326 |
|
BLAKE2b-256 | b44ffd10ab244624de84aea353d484d62324349fc996db64432ad2ce1a2c24b5 |