Run a command within python
Project description
run-cmd
Run a command within python
Install it
pip install python-run-cmd
# pip install git+https://github.com/ffreemt/run-cmd
# poetry add git+https://github.com/ffreemt/run-cmd
# git clone https://github.com/ffreemt/run-cmd && cd run-cmd
Use it
from python_run_cmd import run_cmd
ret = run_cmd("ls -l")
if ret.returncode:
print("Failed")
else:
print("OK")
Raise an exception when errors occur. This may come handy sometimes.
from python_run_cmd import run_cmd
ret = run_cmd("lsss -l")
# 'lsss' is not recognized as an internal
# or external command, operable program or batch file.
Set raise_stderr=False
to ignore errors
from python_run_cmd import run_cmd
ret = run_cmd("lsss -l", raise_stderr=False)
if ret.returncode:
print("Failed")
else:
print("OK")
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
python_run_cmd-0.1.0.tar.gz
(3.2 kB
view hashes)
Built Distribution
Close
Hashes for python_run_cmd-0.1.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 0b42c35ae0a1e0fab56bea53cb6eea77c1b735832b92264b65dad44dd50a1045 |
|
MD5 | 617ea804fda9c12c77e4937d6555d1e6 |
|
BLAKE2b-256 | a4ea033b46dfcb71f3cbbed012961ac84a8a7d0f5a5903742b7e9d87543faf24 |