A better way to run shell commands in Python.
“”“A better way to run shell commands in Python.”“”
Built because every time I go to use subprocess, I spend more time in the docs & futzing around than actually implementing what I’m trying to get done.
Full docs are at https://shell.readthedocs.org/en/latest/.
- Python 2.6+ or Python 3.3+
If you just need to quickly run a command, you can use the shell shortcut function:
>>> from shell import shell >>> ls = shell('ls') >>> for file in ls.output(): ... print file 'another.txt'
If you need to extend the behavior, you can also use the Shell object:
>>> from shell import Shell >>> sh = Shell(has_input=True) >>> cat = sh.run('cat -u') >>> cat.write('Hello, world!') >>> cat.output() ['Hello, world!']
You can even chain calls if you’d like:
>>> from shell import shell >>> shell('cat -u', has_input=True).write('Hello, world!').output() ['Hello, world!']
Using pip, simply run:
pip install shell
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
|File Name & Checksum SHA256 Checksum Help||Version||File Type||Upload Date|
|shell-1.0.1-py2.py3-none-any.whl (5.4 kB) Copy SHA256 Checksum SHA256||2.7||Wheel||Dec 3, 2013|
|shell-1.0.1.tar.gz (4.5 kB) Copy SHA256 Checksum SHA256||–||Source||Jun 3, 2013|