ó
NRc           @@ s˝   d  Z  d d l m Z d d l m Z d d l Z d d d d g Z e e d  rq e j Z e j Z e j	 Z	 n d	   Z d
 Z d Z	 d   Z
 e e d  rŞ e j Z n e
 Z e j Z d S(   sÜ  
A replacement wrapper around the subprocess module, with a number of
work-arounds:
- Provides the check_output function (which subprocess only provides from Python
  2.7 onwards).
- Provides a stub implementation of subprocess members on Google App Engine
  (which are missing in subprocess).

Instead of importing subprocess, other modules should use this as follows:

from matplotlib.compat import subprocess

This module is safe to import from anywhere within matplotlib.
i    (   t   absolute_import(   t   print_functionNt   Popent   PIPEt   STDOUTt   check_outputc          O@ s   t  d   d  S(   Ns!   subprocess.Popen is not supported(   t   OSError(   t   argst   kwargs(    (    sV   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/compat/subprocess.pyR       s    i˙˙˙˙iţ˙˙˙c          O@ s   d | k r t  d   n  t d t |  |  } | j   \ } } | j   } | r | j d  } | d k r| |  d } n  t j | | d |  n  | S(   s  Run command with arguments and return its output as a byte
    string.

    If the exit code was non-zero it raises a CalledProcessError.  The
    CalledProcessError object will have the return code in the
    returncode
    attribute and output in the output attribute.

    The arguments are the same as for the Popen constructor.  Example::

    >>> check_output(["ls", "-l", "/dev/null"])
    'crw-rw-rw- 1 root root 1, 3 Oct 18  2007 /dev/null\n'

    The stdout argument is not allowed as it is used internally.
    To capture standard error in the result, use stderr=STDOUT.::

    >>> check_output(["/bin/sh", "-c",
    ...               "ls -l non_existent_file ; exit 0"],
    ...              stderr=STDOUT)
    'ls: non_existent_file: No such file or directory\n'
    t   stdouts3   stdout argument not allowed, it will be overridden.R   i    t   outputN(	   t
   ValueErrorR   R   t   communicatet   pollt   gett   Nonet
   subprocesst   CalledProcessError(   t	   popenargsR   t   processR
   t
   unused_errt   retcodet   cmd(    (    sV   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/compat/subprocess.pyt   _check_output&   s    (   t   __doc__t
   __future__R    R   R   t   __all__t   hasattrR   R   R   R   R   R   (    (    (    sV   /opt/xtal/ccp4-6.5-linux32/lib/python2.7/site-packages/matplotlib/compat/subprocess.pyt   <module>   s    				$