
    S`B                     r   d dl Z d dlZd dlZd dlmZ d dlmZ d dlmZ d dl	m
Z d dl	mZ d dl	mZ d dlmZ d	d
lmZ ddlmZ ddlmZ ddlmZ ddlmZ ddlmZ  ej0                  e      Z G d de      Z G d de      Z
e j:                  d        Zd Zd Z d Z!d Z"d Z#d Z$d Z%dZ&dZ'dZ(d Z)d!Z*d"Z+d#Z,y)$    N)find_executable)dedent)APIError)ConnectionError)ReadTimeout)SSLError)ReadTimeoutError   )API_VERSION_TO_ENGINE_VERSION   )binarystr_to_unicode)is_docker_for_mac_installed)is_mac)	is_ubuntu)
is_windowsc                       e Zd Zd Zd Zy)	UserErrorc                 @    t        |      j                         | _        y N)r   stripmsg)selfr   s     4/usr/lib/python3/dist-packages/compose/cli/errors.py__init__zUserError.__init__   s    #;$$&    c                     | j                   S r   r   )r   s    r   __str__zUserError.__str__   s    xxr   N)__name__
__module____qualname__r   r    r   r   r   r      s    'r   r   c                       e Zd Zy)r   N)r   r    r!   r"   r   r   r   r   !   s    r   r   c              #     K   	 d  y # t         $ r'}t        j                  d|z         t               d }~wt        $ rp}|j
                  r<t        |j
                  d   t              rt        | j                         t               t        t        | j                               Y d }~y d }~wt        $ r%}t        || j                         t               d }~wt         t"        j                  f$ r  t        | j                         t               t$        $ r?}t'               r/dd l}t        ||j                        rt+        |       t                d }~ww xY ww)NzSSL error: %sr   )r   logerrorr   RequestsConnectionErrorargs
isinstancer	   log_timeout_errortimeoutexit_with_errorget_conn_error_messagebase_urlr   log_api_errorapi_versionr   socket	Exceptionr   
pywintypeslog_windows_pipe_error)clienter3   s      r   handle_connection_errorsr7   %   s      		/A%&" A66j,<=fnn-!##.v?@@  a++,(  &..) <!Z--.&q)%''sN   E	 E	E"4E A&B+&E+E7 CAE:EEEc                    | j                   dk(  rt        j                  d       y | j                   dk(  rt        j                  d       y t        j                  dj                  t	        | j
                        | j                                y )Nr
   zNCouldn't connect to Docker daemon. You might need to start Docker for Windows.   zThe current Compose file version is not compatible with your engine version. Please upgrade your Compose file to a more recent version, or set a COMPOSE_API_VERSION in your environment.z'Windows named pipe error: {} (code: {}))winerrorr%   r&   formatr   strerror)excs    r   r4   r4   @   sf    
||q		bc				9	
 			5<<$S\\2CLL	
r   c                 4    t         j                  d| z         y )NzAn HTTP request took too long to complete. Retry with --verbose to obtain debug information.
If you encounter this issue regularly because of slow network conditions, consider setting COMPOSE_HTTP_TIMEOUT to a higher value (current value: %s).)r%   r&   )r+   s    r   r*   r*   Q   s    II	% (/		/0r   c                    t        | j                        }d|vrt        j                  |       y t	        j
                  |      }|st        j                  |       y t        j                  dj                  |             y )Nzclient is newer than serverzThe Docker Engine version is less than the minimum required by Compose. Your current project requires a Docker Engine of version {version} or greater.)version)r   explanationr%   r&   r   getr;   )r6   client_versionrA   r@   s       r   r/   r/   Z   sf    &q}}5K$K7		++//?G		+II	((.w(?r   c                 n    t         j                  t        |       j                                t	               r   )r%   r&   r   r   r   r   s    r   r,   r,   n   s$    IIfSk!"

r   c                     	 t        d      t        d      S t               rt        S t        d      t        S 	 t        j                  |       S # t
        $ r Y !w xY w)Ndockerz"Couldn't connect to Docker daemon.zdocker-machineurl)r   docker_not_found_msgr   conn_error_docker_for_macconn_error_docker_machineUnicodeDecodeErrorconn_error_genericr;   rG   s    r   r-   r-   s   sm    
8$,'(LMM&(,,+,8,, 9 $$$--	   	s   A A A 	AAc                 6    dj                  | t                     S )Nz({} You might need to install Docker:

{})r;   docker_install_url)problems    r   rI   rI      s    7>>#%' 'r   c                  n    t               rt        S t               rt        S t	               rt
        S t        S r   )r   docker_install_url_macr   docker_install_url_ubuntur   docker_install_url_windowsdocker_install_url_genericr"   r   r   rO   rO      s)    x%%	((	))))r   z0https://docs.docker.com/engine/installation/mac/z8https://docs.docker.com/engine/installation/ubuntulinux/z4https://docs.docker.com/engine/installation/windows/z,https://docs.docker.com/engine/installation/z_
    Couldn't connect to Docker daemon - you might need to run `docker-machine start default`.
zP
    Couldn't connect to Docker daemon. You might need to start Docker for Mac.
z
    Couldn't connect to Docker daemon at {url} - is it running?

    If it's at a non-standard location, specify the URL with the DOCKER_HOST environment variable.
)-
contextlibloggingr1   distutils.spawnr   textwrapr   docker.errorsr   requests.exceptionsr   r'   r   r   $requests.packages.urllib3.exceptionsr	   constr   utilsr   r   r   r   r   	getLoggerr   r%   r2   r   contextmanagerr7   r4   r*   r/   r,   r-   rI   rO   rR   rS   rT   rU   rK   rJ   rM   r"   r   r   <module>ra      s       +  " J + ( A 1 ' .    g!	 	i 	  4
"0(
.'
* L V S K   
 r   