
                            d dl Z  ed dD              Z G d de      Zd Z G d de j                  j                  e      Z G d	 d
e      Z	 G d de	      Z
 G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d dee      Z G d de      Z G d de      Z G d d e      Z G d! d"e      Zd# Z G d$ d%e      Z G d& d'e      Z G d( d)e      Z G d* d+e      Zy),    Nc              #   <   K   | ]  }|j                           y wN)lower).0fragments      lib/third_party/docker/errors.py	<genexpr>r	      s       3&HNN &s   )zno such imagez+not found: does not exist or no pull accesszrepository does not existz3was found but does not match the specified platformc                       e Zd ZdZy)DockerExceptionz
    A base class from which all other exceptions inherit.

    If you want to catch all errors that the Docker SDK might raise,
    catch this base exception.
    N)__name__
__module____qualname____doc__     r   r   r      s    r   r   c                 R   | j                   }	 |j                         d   }t
        }|j                  dk(  r9|xs dj                         t        fdt        D              rt        }nt        } || ||      | # t        $ r! |j                  xs dj	                         }Y w xY w)zH
    Create a suitable APIError from requests.exceptions.HTTPError.
    message i  c              3   &   K   | ]  }|v  
 y wr   r   )r   r   explanation_msgs     r   r	   z7create_api_error_from_http_exception.<locals>.<genexpr>"   s      GE8 ?*Es   )responseexplanation)r   json
ValueErrorcontentstripAPIErrorstatus_coder   any&_image_not_found_explanation_fragmentsImageNotFoundNotFound)er   r   clsr   s       @r   $create_api_error_from_http_exceptionr%      s     zzH7mmoi0 Cs"&,"335 GEG GCC
a(
<!C  7''-24467s   A< <'B&%B&c                   P     e Zd ZdZd fd	Z fdZed        Zd Zd Z	d Z
 xZS )	r   z%
    An HTTP error from the API.
    c                 @    t         |   |       || _        || _        y r   )super__init__r   r   )selfr   r   r   	__class__s       r   r)   zAPIError.__init__.   s!     	! &r   c                    t         |          }| j                         rPdj                  | j                  j
                  | j                  j                  | j                  j                        }n_| j                         rOdj                  | j                  j
                  | j                  j                  | j                  j                        }| j                  r| d| j                   d}|S )Nz{} Client Error for {}: {}z{} Server Error for {}: {}z ("z"))
r(   __str__is_client_errorformatr   r   urlreasonis_server_errorr   )r*   r   r+   s     r   r-   zAPIError.__str__5   s    '/#!299))4==+<+<$$&G !!#299))4==+<+<$$&G  	T%5%5$6b9Gr   c                 H    | j                   | j                   j                  S y r   )r   r   r*   s    r   r   zAPIError.status_codeG   s!    ==$==,,, %r   c                 F    | j                         xs | j                         S r   )r.   r2   r4   s    r   is_errorzAPIError.is_errorL   s    ##%?)=)=)??r   c                 P    | j                   yd| j                   cxk  xr dk  S c S )NFi    r   r4   s    r   r.   zAPIError.is_client_errorO   -    #d&&,,,,,r   c                 P    | j                   yd| j                   cxk  xr dk  S c S )NFr8   iX  r9   r4   s    r   r2   zAPIError.is_server_errorT   r:   r   )NN)r   r   r   r   r)   r-   propertyr   r6   r.   r2   __classcell__r+   s   @r   r   r   *   s6    '$ - -@-
-r   r   c                       e Zd Zy)r"   Nr   r   r   r   r   r   r"   r"   Z       r   r"   c                       e Zd Zy)r!   Nr@   r   r   r   r!   r!   ^   rA   r   r!   c                       e Zd Zy)InvalidVersionNr@   r   r   r   rD   rD   b   rA   r   rD   c                       e Zd Zy)InvalidRepositoryNr@   r   r   r   rF   rF   f   rA   r   rF   c                       e Zd Zy)InvalidConfigFileNr@   r   r   r   rH   rH   j   rA   r   rH   c                       e Zd Zy)InvalidArgumentNr@   r   r   r   rJ   rJ   n   rA   r   rJ   c                       e Zd Zy)DeprecatedMethodNr@   r   r   r   rL   rL   r   rA   r   rL   c                       e Zd Zd Zd Zy)TLSParameterErrorc                     || _         y r   msgr*   rQ   s     r   r)   zTLSParameterError.__init__w   	    r   c                      | j                   dz   S )Nz. TLS configurations should map the Docker CLI client configurations. See https://docs.docker.com/engine/articles/https/ for API details.rP   r4   s    r   r-   zTLSParameterError.__str__z   s    xx . / 	/r   Nr   r   r   r)   r-   r   r   r   rN   rN   v   s    /r   rN   c                       e Zd Zy)NullResourceNr@   r   r   r   rW   rW      rA   r   rW   c                   "     e Zd ZdZ fdZ xZS )ContainerErrorzK
    Represents a container that has exited with a non-zero exit code.
    c                     || _         || _        || _        || _        || _        |d| nd}dj                  ||||      }t        |   |       y )Nz: r   z=Command '{}' in image '{}' returned non-zero exit status {}{})	containerexit_statuscommandimagestderrr/   r(   r)   )	r*   r[   r\   r]   r^   r_   errrQ   r+   s	           r   r)   zContainerError.__init__   sb    "&
