Python Shell Wrapper library
Project description
Python Shell Wrapper Library
A flexible, easy-to-use library to integrate your Python script with Unix ecosystems.
Why yet another one?
This library comes with a few major points to use it:
- It is easy and intuitive (see examples)
- It's compatible with Python 2 (can be useful in old large systems)
- Continuous support of the library
Getting started
This library is pretty easy to use:
from python_shell import Shell
Shell.ls('-l', '$HOME') # Equals "ls -l $HOME"
command = Shell.whoami() # Equals "whoami"
print(command.output) # prints your current user name
print(command.command) # prints "whoami"
print(command.return_code) # prints "0"
print(command.arguments) # prints ""
To run any Bash command, you need to do it like this:
Shell.<bash_command_name>(<bash command parameters>)
For example, you want to create a new folder:
Shell.mkdir('-p', '/tmp/new_folder')
Installing
Simply run
pip install python-shell
Extending the basic functionality
It's possible to extend the existing functionality without forking the project. The library provides an interface to add a custom Command class.
Running the tests
This library contains tests written using unittest module, so just run in the project directory
python -m unittest
Also it's possible to run tests using Tox:
tox -e <env>
Supported environments:
- py27
- py35
- py36
- py37
- py38
- coverage (using Python 3)
- coverage (using Python 2.7)
- pep8 (style checking)
Other old versions of Python (e.g. 2.6, 3.4, etc) will never be supported. However, you always can implement such support in your forks.
Authors
- Alex Sokolov - Author - Albartash
License
This project is licensed under the MIT License - see the LICENSE.md file for details.
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distributions
Hashes for python_shell-1.0.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 433d4bd9789988e6d4eeb48670553600dd9c7a2da7783c5a8f23ef58d2a8bf39 |
|
MD5 | 050bbb3579befd5f0c6fe0b98082e978 |
|
BLAKE2b-256 | 751f03c0817b176f1cf45cff3dd7d7dfbf27eebcd44136819c68cae5630b9b89 |
Hashes for python_shell-1.0.0-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | c7f164c15b4e84e701dd19683d8a71ca9cf62b2367eb7eb3e816a5fd6c217b77 |
|
MD5 | 04f11652a59cfc9a72cba6d2e3123d6f |
|
BLAKE2b-256 | 59185f2813b554a4b95e6ecfa2aeaaea0cf8cc8230f8c1771c335f3b5f4e353f |