def un_bzip2(self, content): return sh.bzcat(_in=content).stdout
# Alt (but less pythonic/simple IMHO): gawel/chut, plumbum, sarge # Special keyword args: https://amoffat.github.io/sh/special_arguments.html#special-arguments - all commands are checked at 'from sh import' time so they are guaranteed to exist - Always use `_err=sys.stderr` ou `_err_to_out=True` because default is to discard commands stderr - `print()` is NEEDED to display command output (or you need to use `_out=sys.stdout`) - `_piped='direct'` is useful to connect processes without consuming any memory - `_iter` : creates a line generator => you can chain lazy functions taking a 'input_iterator' as input & output - a command invocation return a `RunningCommand` object, on which you can wait for the text output (by calling `str()` on it) or get a list of output lines (by calling `list()` on it) import pip pip.main(['install', '--proxy=' + PROXY, 'requests==2.7.0', 'retrying==1.3.3', 'sh==1.11']) import sh, sys sh = sh(_err=sys.stderr, _out=None) # setting default commands redirections sh.bzcat(...) if len(argv) > 1: pipe = cat(argv[1], _iter=True, _err=stderr) # `pipe` is an input_lines_iterator else: pipe = cat(_in=stdin, _iter=True, _err=stderr) (import [sh [cat grep wc]]) # in Hy, aka Python with Lisp syntax (-> (cat "/usr/share/dict/words") (grep "-E" "^hy") (wc "-l")) """""""""""""""""""""""""" "" Libs & tools for DEVS ! """""""""""""""""""""""""" pew > virtualenv # sandbox. To move an existing environment: virtualenv --relocatable $env pip # NEVER sudo !! > easyinstall - Distutils2 has been abandoned :( Check buildout/conda/bento/hashdist/pyinstaller for new projects or keep using setuptools: https://packaging.python.org