o
    ~îja  ã                   @  sì   d Z ddlmZ ddlmZmZ ddlmZ ddlm	Z	 ddl
mZmZ er<ddlmZ ddlmZmZmZ dd	lmZ G d
d„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZG dd„ deƒZdS )zNetwork-related pip exceptions.é    )Úannotations)ÚTYPE_CHECKINGÚLiteral)Úescape)ÚText)ÚDiagnosticPipErrorÚPipError)Úurllib3)ÚPreparedRequestÚRequestÚResponse)Ú_FileDownloadc                      s2   e Zd ZdZ		dd‡ fdd„Zddd„Z‡  ZS )ÚNetworkConnectionErrorzHTTP connection errorNÚ	error_msgÚstrÚresponseúResponse | NoneÚrequestú Request | PreparedRequest | NoneÚreturnÚNonec                   sJ   || _ || _|| _| j dur| jst|dƒr| j j| _tƒ  |||¡ dS )zc
        Initialize NetworkConnectionError with  `request` and `response`
        objects.
        Nr   )r   r   r   ÚhasattrÚsuperÚ__init__)Úselfr   r   r   ©Ú	__class__© új/raid/bulk_storage/M2HATS/real-image-venv/lib/python3.10/site-packages/pip/_internal/exceptions/network.pyr      s   

ÿþ
zNetworkConnectionError.__init__c                 C  s
   t | jƒS )N)r   r   )r   r   r   r   Ú__str__+   s   
zNetworkConnectionError.__str__)NN)r   r   r   r   r   r   r   r   )r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r   Ú__classcell__r   r   r   r   r      s    ür   c                      ó"   e Zd ZdZd‡ fd	d
„Z‡  ZS )ÚConnectionFailedErrorzconnection-failedÚurlr   ÚhostÚerrorÚ	Exceptionr   r   c                   s   ddl m} ddlm}m}m} t|ƒ}t||ƒr-|jddd�}	t	|	ƒdkr,d|	d  }n6t||ƒrD|jd	dd�}	t	|	ƒdkrC|	\}
}nt||ƒrcz|j
d }W n	 tyY   Y n
w t||tfƒrcd
}tƒ jdt|ƒ› dt|ƒ› �t|ƒdt|ƒ› d�d� d S )Nr   )ÚRemoteDisconnected)ÚNameResolutionErrorÚNewConnectionErrorÚProtocolErrorzFailed to resolve é   )Úmaxsplité   z!Failed to resolve IP address for z&Failed to establish a new connection: z:the connection was closed without a reply from the server.zFailed to connect to [magenta]ú[/] while fetching z\Are you connected to the Internet? If so, check whether your system can connect to [magenta]z[[/] before trying again. There may be a firewall or proxy that's preventing the connection.©ÚmessageÚcontextÚ	hint_stmt)Úhttp.clientr+   Úpip._vendor.urllib3.exceptionsr,   r-   r.   r   Ú
isinstanceÚsplitÚlenÚargsÚ
IndexErrorÚConnectionResetErrorr   r   r   r   )r   r'   r(   r)   r+   r,   r-   r.   ÚdetailsÚpartsÚ_Úreasonr   r   r   r   2   s>   
€
€
ÿÿÿÿ
ùzConnectionFailedError.__init__)r'   r   r(   r   r)   r*   r   r   ©r    r!   r"   Ú	referencer   r$   r   r   r   r   r&   /   ó    r&   c                      s"   e Zd ZdZd‡ fdd„Z‡  ZS )ÚConnectionTimeoutErrorzconnection-timeoutr'   r   r(   ÚkindúLiteral['connect', 'read']ÚtimeoutÚfloatr   r   c                  sJ   t  |dfd|› d�¡}|dkr| d¡ tƒ jdt|ƒ› �|dd� d S )	NÚmagentaz didn't respond within z secondsÚconnectz" (while establishing a connection)zUnable to fetch zÐThis is probably a temporary issue with the remote server or the network connection. If this error persists, check the network configuration. There may be a firewall or proxy that's preventing the connection.r3   )r   ÚassembleÚappendr   r   r   )r   r'   r(   rG   rI   r5   r   r   r   r   `   s   ÿ

