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.11.tar.gz
(2.6 kB
view hashes)
Built Distribution
Close
Hashes for runcmd-2018.12.11-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 2ee98f4dfd4afa2bd1e2267dbc8116b431eb66271eb7d43964288ae5557a6dd7 |
|
MD5 | a93539190fdcab41e1d0d597aaaf94c3 |
|
BLAKE2b-256 | 7e5f06f37786e804b0a7ba479cc208a6fc0b37498cccfa6540598d5fe031e14d |