o
    Uh                     @   s4   d Z ddlZddlZG dd dZG dd dZdS )a  Paramiko SSH support for Dulwich.

To use this implementation as the SSH implementation in Dulwich, override
the dulwich.client.get_ssh_vendor attribute:

  >>> from dulwich import client as _mod_client
  >>> from dulwich.contrib.paramiko_vendor import ParamikoSSHVendor
  >>> _mod_client.get_ssh_vendor = ParamikoSSHVendor

This implementation is experimental and does not have any tests.
    Nc                   @   sF   e Zd ZdddZedd Zdd Zd	d
 ZdddZdddZ	dS )_ParamikoWrapperreturnNc                 C   s   || _ || _| jd d S )NT)clientchannelsetblocking)selfr   r    r   s/var/www/html/construction_image-detection-poc/venv/lib/python3.10/site-packages/dulwich/contrib/paramiko_vendor.py__init__'   s   z_ParamikoWrapper.__init__c                 C   s   | j dS )Nrb)r   makefile_stderrr   r   r   r	   stderr.   s   z_ParamikoWrapper.stderrc                 C   s
   | j  S N)r   
recv_readyr   r   r   r	   can_read2      
z_ParamikoWrapper.can_readc                 C   s   | j |S r   )r   sendall)r   datar   r   r	   write5   s   z_ParamikoWrapper.writec                 C   sB   | j |}t|}|sdS |r||k r|| }|| | S |S )N    )r   recvlenread)r   nr   data_lendiff_lenr   r   r	   r   8   s   z_ParamikoWrapper.readc                 C   s   | j   d S r   )r   closer   r   r   r	   r   F   s   z_ParamikoWrapper.closer   Nr   )
__name__
__module____qualname__r
   propertyr   r   r   r   r   r   r   r   r	   r   &   s    


r   c                   @   s,   e Zd ZdddZ						dddZdS )	ParamikoSSHVendorr   Nc                 K   s
   || _ d S r   )kwargs)r   r$   r   r   r	   r
   M   r   zParamikoSSHVendor.__init__c	                 K   s   t  }
d|i}|| j |r||d< |r||d< |r ||d< |r&||d< |r,||d< ||	 t j }|
| |
jdi | |
 	 }|d u sQ|dkrX|j
dd	d
 || t|
|S )Nhostnameusernameportpasswordpkeykey_filename   GIT_PROTOCOLz	version=2)namevaluer   )paramiko	SSHClientupdater$   r   MissingHostKeyPolicyset_missing_host_key_policyconnectget_transportopen_sessionset_environment_variableexec_commandr   )r   hostcommandr&   r'   r(   r)   r*   protocol_versionr$   r   connection_kwargspolicyr   r   r   r	   run_commandP   s,   




zParamikoSSHVendor.run_commandr   )NNNNNN)r   r    r!   r
   r>   r   r   r   r	   r#   J   s    
r#   )__doc__r/   paramiko.clientr   r#   r   r   r   r	   <module>   s
   $