mirror of
https://github.com/docker/compose.git
synced 2025-07-21 04:34:38 +02:00
Refactor "docker not found" message generation, add Windows message
Signed-off-by: Aanand Prasad <aanand.prasad@gmail.com>
This commit is contained in:
parent
e4bb9bde30
commit
8b383ad795
@ -17,6 +17,7 @@ from .utils import call_silently
|
|||||||
from .utils import is_docker_for_mac_installed
|
from .utils import is_docker_for_mac_installed
|
||||||
from .utils import is_mac
|
from .utils import is_mac
|
||||||
from .utils import is_ubuntu
|
from .utils import is_ubuntu
|
||||||
|
from .utils import is_windows
|
||||||
|
|
||||||
|
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
@ -90,11 +91,7 @@ def exit_with_error(msg):
|
|||||||
|
|
||||||
def get_conn_error_message(url):
|
def get_conn_error_message(url):
|
||||||
if call_silently(['which', 'docker']) != 0:
|
if call_silently(['which', 'docker']) != 0:
|
||||||
if is_mac():
|
return docker_not_found_msg("Couldn't connect to Docker daemon.")
|
||||||
return docker_not_found_mac
|
|
||||||
if is_ubuntu():
|
|
||||||
return docker_not_found_ubuntu
|
|
||||||
return docker_not_found_generic
|
|
||||||
if is_docker_for_mac_installed():
|
if is_docker_for_mac_installed():
|
||||||
return conn_error_docker_for_mac
|
return conn_error_docker_for_mac
|
||||||
if call_silently(['which', 'docker-machine']) == 0:
|
if call_silently(['which', 'docker-machine']) == 0:
|
||||||
@ -102,25 +99,26 @@ def get_conn_error_message(url):
|
|||||||
return conn_error_generic.format(url=url)
|
return conn_error_generic.format(url=url)
|
||||||
|
|
||||||
|
|
||||||
docker_not_found_mac = """
|
def docker_not_found_msg(problem):
|
||||||
Couldn't connect to Docker daemon. You might need to install Docker:
|
return "{} You might need to install Docker:\n\n{}".format(
|
||||||
|
problem, docker_install_url())
|
||||||
https://docs.docker.com/engine/installation/mac/
|
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
docker_not_found_ubuntu = """
|
def docker_install_url():
|
||||||
Couldn't connect to Docker daemon. You might need to install Docker:
|
if is_mac():
|
||||||
|
return docker_install_url_mac
|
||||||
https://docs.docker.com/engine/installation/ubuntulinux/
|
elif is_ubuntu():
|
||||||
"""
|
return docker_install_url_ubuntu
|
||||||
|
elif is_windows():
|
||||||
|
return docker_install_url_windows
|
||||||
|
else:
|
||||||
|
return docker_install_url_generic
|
||||||
|
|
||||||
|
|
||||||
docker_not_found_generic = """
|
docker_install_url_mac = "https://docs.docker.com/engine/installation/mac/"
|
||||||
Couldn't connect to Docker daemon. You might need to install Docker:
|
docker_install_url_ubuntu = "https://docs.docker.com/engine/installation/ubuntulinux/"
|
||||||
|
docker_install_url_windows = "https://docs.docker.com/engine/installation/windows/"
|
||||||
https://docs.docker.com/engine/installation/
|
docker_install_url_generic = "https://docs.docker.com/engine/installation/"
|
||||||
"""
|
|
||||||
|
|
||||||
|
|
||||||
conn_error_docker_machine = """
|
conn_error_docker_machine = """
|
||||||
|
@ -11,6 +11,7 @@ import sys
|
|||||||
import docker
|
import docker
|
||||||
|
|
||||||
import compose
|
import compose
|
||||||
|
from ..const import IS_WINDOWS_PLATFORM
|
||||||
|
|
||||||
# WindowsError is not defined on non-win32 platforms. Avoid runtime errors by
|
# WindowsError is not defined on non-win32 platforms. Avoid runtime errors by
|
||||||
# defining it as OSError (its parent class) if missing.
|
# defining it as OSError (its parent class) if missing.
|
||||||
@ -73,6 +74,10 @@ def is_ubuntu():
|
|||||||
return platform.system() == 'Linux' and platform.linux_distribution()[0] == 'Ubuntu'
|
return platform.system() == 'Linux' and platform.linux_distribution()[0] == 'Ubuntu'
|
||||||
|
|
||||||
|
|
||||||
|
def is_windows():
|
||||||
|
return IS_WINDOWS_PLATFORM
|
||||||
|
|
||||||
|
|
||||||
def get_version_info(scope):
|
def get_version_info(scope):
|
||||||
versioninfo = 'docker-compose version {}, build {}'.format(
|
versioninfo = 'docker-compose version {}, build {}'.format(
|
||||||
compose.__version__,
|
compose.__version__,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user