run shell command
Project description
Installation
$ [sudo] pip install runcmd
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
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-2020.12.3.tar.gz
(2.5 kB
view details)
File details
Details for the file runcmd-2020.12.3.tar.gz
.
File metadata
- Download URL: runcmd-2020.12.3.tar.gz
- Upload date:
- Size: 2.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.6.0 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.50.2 CPython/3.8.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1f2652c2e51404bb0faaa83610f23fdafd4c246b46e361a5dd6d4334d013fc24 |
|
MD5 | ba1a2043d3955911afa5c68ee5be27b6 |
|
BLAKE2b-256 | 41b708c18bc2944c0443aa77672e5610e861c6946f93f247bef0aa8d7737b248 |