classification
Title: subprocess.pipe function
Type: enhancement Stage:
Components: Library (Lib) Versions: Python 3.3
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: Netto, aht, amaury.forgeotdarc, eric.araujo, pitrou, vincent.legoll, vlegoll
Priority: normal Keywords: patch

Created on 2008-08-12 17:23 by tebeka, last changed 2011-01-03 23:59 by tebeka.

Files
File name Uploaded Description Edit
pipe.patch tebeka, 2008-08-12 17:23 Patch file for "subprocess.pipe" review
toto.py vincent.legoll, 2008-08-26 13:02 alternate implementation (not a patch)
pipeline.py vincent.legoll, 2008-08-26 13:51 clean, doc & unit test (still not a patch)
pipeline.py vincent.legoll, 2008-09-01 14:57 new version (pylint, license, copyright)
Messages (10)
msg71062 - (view) Author: Miki Tebeka (tebeka) Date: 2008-08-12 17:23
Attached is a patch that add "pipe" command to the "subprocess" module.

pipe(["ls"], ["grep", "test_"]) will return the output of 
"ls | grep test_".
msg71063 - (view) Author: Miki Tebeka (tebeka) Date: 2008-08-12 17:35
Not sure about the name, maybe "chain" will be better?
msg71978 - (view) Author: Vincent Legoll (vincent.legoll) Date: 2008-08-26 13:02
Hello,

I was searching for a bug in subprocess
module when I saw your patch.

I was implementing the exact same functionality
and mixed some of your ideas in what I use now,
which is attached...

Feel free to use it
msg71979 - (view) Author: Vincent Legoll (vincent.legoll) Date: 2008-08-26 13:51
Here's a clean version with doc & test

enjoy !
msg72257 - (view) Author: Vincent Legoll (vincent.legoll) Date: 2008-09-01 14:57
- Added "shut pylint up" comment for ** keyword expansion
- Added Copyright & license header
msg72262 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-09-01 15:13
Vincent,
GPL licenced code is incompatible with the inclusion into python.
And if I am correct, you should sign a contributor agreement. Then the
licence text is not necessary.
msg72318 - (view) Author: Legoll Vincent (vlegoll) Date: 2008-09-02 08:26
On Mon, Sep 1, 2008 at 5:13 PM, Amaury Forgeot d'Arc
<report@bugs.python.org> wrote:
> Amaury Forgeot d'Arc <amauryfa@gmail.com> added the comment:
>
> Vincent,
> GPL licenced code is incompatible with the inclusion into python.
> And if I am correct, you should sign a contributor agreement. Then the
> licence text is not necessary.

This is not a patch against python, this is a standalone script, just
implementing the same functionality as the original bug report in a
slightly different way...

But thanks for the input anyways.

If this functionality is really interesting people and agreed to be integrated
into upstream subprocess module, I can rework it the right way, or work
from the original patch from the bug report.
msg114730 - (view) Author: Anh Hai Trinh (aht) Date: 2010-08-23 08:53
I've written a package which can do this with arbitrary redirection in all subcommands (and some more).

You can, for example, do this:

    >>> Pipe(Sh('echo -n foo >&2', {2: 1}), Sh('cat; echo ERROR >&2', {2: os.devnull})).capture(1).read()
    'foo'

The package is at: http://github.com/aht/pc.py
msg122557 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2010-11-27 21:01
pipe.patch looks interesting to me.  I would replace **kwargs with a keyword-only argument named stderr, since that’s the only key used.  This requires more tests and docs.
msg125226 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2011-01-03 20:06
I think this would be more useful if you could pass an optional input string (as in communicate()) and if it returned a (stdout, stderr) tuple. Or perhaps even a (return code, stdout, stderr) tuple; alternately, non-zero return codes could raise an exception.
History
Date User Action Args
2011-01-03 23:59:57tebekasetnosy: - tebeka
2011-01-03 20:06:02pitrousetnosy: + pitrou

messages: + msg125226
versions: + Python 3.3, - Python 3.2
2010-11-27 21:01:19eric.araujosetnosy: + eric.araujo
messages: + msg122557
2010-08-23 08:53:40ahtsetnosy: + aht
messages: + msg114730
2010-08-23 05:00:25Nettosetnosy: + Netto
2010-08-21 23:07:50georg.brandlsetversions: + Python 3.2, - Python 3.1, Python 2.7
2008-09-02 08:26:01vlegollsetnosy: + vlegoll
messages: + msg72318
2008-09-01 15:13:54amaury.forgeotdarcsetnosy: + amaury.forgeotdarc
messages: + msg72262
2008-09-01 14:57:59vincent.legollsetfiles: + pipeline.py
messages: + msg72257
2008-08-26 13:55:47pitrousetpriority: normal
versions: + Python 3.1, Python 2.7, - Python 2.6, Python 3.0
2008-08-26 13:51:19vincent.legollsetfiles: + pipeline.py
messages: + msg71979
2008-08-26 13:02:31vincent.legollsetfiles: + toto.py
nosy: + vincent.legoll
messages: + msg71978
2008-08-12 17:35:22tebekasetmessages: + msg71063
2008-08-12 17:23:58tebekacreate