;
Ńâ"Ic               @   s   d  Z  d Z d d l Z d d l Z d d l Td d l m Z d d d d  Z d   Z d d d d	  Z	 d d d d
  Z
 d d d d  Z d d  Z d S(   uě   distutils.spawn

Provides the 'spawn()' function, a front-end to various platform-
specific functions for launching another program in a sub-process.
Also provides the 'find_executable()' to search the path for a given
executable name.
u7   $Id: spawn.py 59793 2008-01-06 21:13:42Z georg.brandl $i    N(   u   *(   u   logi   c             C   s   t  j d k o t |  | d | nb t  j d k o t |  | d | n; t  j d k o t |  | d | n t d t  j   d S(   u  Run another program, specified as a command list 'cmd', in a new
    process.  'cmd' is just the argument list for the new process, ie.
    cmd[0] is the program to run and cmd[1:] are the rest of its arguments.
    There is no way to run a program with a name different from that of its
    executable.

    If 'search_path' is true (the default), the system's executable
    search path will be used to find the program; otherwise, cmd[0]
    must be the exact path to the executable.  If 'dry_run' is true,
    the command will not actually be run.

    Raise DistutilsExecError if running the program fails in any way; just
    return on success.
    u   posixu   dry_runu   ntu   os2u1   don't know how to spawn programs on platform '%s'N(   u   osu   nameu   _spawn_posixu	   _spawn_ntu
   _spawn_os2u   DistutilsPlatformError(   u   cmdu   search_pathu   verboseu   dry_run(    (    u,   /mit/python/lib/python3.0/distutils/spawn.pyu   spawn   s    c             C   sQ   xJ t  t |    D]6 } |  | j d  d k o d |  | |  | <q q W|  S(   uŠ   Quote command-line arguments for DOS/Windows conventions: just
    wraps every argument which contains blanks in double quotes, and
    returns a new argument list.
    u    i˙˙˙˙u   "%s"(   u   rangeu   lenu   find(   u   argsu   i(    (    u,   /mit/python/lib/python3.0/distutils/spawn.pyu   _nt_quote_args)   s
    
 c             C   sü   |  d } t  |   }  | o t |  p | } n t j d j | g |  d d     | p y t j t j | |   } WnH t k
 o< } z& t	 d |  d | j
 d f   WYd  d  } ~ Xn X| d k o t	 d |  d | f   qř n d  S(   Ni    u    i   u   command '%s' failed: %si˙˙˙˙u'   command '%s' failed with exit status %d(   u   _nt_quote_argsu   find_executableu   logu   infou   joinu   osu   spawnvu   P_WAITu   OSErroru   DistutilsExecErroru   args(   u   cmdu   search_pathu   verboseu   dry_runu
   executableu   rcu   exc(    (    u,   /mit/python/lib/python3.0/distutils/spawn.pyu	   _spawn_nt8   s    
'2c             C   s  |  d } | o t  |  p | } n t j d j | g |  d d     | pŽ y t j t j | |   } WnH t k
 o< } z& t d |  d | j	 d f   WYd  d  } ~ Xn X| d k o6 t
 d |  d | f  t d |  d | f   qn d  S(   Ni    u    i   u   command '%s' failed: %si˙˙˙˙u'   command '%s' failed with exit status %d(   u   find_executableu   logu   infou   joinu   osu   spawnvu   P_WAITu   OSErroru   DistutilsExecErroru   argsu   print(   u   cmdu   search_pathu   verboseu   dry_runu
   executableu   rcu   exc(    (    u,   /mit/python/lib/python3.0/distutils/spawn.pyu
   _spawn_os2M   s    
'2c             C   s9  t  j d j |    | o d  S| o
 t j p t j } t j   } | d k o y | |  d |   WnU t k
 oI } z3 t j	 j
 d |  d | j f  t j d  WYd  d  } ~ Xn Xt j	 j
 d |  d  t j d  nKxGy t j | d  \ } } Wnn t k
 ob } zL d d  l }	 | j |	 j k o wî n t d |  d | j d f   WYd  d  } ~ Xn Xt j |  o' t d |  d t j |  f   qî t j |  o? t j |  }
 |
 d k o d  St d	 |  d |
 f   qî t j |  o qî qî t d
 |  d | f   qî d  S(   Nu    i    u   unable to execute %s: %s
i   u(   unable to execute %s for unknown reasonsu   command '%s' failed: %si˙˙˙˙u$   command '%s' terminated by signal %du'   command '%s' failed with exit status %du3   unknown error executing '%s': termination status %d(   u   logu   infou   joinu   osu   execvpu   execvu   forku   OSErroru   sysu   stderru   writeu   strerroru   _exitu   waitpidu   errnou   EINTRu   DistutilsExecErroru   argsu   WIFSIGNALEDu   WTERMSIGu	   WIFEXITEDu   WEXITSTATUSu
   WIFSTOPPED(   u   cmdu   search_pathu   verboseu   dry_runu   exec_fnu   pidu   eu   statusu   excu   errnou   exit_status(    (    u,   /mit/python/lib/python3.0/distutils/spawn.pyu   _spawn_posixc   sN    !2!c             C   sá   | d k o t j d } n | j t j  } t j j |   \ } } t j d k p t j	 d k o | d k o |  d }  n t j j
 |   pC x; | D]3 } t j j | |   } t j j
 |  o | Sq Wd S|  Sd S(   uÜ   Try to find 'executable' in the directories listed in 'path' (a
    string listing directories separated by 'os.pathsep'; defaults to
    os.environ['PATH']).  Returns the complete filename or None if not
    found.
    u   PATHu   win32u   os2u   .exeN(   u   Noneu   osu   environu   splitu   pathsepu   pathu   splitextu   sysu   platformu   nameu   isfileu   join(   u
   executableu   pathu   pathsu   baseu   extu   pu   f(    (    u,   /mit/python/lib/python3.0/distutils/spawn.pyu   find_executable   s    - 	(   u   __doc__u   __revision__u   sysu   osu   distutils.errorsu	   distutilsu   logu   spawnu   _nt_quote_argsu	   _spawn_ntu
   _spawn_os2u   _spawn_posixu   Noneu   find_executable(    (    (    u,   /mit/python/lib/python3.0/distutils/spawn.pyu   <module>   s   
	1