a
    /§»a  ã                	   @   sv   d dl Z d dlZd dlZd dlmZmZ dd„ ZG dd„ dejjƒZee_zde_	de_
W n eefyp   Y n0 dS )	é    N)ÚPopenÚPIPEc                 C   s¢   t j| ddt jt jd�}| ¡ \}}tjd dk r‚zt ¡ }W n ty\   tjj	pVd}Y n0 t
||jj	pl|ƒ}t
||jj	p~|ƒ}| ¡ }|ržt||| ||ƒ‚|S )a€   return unicode output of executing 'cmd' in a separate process.

    raise cmdexec.Error exeception if the command failed.
    the exception will provide an 'err' attribute containing
    the error-output from the command.
    if the subprocess module does not provide a proper encoding/unicode strings
    sys.getdefaultencoding() will be used, if that does not exist, 'UTF-8'.
    T)ÚshellÚuniversal_newlinesÚstdoutÚstderrr   é   zUTF-8)Ú
subprocessr   r   ÚcommunicateÚsysÚversion_infoÚgetdefaultencodingÚAttributeErrorr   ÚencodingÚunicoder   ÚpollÚExecutionFailed)ÚcmdÚprocessÚoutÚerrÚdefault_encodingÚstatus© r   úM/home/yuhw/wc/pochoir/venv/lib/python3.9/site-packages/py/_process/cmdexec.pyÚcmdexec   s     	þr   c                   @   s   e Zd Zdd„ Zdd„ ZdS )r   c                 C   s,   t  | ¡ || _|| _|| _|| _|| _d S )N)Ú	ExceptionÚ__init__r   Úsystemstatusr   r   r   )Úselfr   r   r   r   r   r   r   r   r       s    
zExecutionFailed.__init__c                 C   s   d| j | j| jf S )NzExecutionFailed: %d  %s
%s)r   r   r   )r   r   r   r   Ú__str__(   s    zExecutionFailed.__str__N)Ú__name__Ú
__module__Ú__qualname__r   r    r   r   r   r   r      s   r   zpy.process.cmdexecÚError)r   r	   Úpyr   r   r   Úerrorr$   r   r"   r!   r   Ú	TypeErrorr   r   r   r   Ú<module>   s   
