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.4.tar.gz
(6.9 kB
view details)
Built Distribution
File details
Details for the file subprocrunner-0.8.4.tar.gz
.
File metadata
- Download URL: subprocrunner-0.8.4.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 54015662f467e1e2091e78a39ee67207ab88c60844a73fc946a418b395b7cf23 |
|
MD5 | ba76f4046570647a6469af7c799bef2d |
|
BLAKE2b-256 | 1f620db6b64e11a0df418fa53d7f5c56df3a12e5109a76d35c93c68783758d39 |
File details
Details for the file subprocrunner-0.8.4-py2.py3-none-any.whl
.
File metadata
- Download URL: subprocrunner-0.8.4-py2.py3-none-any.whl
- Upload date:
- Size: 7.6 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | e7a254bc31396405fdaa8f15e6e805df63157dfe520c709dd23f325a7bde0084 |
|
MD5 | 01eafab67f2b75f6b219e40facc282c6 |
|
BLAKE2b-256 | 68ae9d6de6f07741798dfe51de0d3dfb379705151afb84d527bdddb262c7e096 |