Toolchest for Python shell scripters

Banish growing bash scripts

Alexander Hultnér
Py.Watch

--

The code in the picture is unrelated to the article

Every once in a while we end up with a shell-script that’s grown out of it’s suit. At this point we need some tools to transition it into a language such as Python. Therefor I’ve collected a small set of tools for achieving these results.

The personal favourite

A personal favourite of mine is sh, I’ve used it several times and is very happy with it.

For the docker pirate

ShutIt focuses on docker (container) build. In addition to their own extensive documentation there’s also a great tutorial on how to build shell scripts in python with ShutIt over at Learn x in y Minutes.

For the make hacker

Tony Narlock (author of The Tao of tmux) describes invoke to me as “Invoke wraps subprocess commands into Makefile-like tasks”, I think that sums it up the purpose perfectly.

Following that advice Mr Narlock also recommended Fabric “Same as invoke, but catered to remote subprocess commands over SSH”, do check it out if you’re going to work with remote servers.

And when you’re at it don’t forget to checkout his libvcs tool which enables easy git (and other vcs systems) automation via python.

Not enough?

Don’t worry I added two great guides on python shell scripting and as a bonus I threw in a fun CLI UI library.

Example of a graph ui built with urwid

http://nvie.com/posts/writing-a-cli-in-python-in-under-60-seconds/

https://python-guide-pt-br.readthedocs.io/en/latest/scenarios/cli/

https://urwid.readthedocs.io/en/latest/

--

--