![]() Official documentation is available here. Test coverage is one of the top priority for this library: However, you always can implement such support in your forks. This library contains tests written using unittest module, so just run in the project directory python -m unittestĪlso it's possible to run tests using Tox: tox -e The library provides an interface to add a custom Command class. It's possible to extend the existing functionality without forking the project. This feature enables autocomplete of commands in a few popular interfaces: ![]() Shell class now allows to list all available commands simply by dir ( Shell ) However, even if you didn't save a reference to your command, you still can access it. When the command fails (returncode is non-zero), Shell throws a ShellException error. To do this, use Shell class as a callable instance: command = Shell ( '2to3' ) It's also possible to run a command which name is not a valid Python identifier. To run any Bash command, you need to do it like this: Shell.()įor example, you want to create a new folder: Shell. output )) # Prints out command's stdout print ( decode_stream ( command. arguments ) # prints "" print ( decode_stream ( command. return_code ) # prints "0" print ( command. command ) # prints "whoami" print ( repr ( command )) # Does the same as above print ( command. whoami () # Equals "whoami" print ( command ) # Prints representation of command in shell print ( command. ls ( '-l', '$HOME' ) # Equals "ls -l $HOME" command = Shell. This library is pretty easy to use: from python_shell import Shell from python_ import decode_stream Shell. It's compatible with Python 2 (can be useful in old large systems).It is easy and intuitive (see examples).This library comes with a few major points to use it: A flexible, easy-to-use library to integrate your Python script with Unix ecosystems. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |