ó
ĉNXc           @  s"  d  Z  d d l m Z d d l Z d d l Z e j d k rb d d l m Z m Z m	 Z	 m
 Z
 nV e j d k r d d l m Z m Z m	 Z	 m
 Z
 n" d d l m Z m Z m	 Z	 m
 Z
 d d l m Z m Z m Z d d	 l m Z d
 e f d     YZ d   Z d   Z d   Z d   Z d S(   s0   
Utilities for working with external processes.
i˙˙˙˙(   t   print_functionNt   win32i   (   t   systemt	   getoutputt	   arg_splitt	   check_pidt   cli(   t   getoutputerrort   get_output_error_codet   process_handler(   t	   py3compatt   FindCmdErrorc           B  s   e  Z RS(    (   t   __name__t
   __module__(    (    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/process.pyR      s   c         C  s2   t  j |   } | d k r. t d |    n  | S(   s  Find absolute path to executable cmd in a cross platform manner.

    This function tries to determine the full path to a command line program
    using `which` on Unix/Linux/OS X and `win32api` on Windows.  Most of the
    time it will use the version that is first on the users `PATH`.

    Warning, don't use this to find IPython command line programs as there
    is a risk you will find the wrong one.  Instead find those using the
    following code and looking for the application itself::

        from IPython.utils.path import get_ipython_module_path
        from IPython.utils.process import pycmd2argv
        argv = pycmd2argv(get_ipython_module_path('IPython.terminal.ipapp'))

    Parameters
    ----------
    cmd : str
        The command line program to look for.
    s   command could not be found: %sN(   R
   t   whicht   NoneR   (   t   cmdt   path(    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/process.pyt   find_cmd   s    c         C  s+   y t  |   t SWn t k
 r& t SXd S(   s?   Check whether executable `cmd` exists or not and return a bool.N(   R   t   TrueR   t   False(   R   (    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/process.pyt   is_cmd_found7   s
    
c         C  s:   t  j j |   d } | d k r) |  g St j |  g Sd S(   sö  Take the path of a python command and return a list (argv-style).

    This only works on Python based command line programs and will find the
    location of the ``python`` executable using ``sys.executable`` to make
    sure the right version is used.

    For a given path ``cmd``, this returns [cmd] if cmd's extension is .exe,
    .com or .bat, and [, cmd] otherwise.

    Parameters
    ----------
    cmd : string
      The path of the command.

    Returns
    -------
    argv-style list.
    i   s   .exes   .coms   .batN(   s   .exes   .coms   .bat(   t   osR   t   splitextt   syst
   executable(   R   t   ext(    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/process.pyt
   pycmd2argv@   s    c          C  sµ   t  j   j d d  }  d } |  } t j d k rd t |   d k  rI |  St j j |   \ } } n  | j	 d  } t |  d k r d j
 | d  } n  | |  d k r° d p³ | S(   s1    Return abbreviated version of cwd, e.g. d:mydir s   \t   /t    R   i   i   iŝ˙˙˙(   R
   t   getcwdt   replaceR   t   platformt   lenR   R   t
   splitdrivet   splitt   join(   t   cwdt	   drivepartt   tailt   parts(    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/process.pyt
   abbrev_cwdZ   s    (   t   __doc__t
   __future__R    R   R   R    t   _process_win32R   R   R   R   t   _process_clit   _process_posixt   _process_commonR   R   R	   R   R
   t	   ExceptionR   R   R   R   R)   (    (    (    sM   /data/av2000/mvv/env_mvv/lib/python2.7/site-packages/IPython/utils/process.pyt   <module>   s   %%"				