o
    Wi                     @  s`   d dl mZ d dlZd dlmZ d dlmZ erd dlmZ dZ	G dd dZ
dddZdZdS )    )annotationsN)quote)TYPE_CHECKING)Mappingl        c                   @  s"   e Zd Zdddd	ZdddZdS )LogCmdNcmd	list[str]envMapping[str, str] | NonereturnNonec                 C  s   || _ || _d S N)r   r	   )selfr   r	    r   W/home/ubuntu/.local/lib/python3.10/site-packages/virtualenv/util/subprocess/__init__.py__init__   s   
zLogCmd.__init__strc                 C  s4   d dd | jD }| jd ur| d| j}|S )N c                 s  s    | ]	}t t|V  qd S r   )r   r   ).0cr   r   r   	<genexpr>   s    z"LogCmd.__repr__.<locals>.<genexpr>z env of )joinr   r	   )r   cmd_reprr   r   r   __repr__   s   
zLogCmd.__repr__r   )r   r   r	   r
   r   r   )r   r   )__name__
__module____qualname__r   r   r   r   r   r   r      s    r   r   r   r   tuple[int, str, str]c              
   C  s   zt j| dt jt jt jdd}| \}}|j}W n, tyE } z |jd|j}}}|dkr;|d ur;d|v r;t|}W Y d }~nd }~ww |||fS )NTzutf-8)universal_newlinesstdinstderrstdoutencoding    file)	
subprocessPopenPIPEcommunicate
returncodeOSErrorerrnostrerrorr   )r   processouterrcodeerrorr   r   r   run_cmd   s$   

r3   )CREATE_NO_WINDOWr   r3   )r   r   r   r   )
__future__r   r&   shlexr   typingr   collections.abcr   r4   r   r3   __all__r   r   r   r   <module>   s    
