Set your shell free !
Combine python and shell command.
- Light: There are no dependencies
- Async: Work with async/await
- Testable: Unshell script are easily testable because they yield execution control
pip install unshellExecute script through unshell runtime
Usage:
unshell COMMAND [SCRIPT_PATH] [ARGS...]
Commands:
help Print this help message
run run a script through unshell runtime
Given the script: pause.py to pause all docker containers
def pause():
ids = yield from fetchContainerIds()
for id in ids:
yield f"docker pause {id}"
def fetchContainerIds():
ids = yield f"docker ps -q --no-trunc"
return ids.splitlines()Run it through unshell
unshell run pause.pyGiven the precedent script pause.py
from unshell import Unshell
import os
def main():
script = resolve('./scripts/pause.js') # resolve your python module
try:
Unshell({"env": os.environ})(script)
except Exception as err:
print(err)Here is some examples of what you can do with unshell
The code is available under the MIT license.
- finish spec
- example
- publish on pypi instead of test.pypi
