run shell command
Project description
Install
$ [sudo] pip install runcmd
Classes
runcmd.Process
Process class
method | description |
---|---|
exc() |
raise OSError if status code is not 0. returns self |
__bool__() |
return True if status code is 0 |
@property | description |
---|---|
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 | description |
---|---|
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 - add background=True
>>> r = runcmd.run(["sleep","5"],background=True)
>>> while r.running: # True if process is running and not "zombie process"
>>> print("running")
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.11.20.tar.gz
(2.5 kB
view hashes)
Built Distribution
Close
Hashes for runcmd-2018.11.20-py2.py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3a86a5c6f3f906f48df4aa23b87193e45e3e2200c81cefd4e52dd051972e3077 |
|
MD5 | 37298acfba52554bc8c87e86d4c423a2 |
|
BLAKE2b-256 | b8e47deeec287d3ec90424d30d8b938c0a8c7efdd5f5b5d336134fe21712e168 |