
    'wf              
          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j0                  j                   j2                  ej4                  j6                  ef
Z e edd	            d
dgz   Z e eeD  cg c]
  }  e!|        c} z         Zd Z"ddZ#e
dd       Z$yc c} w )    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.c                    || _         |r|j                  dd       | _        |j                  dd      | _        | j                  r|t	        | j                  t
              r1| xj                  d| j                  z  j                         z  c_        n1| xj                  d| j                  z  z  c_        nd| _        d | _        t        | !  | j                         y )Ncodemessage z, %s)	_error_responsegetr   r	   
isinstancebytesencodesuper__init__)selferror_response	__class__s     _/home/panchajanya/Development/work/volatility3/venv/lib/python3.12/site-packages/gcsfs/retry.pyr   zHttpError.__init__   s    -&**648DI)--i<DLyydllE2LLVdii%7$?$?$AALLLFTYY$66L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      s    7'"2r   r   c                       e Zd ZdZy)ChecksumErrorzBRaised when the md5 hash of the content does not match the header.N)r   r   r   r    r   r   r    r    )   s    Lr   r    i  i  i  i  c                 f    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   s+     )Y'~~%%i!566r   c                 Z   | dk\  r| dk7  r|r)ddl m}  |j                  |D cg c]
  } ||       c} }| dk(  rt        |      d}t	        |d      r|j                         }	 t        j                  |      d   }|d	   }| d
k(  rt        d| d|       | dk(  rt        j                  j                         dt        |      v rt        d| d|       |rt!        |      | rt!        | |d      t#        |      yyc c}w # t        j                  j                  $ r |}Y w xY w)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     )quote  Ndecodeerrorr	   i  zForbidden: 
i  invalidzBad Request: )r   r	   )corer*   formatFileNotFoundErrorhasattrr,   jsonloadsdecoderJSONDecodeErrorOSErrorrequests
exceptions
ProxyErrorstr
ValueErrorr   RuntimeError)statuscontentpathargsr*   pr-   msgs           r   validate_responserE   O   s>    }3#4;;4 8aq 89DS=#D))7H%nn&G	JJw'0E	"C S=KvRu566s]%%0022#c("}TF"SE:;;E""V<==s##; '}
 !9 ||++ 	C	s   D%D D*)D*c           	      H  K   t        |      D ][  }	 |dkD  rBt        j                  t        t	        j                         d|dz
  z  z   d             d {     | |i | d {   c S  y 7 7 
# t
        t        j                  j                  t        j                  j                  j                  t        t        j                  j                  f$ rI}t!        |t
              r+|j"                  dk(  rd|j$                  v rd}t'        |      |t!        |t        j                  j(                        r&|j*                  dk(  rt,        j/                  d	       |t!        |t
              r&|j"                  dk(  rt,        j/                  d	       |||dz
  k(  r&t,        j1                  | j2                   d
|        |t5        |      r*t,        j/                  | j2                   d|        Y d }~t,        j1                  | j2                   d|        |d }~ww xY ww)Nr      r)       r(   zrequester payszTBucket is requester pays. Set `requester_pays=True` when creating the GCSFileSystem.r+   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   r9   r:   RequestExceptiongoogleauthGoogleAuthErrorr    aiohttpclient_exceptionsClientErrorr   r   r	   r=   ClientResponseErrorr?   loggerdebugr%   r   r&   )funcretriesrB   kwargsretryerD   s          r   retry_requestr]   x   s    w '&	qymmC!	:J(JB$OPPPt.v...	' Q.00KK""22%%11
 "	 1i(FFcM$		1Q  !o1, 1g77KKLHHO@A!Y'AFFcM@A!#  DMM?2PQRPS!TUA.I!MN.HLMGE"	s[   H"AA1A-A1$A/%A1(H"-A1/A11A%HDH.H"4&HHH"r   )   )%rJ   r4   loggingrM   aiohttp.client_exceptionsrR   google.auth.exceptionsrO   requests.exceptionsr9   r   	getLoggerrV   	Exceptionr   r    r:   ChunkedEncodingErrorConnectionErrorReadTimeoutTimeoutr;   SSLErrorContentDecodingErrorrP   RefreshErrorrS   rT   r$   listrI   r#   setr<   r&   rE   r]   )r\   s   0r   <module>rn      sF           			7	#2	 26	I 	 ,,''##""  ,,
KK''))  E#sO	   44(a3q6(()7&$R ( (m )s   0E