%16(mr$fWe[#F 	 	r   )r   r   r   r   r)   r=   r>   s   @r   rY   rY      s     r   rY   c                       e Zd Zd Zy)StreamParseErrorc                     || _         y r   rP   )r*   r1   s     r   r)   zStreamParseError.__init__   s	    r   N)r   r   r   r)   r   r   r   rb   rb      s    r   rb   c                        e Zd Z fdZ xZS )
BuildErrorc                 @    t         |   |       || _        || _        y r   )r(   r)   rQ   	build_log)r*   r1   rg   r+   s      r   r)   zBuildError.__init__   s     "r   )r   r   r   r)   r=   r>   s   @r   re   re      s    # #r   re   c                       e Zd Zy)ImageLoadErrorNr@   r   r   r   ri   ri      rA   r   ri   c                 &   t        |      D cg c]  }d| d
 }}|  dg}t        |      dk(  r|j                  d       n|j                  d       |j                  dj                  |             t	        dj                  |            S c c}w )N'z()    z#got an unexpected keyword argument z!got unexpected keyword arguments z, r   )sortedlenappendjoin	TypeError)namekwargskquoted_kwargstexts        r   create_unexpected_kwargs_errorrw      s    '-f~6~!q1X~M6fCL>D
=Q9:78KK		-()RWWT]## 7s   Bc                       e Zd Zd Zd Zy)MissingContextParameterc                     || _         y r   param)r*   r|   s     r   r)   z MissingContextParameter.__init__   s	    
r   c                      d| j                    S )Nzmissing parameter: r{   r4   s    r   r-   zMissingContextParameter.__str__   s    %djj\23r   NrU   r   r   r   ry   ry      s    4r   ry   c                       e Zd Zd Zd Zy)ContextAlreadyExistsc                     || _         y r   rr   r*   rr   s     r   r)   zContextAlreadyExists.__init__   	    	r   c                 "    d| j                    dS )Nzcontext z already existsr   r4   s    r   r-   zContextAlreadyExists.__str__   s    499+_56r   NrU   r   r   r   r   r      s    7r   r   c                       e Zd Zd Zd Zy)ContextExceptionc                     || _         y r   rP   rR   s     r   r)   zContextException.__init__   rS   r   c                     | j                   S r   rP   r4   s    r   r-   zContextException.__str__   s    r   NrU   r   r   r   r   r      s    r   r   c                       e Zd Zd Zd Zy)ContextNotFoundc                     || _         y r   r   r   s     r   r)   zContextNotFound.__init__   r   r   c                 "    d| j                    dS )Nz	context 'z' not foundr   r4   s    r   r-   zContextNotFound.__str__   s    DII;k23r   NrU   r   r   r   r   r      s    4r   r   )requests	frozensetr    	Exceptionr   r%   
exceptions	HTTPErrorr   r"   r!   rD   rF   rH   rJ   rL   rN   r   rW   rY   RuntimeErrorrb   re   ri   rw   ry   r   r   r   r   r   r   <module>r      s"   )2 3&3 * &i D(--x"",,o --`	x 		H 		_ 		 		 		o 		 	/ /	?J 	_ $| 
# #	_ 	$4o 47? 7 4o 4r   