Skip to main content

run shell command

Project description

Install

$ [sudo] pip install runcmd

Classes

runcmd.Process - Process class

method __doc__
__bool__() return True if status code is 0
exc() raise OSError if status code is not 0. returns self
kill(signal=None) kill process. return error string if error occured
@property __doc__
args return arguments list
code return status code
err return stderr string
ok return True if status code is 0, else False
out return stdout string
pid return rocess pid
running return True if process is running, else False

Functions

function __doc__
runcmd.run(args, cwd=None, background=False) run command and return Process object

Examples

>>> import runcmd
>>> r = runcmd.run(["echo", "hello world"])
>>> r.code  # exit status code
0
>>> r.out  # stdout
'hello world'
>>> r.err  # stderr
''
>>> r.pid  # process pid
1234

background=True

>>> r = runcmd.run(["sleep","5"],background=True)
>>> while r.running:  # True if process is running and not "zombie process"
>>>     print("running")

kill(signal=None) - kill process

>>> r.kill(-9)

exc() - raise exception if code is not 0

>>> runcmd.run(["ls"]).exc()              # code 0, ok
>>> runcmd.run(["mkdir", "/"]).exc()      # code 1, raise OSError
...
OSError: exited with code 1
mkdir: /: Is a directory

readme-md - README.md generator

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

runcmd-2018.12.14.tar.gz (2.6 kB view hashes)

Uploaded source

Built Distribution

runcmd-2018.12.14-py2.py3-none-any.whl (3.3 kB view hashes)

Uploaded py2 py3

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page