³ò
ŠaIc           @   s5   d  Z  d d k Z d d k Z d d d „  ƒ  YZ d S(   s%   process.py - Process spawning module.iÿÿÿÿNt   Processc           B   s2   e  Z d  Z d „  Z d „  Z d „  Z d „  Z RS(   sI  The subprocess and popen2 modules in Python are broken (see issue
    #1336). The problem (i.e. complete crash) they can cause happen fairly
    often (once is too often) in Comix when calling "rar" or "unrar" to
    extract specific files from archives. We roll our own very simple
    process spawning module here instead.
    c         C   s   | |  _  d |  _ d S(   su   Setup a Process where <args> is a sequence of arguments that defines
        the process, e.g. ['ls', '-a'].
        N(   t   _argst   Nonet   _proc(   t   selft   args(    (    sG   /home/sork/Pontus/Programmering/Python/Comix/comix-4.0.4/src/process.pyt   __init__   s    	c         C   sJ   y, t  i |  i d t  i ƒ|  _ |  i i SWn t j
 o d Sn Xd S(   s   Spawns the process, and returns its stdout.
        (NOTE: separate function to make python2.4 exception syntax happy)
        t   stdoutN(   t
   subprocesst   PopenR   t   PIPER   R   t	   ExceptionR   (   R   (    (    sG   /home/sork/Pontus/Programmering/Python/Comix/comix-4.0.4/src/process.pyt   _exec   s
    c         C   s*   z t  i ƒ  |  i ƒ  SWd t  i ƒ  Xd S(   s†   Spawn the process defined by the args in __init__(). Return a
        file-like object linked to the spawned process' stdout.
        N(   t   gct   disableR   t   enable(   R   (    (    sG   /home/sork/Pontus/Programmering/Python/Comix/comix-4.0.4/src/process.pyt   spawn#   s    
c         C   s-   |  i  d j o t d ƒ ‚ n |  i  i ƒ  S(   s"   Wait for the process to terminate.s   Process not spawned.N(   R   R   R   t   wait(   R   (    (    sG   /home/sork/Pontus/Programmering/Python/Comix/comix-4.0.4/src/process.pyR   -   s    (   t   __name__t
   __module__t   __doc__R   R   R   R   (    (    (    sG   /home/sork/Pontus/Programmering/Python/Comix/comix-4.0.4/src/process.pyR       s
   		
	
(    (   R   R   R   R    (    (    (    sG   /home/sork/Pontus/Programmering/Python/Comix/comix-4.0.4/src/process.pys   <module>   s   