The subprocess module extension to run processes.
Project description
The subprocess extension to run processes.
>>> from subprocess import run
>>> print run('uname -r')
3.7.0-7-generic
>>> print run('uname -r').stdout
3.7.0-7-generic
>>> run('uname -a').status
0
>>> print run('rm not_existing_directory').stderr
rm: cannot remove `not_existing_directory': No such file or directory
>>> print run('ls -la', 'wc -l')
14
>>> print run('ls -la', 'wc -l', 'wc -c')
3
>>> run('ls -la', 'wc -l', 'wc -c')
ls -la | wc -l | wc -c
>>> print run('ls -la').stdout.lines
['total 20',
'drwxrwxr-x 3 user user 4096 Dec 20 22:55 .',
'drwxrwxr-x 5 user user 4096 Dec 20 22:57 ..',
'drwxrwxr-x 2 user user 4096 Dec 20 22:37 dir',
'-rw-rw-r-- 1 user user 0 Dec 20 22:52 file']
To use pipe from the shell.
from subprocess import run
run('grep something', data=run.stdin)
$ ps aux | python script.py
Install
You can install it from PyPi, by simply pip:
$ pip install subprocess.run
only if you don’t have pip installed, an alternative method is easy_install:
$ easy_install subprocess.run
to test it, launch python
>>> from subprocess import run
Supported platforms
Python2.6
Python2.7
Python3.3
PyPy1.9
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
subprocess.run-0.0.1.tar.gz
(4.1 kB
view details)
File details
Details for the file subprocess.run-0.0.1.tar.gz
.
File metadata
- Download URL: subprocess.run-0.0.1.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | cb3398a4b503427548cc85a9c17ae1908fd02f1bd3773ce8e3220866dd74b80a |
|
MD5 | 13f2806a2377d721a7c5a1adc40147b7 |
|
BLAKE2b-256 | daf80fee04a426faf981997589b61c6da14fe180546a4a2c2b1bc92436576d92 |