ANN: Version 0.1.2 of sarge (a subprocess wrapper library) has beenreleased.


Vinay Sajip

Version 0.1.2 of Sarge, a cross-platform library which wraps the subprocess
module in the standard library, has been released.

What changed?

- Fixed issue #12: Prevented a hang which occurred when a redirection failed.

- Fixed issue #11: Added "+" to the characters allowed in parameters.

- Fixed issue #10: Removed a spurious debugger breakpoint.

- Fixed issue #9: Relative pathnames in redirections are now relative to the
current working directory for the redirected process.

- Added the ability to pass objects with "fileno()" methods as values
to the "input" argument of "run()", and a "Feeder" class which
facilitates passing data to child processes dynamically over time (rather
than just an initial string, byte-string or file).

- Added functionality under Windows to use PATH, PATHEXT and the
registry to find appropriate commands. This can e.g. convert a
command 'foo bar', if '' is a Python script in the
c:\Tools directory which is on the path, to the equivalent
'c:\Python26\Python.exe c:\Tools\ bar'. This is done internally
when a command is parsed, before it is passed to subprocess.

- Fixed issue #7: Corrected handling of whitespace and redirections.

- Fixed issue #8: Added a missing import.

- Added Travis integration.

- Added encoding parameter to the "Capture" initializer.

- Fixed issue #6: addressed bugs in Capture logic so that iterating over
captures is closer to subprocess behaviour.

- Tests added to cover added functionality and reported issues.

- Numerous documentation updates.

What does Sarge do?

Sarge tries to make interfacing with external programs from your
Python 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 you
can run on Windows without cygwin (subject to having those commands

* The ability to format shell commands with placeholders, such that
variables are quoted to prevent shell injection attacks.

* The ability to capture output streams without requiring you to
program your own threads. You just use a Capture object and then you
can read from it as and when you want.

* The ability to look for patterns in captured output and to interact
accordingly 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 the
box often leads to deadlocks because pipe buffers get filled up.

* It would be nice to use Bash-style pipe syntax on Windows, but
Windows 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 for
one's needs - for example, when one needs to process output a line at
a time without buffering the entire output in memory.

* It's desirable to avoid shell injection problems by having the
ability to quote command arguments safely.

* subprocess allows you to let stderr be the same as stdout, but not
the 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 is
tested on Python versions 2.6, 2.7, 3.1, 3.2 and 3.3 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 all
these platforms).

Finding out more

You can read the documentation at

There's a lot more information, with examples, than I can put into
this post.

You can install Sarge using "pip install sarge" to try it out. The
project is hosted on BitBucket at

And you can leave feedback on the issue tracker there.

I hope you find Sarge useful!


Vinay Sajip


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question