Python-sh - easy access to shell commands without needing to use subprocess

A bit off-topic, but still could apply for future python work… Feel free to separate into another topic.

I have starting using a python library named sh and thought I would share. It allows very easy access to shell commands without needing to use subprocess, etc. I figure since Whonix is largely shell script based it may come in handy.

Here are a few examples of usage (from the docs):

from sh import ifconfig
print(ifconfig("wlan0"))

# checkout master branch
git.checkout("master")

# print(the contents of this directory
print(ls("-l"))

# get the longest line of this file
longest_line = wc(__file__, "-L")

Note that these aren’t Python functions, these are running the binary commands on your system dynamically by resolving your $PATH, much like Bash does. In this way, all the programs on your system are easily available to you from within Python.

Github:
[url=https://github.com/amoffat/sh]https://github.com/amoffat/sh[/url]

Docs:
[url=https://amoffat.github.io/sh/]https://amoffat.github.io/sh/[/url]

That would be very useful, but the library is not available (yet?) from Debian. So we won’t be able to use it.

Available in jessie:
https://packages.debian.org/jessie/python-sh

I also just packaged it which can be used. I am going to use it for some of the systemd stuff I am working on

That could be troublesome. How was it packaged? When I read this, it sounds like we upload this to Whonix repository or copy into some source package and then are responsible for tracking it and keeping it updated. That looks troublesome maintenance wise. Or is it assumed, that this package is seldom updated and/or very unlikely to be ever in need of security updates?

What about using something like this?
https://github.com/hartwork/image-bootstrap/blob/master/image_bootstrap/executor.py

[quote=“Patrick, post:5, topic:929”]That could be troublesome. How was it packaged? When I read this, it sounds like we upload this to Whonix repository or copy into some source package and then are responsible for tracking it and keeping it updated. That looks troublesome maintenance wise. Or is it assumed, that this package is seldom updated and/or very unlikely to be ever in need of security updates?

What about using something like this?
https://github.com/hartwork/image-bootstrap/blob/master/image_bootstrap/executor.py[/quote]

[url=https://github.com/nrgaway/python-sh]https://github.com/nrgaway/python-sh[/url]

It’s a very small package. sh.py is one file. The features benefits are many compared to bootstrap executor and can be used in many packages.

I see.

Rather than packaging it ourselves, couldn’t we just download it from testing and install + add to Whonix repository, as we are doing with python-stem? (https://github.com/Whonix/Whonix/blob/c15437dfd36b5b643a44eaa28c187f027e588838/build-steps.d/1200_create-debian-packages#L132)

Not sure how relevant it is anyhow. Look like Debian jessie is to be blessed stable anytime soon anyhow.

Quote https://lists.debian.org/debian-devel-announce/2015/03/msg00002.html:

an April release is /a possibility/ - *however*