
    Bf              
          d dl Z d dlZd dlZd dlZd dlZd dlZd dlZ	d dl
m
Z
  ej        d          Z G d de          Z G d de          Ze	j        j        e	j        j        e	j        j        e	j        j        e	j        j        e	j        j        e	j        j        ej        j        j        ej        j        ef
Z e edd	                    d
dgz   Z e ed eD             z             Zd Z!ddZ"e
dd            Z#dS )    N)	decoratorgcsfsc                   *     e Zd ZdZd fd	Zd Z xZS )	HttpErrorz-Holds the message and code from cloud errors.Nc                    || _         |r|                    dd           | _        |                    dd          | _        | j        r]t	          | j        t
                    r+| xj        d| j        z                                  z  c_        n'| xj        d| j        z  z  c_        nd| _        d | _        t                                          | j                   d S )Ncodemessage z, %s)	_error_responsegetr   r	   
isinstancebytesencodesuper__init__)selferror_response	__class__s     Z/home/panchajanya/Development/work/volatility3/lib/python3.11/site-packages/gcsfs/retry.pyr   zHttpError.__init__   s    - 
	&**6488DI)--i<<DLy 7dlE22 7LLVdi%7$?$?$A$AALLLLLFTY$66LLDLDI&&&&&    c                      t           | j        ffS )z$This makes the Exception pickleable.)r   r   )r   s    r   
__reduce__zHttpError.__reduce__"   s     4/111r   N)__name__
__module____qualname____doc__r   r   __classcell__)r   s   @r   r   r      sR        77' ' ' ' ' '"2 2 2 2 2 2 2r   r   c                       e Zd ZdZdS )ChecksumErrorzBRaised when the md5 hash of the content does not match the header.N)r   r   r   r    r   r   r    r    )   s        LLDr   r    i  i  i  i  c                 ,    g | ]}t          |          S r!   )str).0es     r   
<listcomp>r&   C   s    (((a3q66(((r   c                 r    t          | t                    r| j        t          v S t          | t                    S )z,Returns True if this exception is retriable.)r   r   r   errsRETRIABLE_EXCEPTIONS)	exceptions    r   is_retriabler+   F   s4     )Y'' &~%%i!5666r   c                    | dk    r9| dk    r4|rddl m  |j        fd|D              }| dk    rt          |          d}t	          |d          r|                                }	 t          j        |          d	         }|d
         }n# t          j        j	        $ r |}Y nw xY w| dk    rt          d| d|           | dk    rt          j                                        dt          |          v rt          d| d|           |rt!          |          | rt!          | |d          t#          |          dS dS )z
    Check the requests object r, raise error if it's not ok.

    Parameters
    ----------
    r: requests response object
    path: associated URL path, for error messages
      i     )quotec                 &    g | ]} |          S r!   r!   )r$   pr/   s     r   r&   z%validate_response.<locals>.<listcomp>]   s!     8 8 8aq 8 8 8r     Ndecodeerrorr	   i  zForbidden: 
i  invalidzBad Request: )r   r	   )corer/   formatFileNotFoundErrorhasattrr3   jsonloadsdecoderJSONDecodeErrorOSErrorrequests
exceptions
ProxyErrorr#   
ValueErrorr   RuntimeError)statuscontentpathargsr4   msgr/   s         @r   validate_responserJ   O   s    }}3 	:######4; 8 8 8 84 8 8 89DS==#D)))7H%% 	'nn&&G	Jw''0E	"CC|+ 	 	 	CCC	 S==55555666s]]%00222#c(("":T::S::;;; 	$E""" 	$V<<===s###; }s   *"B B&%B&   c           	        K   t          |          D ]}	 |dk    rBt          j        t          t	          j                    d|dz
  z  z   d                     d {V   | |i | d {V c S # t
          t          j        j        t          j
        j        j        t          t          j        j        f$ rP}t!          |t
                    r&|j        dk    rd|j        v rd}t'          |          |t!          |t          j        j                  r'|j        dk    rt,                              d	           |t!          |t
                    r'|j        dk    rt,                              d	           |||dz
  k    r&t,                              | j         d
|            |t5          |          r*t,                              | j         d|            Y d }~t,                              | j         d|            |d }~ww xY wd S )Nr      r.       r-   zrequester payszTBucket is requester pays. Set `requester_pays=True` when creating the GCSFileSystem.r2   z!Request returned 404, no retries.z out of retries on exception: z retrying after exception: z non-retriable exception: )rangeasynciosleepminrandomr   r@   rA   RequestExceptiongoogleauthGoogleAuthErrorr    aiohttpclient_exceptionsClientErrorr   r   r	   rC   ClientResponseErrorrE   loggerdebugr*   r   r+   )funcretriesrH   kwargsretryr%   rI   s          r   retry_requestrb   x   s:     w ' '&	qyymC!	:J(JB$O$OPPPPPPPPPt.v...........0K"2%1
 "	 "	 "	 1i((	-FcMM$	11Q  !oo1, 1g7KLLHOO@AAA!Y'' AFcMM@AAA!##  DM!T!TQR!T!TUUUA MM!MMNNNLLLLMMMGE"	' 's    AA..AH5DH &H  Hr   )rK   )$rP   r;   loggingrS   aiohttp.client_exceptionsrX   google.auth.exceptionsrU   requests.exceptionsr@   r   	getLoggerr\   	Exceptionr   r    rA   ChunkedEncodingErrorConnectionErrorReadTimeoutTimeoutrB   SSLErrorContentDecodingErrorrV   RefreshErrorrY   rZ   r)   listrO   r(   setr+   rJ   rb   r!   r   r   <module>rr      s                            		7	#	#2 2 2 2 2	 2 2 26	 	 	 	 	I 	 	 	 ,'#" ,
K')  tEE#sOO	   s4((4(((())7 7 7&$ &$ &$ &$R ( ( ( ( ( (r   