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.14.0.tar.gz
(9.7 kB
view details)
Built Distribution
File details
Details for the file subprocrunner-0.14.0.tar.gz
.
File metadata
- Download URL: subprocrunner-0.14.0.tar.gz
- Upload date:
- Size: 9.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3db81dc0a0d4ebef4e6f6d30b84fe93a057b9605d3d9edc5afdd8b5f46259733 |
|
MD5 | 68f9045d05fabafb748826b2e5ff071a |
|
BLAKE2b-256 | 6012e5390a4c736aad4e83058497cdfe25eb8d580b33d314c4341bb9a19a2a14 |
File details
Details for the file subprocrunner-0.14.0-py2.py3-none-any.whl
.
File metadata
- Download URL: subprocrunner-0.14.0-py2.py3-none-any.whl
- Upload date:
- Size: 6.9 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2a690dd79ab00aa79755553b60183fdcfd273cd303251cb3839aed582b0c35d6 |
|
MD5 | abd847a190f212cf47ea967b3c9ae706 |
|
BLAKE2b-256 | 92b6f34ef3a2e407bdc0e68ac1afc1a5b1164981689fe267672475f77b051d1a |