Skip to content
 
 

Repository files navigation

un shell

Set your shell free !

Combine python and shell command.

Features

  • Light: There are no dependencies
  • Async: Work with async/await
  • Testable: Unshell script are easily testable because they yield execution control

Setup

pip install unshell

Usage

Execute script through Shell

Execute 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.py

Embedded script inside apps

Given 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)

Examples

Here is some examples of what you can do with unshell

License

The code is available under the MIT license.

TODO

  • finish spec
  • example
  • publish on pypi instead of test.pypi

About

Set your shell free !

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages