Sultan

Sultan

Command and Rule over your Shell

Sultan is a Python package for interfacing with command-line utilities, like yum, apt-get, or ls, in a Pythonic manner. It lets you run command-line utilities using simple function calls.

Here is how you’d use Sultan:

from sultan.api import Sultan

def install_tree():
    '''
    Install 'tree' package.
    '''
    s = Sultan()
    s.sudo("yum install -y tree").run()

Here is how to use Sultan with Context Management:

from sultan.api import Sultan

def echo_hosts():
    '''
    Echo the contents of `/etc/hosts`
    '''
    with Sultan.load(cwd="/etc") as s:
        s.cat("hosts").run()

That’s it!