üzConnectionTimeoutError.__init__)
r'   r   r(   r   rG   rH   rI   rJ   r   r   rC   r   r   r   r   rF   ]   rE   rF   c                      s"   e Zd ZdZd‡ fdd„Z‡  ZS )	ÚSSLMissingErrorzssl-missingr'   r   r   r   c                   s    t ƒ jdt|ƒ› �dd d� d S )Nz,Failed to establish a secure connection for z;The 'ssl' module is unavailable but required for HTTPS URLsr3   )r   r   r   )r   r'   r   r   r   r   |   s
   
ýzSSLMissingError.__init__)r'   r   r   r   rC   r   r   r   r   rO   y   rE   rO   c                      r%   )ÚSSLVerificationErrorzssl-verification-failedr'   r   r(   r)   úurllib3.exceptions.SSLErrorr   r   c                   s:   dt |ƒ› dt |ƒ› �}d}tƒ j|tt|ƒƒ|d� d S )Nz4Failed to establish a secure connection to [magenta]r2   zEYou may need to use --cert or check your proxy/firewall configurationr3   )r   r   r   r   r   )r   r'   r(   r)   r4   Úhintr   r   r   r   ‡   s   ÿÿÿzSSLVerificationError.__init__)r'   r   r(   r   r)   rQ   r   r   rC   r   r   r   r   rP   „   rE   rP   c                      r%   )ÚProxyConnectionErrorzproxy-connection-failedr'   r   Úproxyr)   úurllib3.exceptions.ProxyErrorr   r   c                   s2   t ƒ jdt|ƒ› dt|ƒ› �tt|ƒƒdd� d S )Nz$Failed to connect to proxy [magenta]r2   z+This is likely a proxy configuration issue.r3   )r   r   r   r   r   )r   r'   rT   r)   r   r   r   r   “   s   ÿÿ

úzProxyConnectionError.__init__)r'   r   rT   r   r)   rU   r   r   rC   r   r   r   r   rS   �   rE   rS   c                      s&   e Zd ZdZdZd	‡ fdd„Z‡  ZS )
ÚIncompleteDownloadErrorzaRaised when the downloader receives fewer bytes than advertised
    in the Content-Length header.zincomplete-downloadÚdownloadr   r   r   c                   s’   ddl m} |jd usJ ‚||jƒ› d||jƒ› �}|jr)d|jd › d�}d}nd}d	}td
|› d|› d�ƒ}tƒ j|d|jj	› �|dd� d S )Nr   )Úformat_sizeú/zafter r/   z
 attempts z7Use --resume-retries to configure resume attempt limit.Ú z>Consider using --resume-retries to enable download resumption.zDownload failed z(because not enough bytes were received (ú)zURL: z4This is an issue with network connectivity, not pip.)r4   r5   r6   Ú	note_stmt)
Úpip._internal.utils.miscrX   ÚsizeÚbytes_receivedÚ
reattemptsr   r   r   ÚlinkÚredacted_url)r   rW   rX   Údownload_statusÚretry_statusrR   r4   r   r   r   r   ¦   s(   ÿÿÿ
üz IncompleteDownloadError.__init__)rW   r   r   r   )r    r!   r"   r#   rD   r   r$   r   r   r   r   rV       s    rV   N)r#   Ú
__future__r   Útypingr   r   Úpip._vendor.rich.markupr   Úpip._vendor.rich.textr   Úpip._internal.exceptions._baser   r   Úpip._vendorr	   Úpip._vendor.requests.modelsr
   r   r   Úpip._internal.network.downloadr   r   r&   rF   rO   rP   rS   rV   r   r   r   r   Ú<module>   s"    .