ANN: Version 0.1.5 of sarge (a subprocess wrapper library) has been released.

Vinay Sajip vinay_sajip at yahoo.co.uk
Mon Jun 18 07:17:15 EDT 2018


Version 0.1.5 of Sarge, a cross-platform library which wraps the subprocessmodule in the standard library, has been released.
What changed?-------------
- Fixed #37: Instead of an OSError with a "no such file or directory" message,  a ValueError is raised with a more informative "Command not found" message.
- Fixed #38: Replaced ``async`` keyword argument with ``async_``, as ``async``  has become a keyword in Python 3.7.
- Fixed #39: Updated tutorial example on progress monitoring.
What does Sarge do?-------------------
Sarge tries to make interfacing with external programs from yourPython applications easier than just using subprocess alone.
Sarge offers the following features:
* A simple way to run command lines which allows a rich subset of Bash-style shell command syntax, but parsed and run by sarge so that youcan run on Windows without cygwin (subject to having those commandsavailable):
>>> from sarge import capture_stdout>>> p = capture_stdout('echo foo | cat; echo bar')>>> for line in p.stdout: print(repr(line))...'foo\n''bar\n'
* The ability to format shell commands with placeholders, such thatvariables are quoted to prevent shell injection attacks.
* The ability to capture output streams without requiring you toprogram your own threads. You just use a Capture object and then youcan read from it as and when you want.
* The ability to look for patterns in captured output and to interactaccordingly with the child process.
Advantages over subprocess---------------------------
Sarge offers the following benefits compared to using subprocess:
* The API is very simple.
* It's easier to use command pipelines - using subprocess out of thebox often leads to deadlocks because pipe buffers get filled up.
* It would be nice to use Bash-style pipe syntax on Windows, butWindows shells don't support some of the syntax which is useful, like&&, ||, |& and so on. Sarge gives you that functionality on Windows,without cygwin.
* Sometimes, subprocess.Popen.communicate() is not flexible enough forone's needs - for example, when one needs to process output a line ata time without buffering the entire output in memory.
* It's desirable to avoid shell injection problems by having theability to quote command arguments safely.
* subprocess allows you to let stderr be the same as stdout, but notthe other way around - and sometimes, you need to do that.
Python version and platform compatibility-----------------------------------------
Sarge is intended to be used on any Python version >= 2.6 and istested on Python versions 2.6, 2.7, 3.3, 3.4, 3.5, 3.6 and 3.7 on Linux,Windows, and Mac OS X (not all versions are tested on all platforms,but sarge is expected to work correctly on all these versions on allthese platforms).
Finding out more----------------
You can read the documentation at
http://sarge.readthedocs.org/
There's a lot more information, with examples, than I can put intothis post.
You can install Sarge using "pip install sarge" to try it out. Theproject is hosted on BitBucket at
https://bitbucket.org/vinay.sajip/sarge/
And you can leave feedback on the issue tracker there.
I hope you find Sarge useful!
Regards,
Vinay Sajip


More information about the Python-announce-list mailing list