ó zfc@sVdZddlZddlZddlZejdeddƒdddgZyejd ƒZWne e fk rd ZnXgZ d „Z d dd „ƒYZ de fd„ƒYZejd dksÜejdkr[ [ddd„Zddd„Zddd„Zn@ddd„Zddd„Zddd„Zejd dgƒ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 stacklevelitpopen2tpopen3tpopen4t SC_OPEN_MAXicCsYxRtD]I}|jdtjƒdkrytj|ƒWqQtk rMqQXqqWdS(Nt _deadstatei(t_activetpolltsystmaxinttremovet ValueError(tinst((s/usr/lib64/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/usr/lib64/python2.7/popen2.pyt__init__(s*     cCsE|jdtjƒ|jdkrAtdk rAtj|ƒqAndS(NRi(RRR tstsRRtappend(R((s/usr/lib64/python2.7/popen2.pyt__del__Js cCs^t|tƒr!dd|g}ntjdtƒztj|d|ƒWdtjdƒXdS(Ns/bin/shs-ciii(t isinstancet basestringRt closerangetMAXFDtexecvpt_exit(RR((s/usr/lib64/python2.7/popen2.pyRRs cCs…|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/usr/lib64/python2.7/popen2.pyR[s cCsR|jdkrKtj|jdƒ\}}||jks?t‚||_n|jS(s9Wait for and return the exit status of the child process.i(R(RR1RtAssertionError(RRR(((s/usr/lib64/python2.7/popen2.pytwaitis  N( t__name__t __module__t__doc__R(tFalseR'R*RRRR5(((s/usr/lib64/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/usr/lib64/python2.7/popen2.pyR'ws   N(R6R7RRR'(((s/usr/lib64/python2.7/popen2.pyR:tsitwintos2emxttcCs%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/usr/lib64/python2.7/popen2.pyRscCs+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/usr/lib64/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/usr/lib64/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.(RR9RR(RR R>R ((s/usr/lib64/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/usr/lib64/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.(R:RR(RR R>R ((s/usr/lib64/python2.7/popen2.pyR¿s((R8RRtwarningstwarntDeprecationWarningt__all__tsysconfR.tAttributeErrorR RR RR:tplatformRRRtextend(((s/usr/lib64/python2.7/popen2.pyts.       R"