Skip to main content

Command and Rule over your Shell

Project description

sultan logo

Command and Rule over your Shell

PyPI Version Travis Build Status MIT License Documentation Status

Sultan now supports Python 2.7+ and 3.0+

Note

Your input is welcome! Please provide your feedback by creating issues on Github

Install

pip install --upgrade sultan

Documentation

Documentation Status

Documentation is available on ReadTheDocs: http://sultan.readthedocs.io/en/latest/

What is Sultan?

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.

The simplest way to use Sultan is to just call it:

from sultan.api import Sultan
s = Sultan()
s.sudo("yum install -y tree").run()

Runs:

sudo yum install -y tree;

The recommended way of using Sultan is to use it in Context Management mode. Here is how to use Sultan with Context Management:

from sultan.api import Sultan

with Sultan.load(sudo=True) as s:
  s.yum("install -y tree").run()

Runs:

sudo su - root -c 'yum install -y tree;'

What if we want to install this command on a remote machine? You can easily achieve this using context management:

from sultan.api import Sultan

with Sultan.load(sudo=True, hostname="myserver.com") as sultan:
  sultan.yum("install -y tree").run()

Runs:

ssh root@myserver.com 'sudo su - root -c 'yum install -y tree;''

If you enter a wrong command, Sultan will print out details you need to debug and find the problem quickly.

Here, the same command was run on a Mac:

from sultan.api import Sultan

with Sultan.load(sudo=True, hostname="myserver.com") as sultan:
  sultan.yum("install -y tree").run()

Yields:

[sultan]: sudo su - root -c 'yum install -y tree;'
Password:
[sultan]: --{ STDERR }-------------------------------------------------------------------------------------------------------
[sultan]: | -sh: yum: command not found
[sultan]: -------------------------------------------------------------------------------------------------------------------

Want to get started? Simply install Sultan, and start writing your clean code:

pip install --upgrade sultan

If you have more questions, check the docs! http://sultan.readthedocs.io/en/latest/

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

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

sultan-0.6.5-py3-none-any.whl (16.1 kB view details)

Uploaded Python 3

sultan-0.6.5-py2-none-any.whl (16.1 kB view details)

Uploaded Python 2

File details

Details for the file sultan-0.6.5-py3-none-any.whl.

File metadata

File hashes

Hashes for sultan-0.6.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7ad19ede4806562ac937edb3736ada67453a2eeaf5d7c836c560a851c4092a1b
MD5 7339513f8defc258b282eba88165b1c9
BLAKE2b-256 0cbcec7c56f1564c8e4730d9289798284aeec0978b68a472b98ad4be9007ce87

See more details on using hashes here.

File details

Details for the file sultan-0.6.5-py2-none-any.whl.

File metadata

File hashes

Hashes for sultan-0.6.5-py2-none-any.whl
Algorithm Hash digest
SHA256 df39664efdfce1a016f08113db1d68a8cbc81442fb907e28011bac2ea9946d08
MD5 275f1b34f997ead16c317c4d07cd51d3
BLAKE2b-256 ed55d55f5ad2c1436a19023f40695b35eee1a0736555136c50bd56d5181fa300

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page