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
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
runcmd-2018.12.10.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for runcmd-2018.12.10-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 577a5b5b73b38685c42a8a15da9f2f2b735d73d946aefe2327c157b7d405dd26 |
|
MD5 | 83c18d66de43405ce836f657d39218db |
|
BLAKE2b-256 | ea8ec9d43be805fb7d0dc62957a14cbc14291f13e2b4742a6a6f8cc30ee1794e |