Skip to main content

subprocrunner

https://badge.fury.io/py/subprocrunner.svg https://img.shields.io/pypi/pyversions/subprocrunner.svg https://img.shields.io/travis/thombashi/subprocrunner/master.svg?label=Linux https://img.shields.io/appveyor/ci/thombashi/subprocrunner/master.svg?label=Windows https://coveralls.io/repos/github/thombashi/subprocrunner/badge.svg?branch=master

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

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.2.tar.gz (9.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

subprocrunner-0.12.2-py2.py3-none-any.whl (6.7 kB view details)

Uploaded Python 2Python 3

File details

Details for the file subprocrunner-0.12.2.tar.gz.

File metadata

File hashes

Hashes for subprocrunner-0.12.2.tar.gz
Algorithm Hash digest
SHA256 717dec789d063cca0569517eea867750adfe00b8300400623b2d75e015da9303
MD5 1d6b2363190f34a085e6b260db275aa7
BLAKE2b-256 770838991c200ea80772f48ea0d7e4cd3d50e785353791b7c697d22612f52b11

See more details on using hashes here.

File details

Details for the file subprocrunner-0.12.2-py2.py3-none-any.whl.

File metadata

File hashes

Hashes for subprocrunner-0.12.2-py2.py3-none-any.whl
Algorithm Hash digest
SHA256 5aea80c41cfbe8ee046d6e3b8771ac3f5cf7830c59f4c5a200405fadfc43961c
MD5 211a4e81063ffd3f16afdebbb63bfd8d
BLAKE2b-256 6b86c6f93af863e9c527b2ff15a72c48793ae893a9ef45161b46d4aa0734e730

See more details on using hashes here.

Release history Release notifications | RSS feed

2.0.1

2 files

2.0.0

2 files

1.6.0

2 files

1.5.0

2 files

1.4.2

2 files

1.4.1

2 files

1.4.0

2 files

1.3.1

2 files

1.3.0

2 files

1.2.3

2 files

1.2.2

2 files

1.2.1

2 files

1.2.0

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

0.17.2

2 files

0.17.1

2 files

0.17.0

2 files

0.16.2

2 files

0.16.1

2 files

0.16.0

2 files

0.15.6

2 files

0.15.5

2 files

0.15.4

2 files

0.15.3

2 files

0.15.2

2 files

0.15.1

2 files

0.15.0

2 files

0.14.1

2 files

0.14.0

2 files

0.13.0

2 files

This release

0.12.2 This release

2 files

0.12.1

2 files

0.12.0

2 files

0.11.0

2 files

0.10.0

2 files

0.9.0

2 files

0.8.7

2 files

0.8.6

2 files

0.8.5

2 files

0.8.4

2 files

0.8.3

2 files

0.8.2

2 files

0.8.1

2 files

0.8.0

2 files

0.7.0

2 files

0.6.0

2 files

0.5.0

2 files

0.4.11

2 files

0.4.10

2 files

0.4.9

1 file

0.4.8

2 files

0.4.7

2 files

0.4.6

2 files

0.4.5

2 files

0.4.4

2 files

0.4.3

1 file

0.4.2

1 file

0.4.1

2 files

0.4.0

2 files

0.3.0

2 files

0.2.0

2 files

0.1.0

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page