-í
ç¶<c       s  d  Z  d k Z d k Z d k Z d d d g Z d Z g  Z d „  Z d f  d „  ƒ  YZ d	 e f d
 „  ƒ  YZ	 e i
 d  d j o7 [ [	 d d d „ Z d d d „ Z d d d „ Z nA d d d „ Z d d d „ Z d d d „ Z e i d d	 g ƒ d „  Z e d j o e ƒ  n d S(   sn  Spawn 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.
Ns   popen2s   popen3s   popen4i   c     s    x t  D] }  |  i ƒ  q Wd  S(   N(   s   _actives   insts   poll(   s   inst(    (    s   /usr/lib/python2.2/popen2.pys   _cleanup s     s   Popen3c      s>   t  Z d  Z d Z d d d „ Z d „  Z d „  Z d „  Z RS(   sw   Class representing a child process.  Normally instances are created
    by the factory functions popen2() and popen3().iÿÿÿÿi    c 
   sG  t  ƒ  t i ƒ  \ } } t i ƒ  \ }	 } | o t i ƒ  \ } } n t i
 ƒ  |  _ |  i d j oL t i | d ƒ t i | d ƒ | o t i | d ƒ n |  i | ƒ n t i | ƒ t i | d | ƒ |  _ t i | ƒ t i |	 d | ƒ |  _ | o) t i | ƒ t i | d | ƒ |  _ n
 t |  _ t i |  ƒ d S(   sb  The parameter 'cmd' is the shell command to execute in a
        sub-process.  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.i    i   i   s   ws   rN(   s   _cleanups   oss   pipes   p2creads   p2cwrites   c2preads   c2pwrites   capturestderrs   errouts   errins   forks   selfs   pids   dup2s
   _run_childs   cmds   closes   fdopens   bufsizes   tochilds	   fromchilds   childerrs   Nones   _actives   append(
   s   selfs   cmds   capturestderrs   bufsizes   p2creads   errouts   p2cwrites   errins   c2pwrites   c2pread(    (    s   /usr/lib/python2.2/popen2.pys   __init__ s,     	c    sˆ   t  | t i ƒ o d d | g } n x2 t d t ƒ D]! } y t i | ƒ Wn n Xq6 Wz t i	 | d | ƒ Wd  t i
 d ƒ Xd  S(   Ns   /bin/shs   -ci   i    i   (   s
   isinstances   cmds   typess   StringTypess   ranges   MAXFDs   is   oss   closes   execvps   _exit(   s   selfs   cmds   i(    (    s   /usr/lib/python2.2/popen2.pys
   _run_child; s      c    s„   |  i d j  oi yL t i |  i t i ƒ \ } } | |  i j o | |  _ t i |  ƒ n Wn t i j
 o n Xn |  i Sd S(   sh   Return the exit status of the child process if it has finished,
        or -1 if it hasn't finished yet.i    N(	   s   selfs   stss   oss   waitpids   pids   WNOHANGs   _actives   removes   error(   s   selfs   pids   sts(    (    s   /usr/lib/python2.2/popen2.pys   pollH s     		c    sP   t  i |  i d ƒ \ } } | |  i j o | |  _ t i |  ƒ n |  i Sd S(   s9   Wait for and return the exit status of the child process.i    N(   s   oss   waitpids   selfs   pids   stss   _actives   remove(   s   selfs   pids   sts(    (    s   /usr/lib/python2.2/popen2.pys   waitU s     	(   s   __name__s
   __module__s   __doc__s   stss   __init__s
   _run_childs   polls   wait(    (    (    s   /usr/lib/python2.2/popen2.pys   Popen3 s    		s   Popen4c      s   t  Z e Z d d „ Z RS(   Niÿÿÿÿc    sæ   t  ƒ  t i ƒ  \ } } t i ƒ  \ } } t i ƒ  |  _	 |  i	 d j oA t i
 | d ƒ t i
 | d ƒ t i
 | d ƒ |  i | ƒ n t i | ƒ t i | d | ƒ |  _ t i | ƒ t i | d | ƒ |  _ t i |  ƒ d  S(   Ni    i   i   s   ws   r(   s   _cleanups   oss   pipes   p2creads   p2cwrites   c2preads   c2pwrites   forks   selfs   pids   dup2s
   _run_childs   cmds   closes   fdopens   bufsizes   tochilds	   fromchilds   _actives   append(   s   selfs   cmds   bufsizes   p2creads   c2preads   p2cwrites   c2pwrite(    (    s   /usr/lib/python2.2/popen2.pys   __init__a s    (   s   __name__s
   __module__s   Nones   childerrs   __init__(    (    (    s   /usr/lib/python2.2/popen2.pys   Popen4^ s   i   s   winiÿÿÿÿs   tc    s)   t  i |  | | ƒ \ } } | | f Sd S(   sÄ   Execute the shell command 'cmd' in a sub-process.  If 'bufsize' is
        specified, it sets the buffer size for the I/O pipes.  The file objects
        (child_stdout, child_stdin) are returned.N(   s   oss   popen2s   cmds   modes   bufsizes   ws   r(   s   cmds   bufsizes   modes   rs   w(    (    s   /usr/lib/python2.2/popen2.pys   popen2w s     c    s/   t  i |  | | ƒ \ } } } | | | f Sd S(   sÒ   Execute the shell command 'cmd' in a sub-process.  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.N(   s   oss   popen3s   cmds   modes   bufsizes   ws   rs   e(   s   cmds   bufsizes   modes   rs   es   w(    (    s   /usr/lib/python2.2/popen2.pys   popen3~ s     c    s)   t  i |  | | ƒ \ } } | | f Sd S(   sË   Execute the shell command 'cmd' in a sub-process.  If 'bufsize' is
        specified, it sets the buffer size for the I/O pipes.  The file objects
        (child_stdout_stderr, child_stdin) are returned.N(   s   oss   popen4s   cmds   modes   bufsizes   ws   r(   s   cmds   bufsizes   modes   rs   w(    (    s   /usr/lib/python2.2/popen2.pys   popen4… s     c    s&   t  |  d | ƒ } | i | i f Sd S(   sÄ   Execute the shell command 'cmd' in a sub-process.  If 'bufsize' is
        specified, it sets the buffer size for the I/O pipes.  The file objects
        (child_stdout, child_stdin) are returned.i    N(   s   Popen3s   cmds   bufsizes   insts	   fromchilds   tochild(   s   cmds   bufsizes   modes   inst(    (    s   /usr/lib/python2.2/popen2.pys   popen2Œ s     c    s,   t  |  d | ƒ } | i | i | i f Sd S(   sÒ   Execute the shell command 'cmd' in a sub-process.  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.i   N(   s   Popen3s   cmds   bufsizes   insts	   fromchilds   tochilds   childerr(   s   cmds   bufsizes   modes   inst(    (    s   /usr/lib/python2.2/popen2.pys   popen3“ s     c    s#   t  |  | ƒ } | i | i f Sd S(   sË   Execute the shell command 'cmd' in a sub-process.  If 'bufsize' is
        specified, it sets the buffer size for the I/O pipes.  The file objects
        (child_stdout_stderr, child_stdin) are returned.N(   s   Popen4s   cmds   bufsizes   insts	   fromchilds   tochild(   s   cmds   bufsizes   modes   inst(    (    s   /usr/lib/python2.2/popen2.pys   popen4š s     c     s‘  d } d } t i d j o
 d } n | i ƒ  } d GHt | ƒ \ } } | i	 | ƒ | i
 ƒ  | i ƒ  } | i ƒ  | j o t d | | f ƒ ‚ n d GHy t | g ƒ \ } } }  Wn t | ƒ \ } } }  n X| i	 | ƒ | i
 ƒ  | i ƒ  } | i ƒ  | j o t d | | f ƒ ‚ n |  i ƒ  } | o t d | ƒ ‚ n x t D] } | i ƒ  q]Wt o t d	 ƒ ‚ n d
 GHd  S(   Ns   cats   ab cd
s   nts   mores   testing popen2...s   wrote %s read %ss   testing popen3...s   unexected %s on stderrs   _active not emptys   All OK(   s   cmds   teststrs   oss   names   strips   expecteds   popen2s   rs   ws   writes   closes   reads   gots
   ValueErrors   popen3s   es   _actives   insts   wait(   s   es   ws   cmds   rs   insts   teststrs   expecteds   got(    (    s   /usr/lib/python2.2/popen2.pys   _test£ s>    


 s   __main__(   s   __doc__s   oss   syss   typess   __all__s   MAXFDs   _actives   _cleanups   Popen3s   Popen4s   platforms   popen2s   popen3s   popen4s   extends   _tests   __name__(   s   __all__s   MAXFDs   Popen4s   popen2s   Popen3s   popen3s   syss   _cleanups   popen4s   _tests   oss   _actives   types(    (    s   /usr/lib/python2.2/popen2.pys   ? s*   				G	#