Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #20222
| From | Vinay Sajip <vinay_sajip@yahoo.co.uk> |
|---|---|
| Newsgroups | comp.lang.python, comp.lang.python.announce |
| Subject | ANN: Sarge, a library wrapping the subprocess module, has been released. |
| Date | 2012-02-10 11:28 -0800 |
| Organization | http://groups.google.com |
| Message-ID | <mailman.5693.1328974297.27778.python-announce-list@python.org> (permalink) |
Cross-posted to 2 groups.
Sarge, a cross-platform library which wraps the subprocess module in
the standard library, has been released.
What does it 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
available):
>>> 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 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.
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
http://sarge.readthedocs.org/
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
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
Back to comp.lang.python | Previous | Next — Next in thread | Find similar | Unroll thread
ANN: Sarge, a library wrapping the subprocess module, has been released. Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2012-02-10 11:28 -0800
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. Anh Hai Trinh <anh.hai.trinh@gmail.com> - 2012-02-12 01:41 -0800
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. Anh Hai Trinh <anh.hai.trinh@gmail.com> - 2012-02-12 01:41 -0800
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2012-02-12 03:31 -0800
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. Anh Hai Trinh <anh.hai.trinh@gmail.com> - 2012-02-12 07:35 -0800
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. Anh Hai Trinh <anh.hai.trinh@gmail.com> - 2012-02-12 08:19 -0800
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2012-02-12 12:21 -0800
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2012-02-12 12:13 -0800
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. Anh Hai Trinh <anh.hai.trinh@gmail.com> - 2012-02-12 19:57 -0800
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2012-02-13 02:34 -0800
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. Rick Johnson <rantingrickjohnson@gmail.com> - 2012-02-12 20:26 -0800
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. Rick Johnson <rantingrickjohnson@gmail.com> - 2012-02-12 20:08 -0800
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. Anh Hai Trinh <anh.hai.trinh@gmail.com> - 2012-02-12 23:08 -0800
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2012-02-13 02:59 -0800
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-02-17 14:49 +0100
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. Vinay Sajip <vinay_sajip@yahoo.co.uk> - 2012-02-17 09:19 -0800
Re: ANN: Sarge, a library wrapping the subprocess module, has been released. 88888 Dihedral <dihedral88888@googlemail.com> - 2012-02-17 09:29 -0800
csiph-web