Home | Trees | Index | Help |
|
---|
Package CedarBackup2 :: Module util :: Class Pipe |
|
Popen3
--+ |Popen4
--+ | Pipe
Specialized pipe class for use by executeCommand
.
The executeCommand
function needs a specialized
way of interacting with a pipe that isn't satisfied by the standard
Popen3
and Popen4
classes in
popen2
. First, executeCommand
only reads from
the pipe, and never writes to it. Second, executeCommand
needs a way to discard all output written to stderr
, as a
means of simulating the shell 2>/dev/null
construct.
This class inherits from Popen4
. If the
ignoreStderr
flag is passed in as False
, then
the standard Popen4
constructor will be called and
stdout
and stderr
will be intermingled in the
output.
Otherwise, we'll call a custom version of the constructor which was
basically stolen from the real constructor in
python2.3/Lib/popen2.py
. This custom constructor will
redirect the stderr
file descriptor to
/dev/null
. I've done this based on a suggestion from Donn
Cave on comp.lang.python.
In either case, the tochild
file object is always closed
before returning from the constructor, since it is never needed by
executeCommand
.
I really wish there were a prettier way to do this. Unfortunately, I
need access to the guts of the constructor implementation because of the
way the pipe process is forked, etc. It doesn't work to just call the
superclass constructor and then modify a few things afterwards. Even
worse, I have to access private popen2
module members
_cleanup
and _active
in order to duplicate the
implementation.
subprocess.Popen
-based implementation when
that class is available.
Copyright: Some of this code, prior to customization, was originally part of the Python 2.3 codebase. Python code is copyright (c) 2001, 2002 Python Software Foundation; All Rights Reserved.
Method Summary | |
---|---|
__init__(self,
cmd,
bufsize,
ignoreStderr)
| |
Inherited from Popen3 | |
Return the exit status of the child process if it has finished, or -1 if it hasn't finished yet. | |
Wait for and return the exit status of the child process. |
Class Variable Summary | |
---|---|
Inherited from Popen4 | |
NoneType |
childerr = None |
Inherited from Popen3 | |
int |
sts = -1 |
Home | Trees | Index | Help |
|
---|
Generated by Epydoc 2.1 on Mon Sep 4 13:49:34 2006 | http://epydoc.sf.net |