�`^c@sVdZddlZddlZddlZejdedd�dddgZyejd �ZWne e
fk
r�d
ZnXgZd�Zddd
��YZ
de
fd��YZejd dks�ejdkr[
[ddd�Zddd�Zddd�Zn@ddd�Zddd�Zddd�Zejddg�dS(snSpawn a command with pipes to its stdin, stdout, and optionally stderr.
The normal os.popen(cmd, mode) call spawns a shell command and provides a
file interface to just the input or output of the process depending on
whether mode is 'r' or 'w'. This module provides the functions popen2(cmd)
and popen3(cmd) which return two or three pipes to the spawned command.
i�Ns<The popen2 module is deprecated. Use the subprocess module.t
stacklevelitpopen2tpopen3tpopen4tSC_OPEN_MAXicCsYxRtD]I}|jdtj�dkrytj|�WqQtk
rMqQXqqWdS(Nt
_deadstatei(t_activetpolltsystmaxinttremovet
ValueError(tinst((s/sys/lib/python2.7/popen2.pyt_cleanups
tPopen3cBsJeZdZdZedd�Zd�Zd�Zdd�Z d�Z
RS(s{Class representing a child process. Normally, instances are created
internally by the functions popen2() and popen3().i�c
Cs;t�||_tj�\}}tj�\}}|rOtj�\}} ntj�|_|jdkr�tj|d�tj|d�|r�tj| d�n|j|�ntj|�tj |d|�|_
tj|�tj |d|�|_|r.tj| �tj |d|�|_n d|_dS(sdThe parameter 'cmd' is the shell command to execute in a
sub-process. On UNIX, 'cmd' may be a sequence, in which case arguments
will be passed directly to the program without shell intervention (as
with os.spawnv()). If 'cmd' is a string it will be passed to the shell
(as with os.system()). The 'capturestderr' flag, if true, specifies
that the object should capture standard error output of the child
process. The default is false. If the 'bufsize' parameter is
specified, it specifies the size of the I/O buffers to/from the child
process.iiitwtrN(R
tcmdtostpipetforktpidtdup2t
_run_childtclosetfdopenttochildt fromchildtchilderrtNone(
tselfRt
capturestderrtbufsizetp2creadtp2cwritetc2preadtc2pwriteterroutterrin((s/sys/lib/python2.7/popen2.pyt__init__(s*
cCsE|jdtj�|jdkrAtdk rAtj|�qAndS(NRi(RRR tstsRRtappend(R((s/sys/lib/python2.7/popen2.pyt__del__JscCs^t|t�r!dd|g}ntjdt�ztj|d|�Wdtjd�XdS(Ns/bin/shs-ciii(t
isinstancet
basestringRt
closerangetMAXFDtexecvpt_exit(RR((s/sys/lib/python2.7/popen2.pyRRscCs�|jdkr~y=tj|jtj�\}}||jkrK||_nWq~tjk
rz|dk r{||_q{q~Xn|jS(shReturn the exit status of the child process if it has finished,
or -1 if it hasn't finished yet.iN(R(RtwaitpidRtWNOHANGterrorR(RRRR(((s/sys/lib/python2.7/popen2.pyR[scCs=|jdkr6tj|jd�\}}||_n|jS(s9Wait for and return the exit status of the child process.i(R(RR1R(RRR(((s/sys/lib/python2.7/popen2.pytwaitisN(t__name__t
__module__t__doc__R(tFalseR'R*RRRR4(((s/sys/lib/python2.7/popen2.pyR"s" tPopen4cBseZdZdd�ZRS(i�cCs�t�||_tj�\}}tj�\}}tj�|_|jdkr�tj|d�tj|d�tj|d�|j|�ntj|�tj |d|�|_
tj|�tj |d|�|_dS(NiiiRR(R
RRRRRRRRRRR(RRR R!R"R#R$((s/sys/lib/python2.7/popen2.pyR'ws
N(R5R6RRR'(((s/sys/lib/python2.7/popen2.pyR9tsitwintos2emxttcCs%tj|||�\}}||fS(s�Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
be a sequence, in which case arguments will be passed directly to the
program without shell intervention (as with os.spawnv()). If 'cmd' is a
string it will be passed to the shell (as with os.system()). If
'bufsize' is specified, it sets the buffer size for the I/O pipes. The
file objects (child_stdout, child_stdin) are returned.(RR(RR tmodeRR((s/sys/lib/python2.7/popen2.pyR�scCs+tj|||�\}}}|||fS(s�Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
be a sequence, in which case arguments will be passed directly to the
program without shell intervention (as with os.spawnv()). If 'cmd' is a
string it will be passed to the shell (as with os.system()). If
'bufsize' is specified, it sets the buffer size for the I/O pipes. The
file objects (child_stdout, child_stdin, child_stderr) are returned.(RR(RR R=RRte((s/sys/lib/python2.7/popen2.pyR�scCs%tj|||�\}}||fS(s�Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
be a sequence, in which case arguments will be passed directly to the
program without shell intervention (as with os.spawnv()). If 'cmd' is a
string it will be passed to the shell (as with os.system()). If
'bufsize' is specified, it sets the buffer size for the I/O pipes. The
file objects (child_stdout_stderr, child_stdin) are returned.(RR(RR R=RR((s/sys/lib/python2.7/popen2.pyR�scCs"t|t|�}|j|jfS(s�Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
be a sequence, in which case arguments will be passed directly to the
program without shell intervention (as with os.spawnv()). If 'cmd' is a
string it will be passed to the shell (as with os.system()). If
'bufsize' is specified, it sets the buffer size for the I/O pipes. The
file objects (child_stdout, child_stdin) are returned.(RR8RR(RR R=R((s/sys/lib/python2.7/popen2.pyR�scCs(t|t|�}|j|j|jfS(s�Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
be a sequence, in which case arguments will be passed directly to the
program without shell intervention (as with os.spawnv()). If 'cmd' is a
string it will be passed to the shell (as with os.system()). If
'bufsize' is specified, it sets the buffer size for the I/O pipes. The
file objects (child_stdout, child_stdin, child_stderr) are returned.(RtTrueRRR(RR R=R((s/sys/lib/python2.7/popen2.pyR�scCst||�}|j|jfS(s�Execute the shell command 'cmd' in a sub-process. On UNIX, 'cmd' may
be a sequence, in which case arguments will be passed directly to the
program without shell intervention (as with os.spawnv()). If 'cmd' is a
string it will be passed to the shell (as with os.system()). If
'bufsize' is specified, it sets the buffer size for the I/O pipes. The
file objects (child_stdout_stderr, child_stdin) are returned.(R9RR(RR R=R((s/sys/lib/python2.7/popen2.pyR�s((R7RRtwarningstwarntDeprecationWarningt__all__tsysconfR.tAttributeErrorRRR
RR9tplatformRRRtextend(((s/sys/lib/python2.7/popen2.pyt<module>s.
R"
|