diff options
author | Aanand Prasad <aanand.prasad@gmail.com> | 2016-10-24 16:15:21 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2016-10-24 16:15:21 -0700 |
commit | 8b5782ba9f1b5fc2b40a89bf141b1aab2cebd6e7 (patch) | |
tree | 8941fcdc350b9cf10af329393a4d1679ef78bbba /compose | |
parent | d5863288124866bf3cda8021196860b5b959e306 (diff) | |
parent | d2fb146913a1204b805ceb05e3d2b1b1a1006675 (diff) |
Merge pull request #4067 from shin-/portable-find-exe
Replace "which" calls with the portable find_executable function
Diffstat (limited to 'compose')
-rw-r--r-- | compose/cli/errors.py | 6 | ||||
-rw-r--r-- | compose/cli/main.py | 6 |
2 files changed, 6 insertions, 6 deletions
diff --git a/compose/cli/errors.py b/compose/cli/errors.py index 4fdec08a..5b977095 100644 --- a/compose/cli/errors.py +++ b/compose/cli/errors.py @@ -4,6 +4,7 @@ from __future__ import unicode_literals import contextlib import logging import socket +from distutils.spawn import find_executable from textwrap import dedent from docker.errors import APIError @@ -13,7 +14,6 @@ from requests.exceptions import SSLError from requests.packages.urllib3.exceptions import ReadTimeoutError from ..const import API_VERSION_TO_ENGINE_VERSION -from .utils import call_silently from .utils import is_docker_for_mac_installed from .utils import is_mac from .utils import is_ubuntu @@ -90,11 +90,11 @@ def exit_with_error(msg): def get_conn_error_message(url): - if call_silently(['which', 'docker']) != 0: + if find_executable('docker') is None: return docker_not_found_msg("Couldn't connect to Docker daemon.") if is_docker_for_mac_installed(): return conn_error_docker_for_mac - if call_silently(['which', 'docker-machine']) == 0: + if find_executable('docker-machine') is not None: return conn_error_docker_machine return conn_error_generic.format(url=url) diff --git a/compose/cli/main.py b/compose/cli/main.py index 58b95c2f..08e58e37 100644 --- a/compose/cli/main.py +++ b/compose/cli/main.py @@ -10,6 +10,7 @@ import pipes import re import subprocess import sys +from distutils.spawn import find_executable from inspect import getdoc from operator import attrgetter @@ -1063,9 +1064,8 @@ def exit_if(condition, message, exit_code): def call_docker(args): - try: - executable_path = subprocess.check_output(["which", "docker"]).strip() - except subprocess.CalledProcessError: + executable_path = find_executable('docker') + if not executable_path: raise UserError(errors.docker_not_found_msg("Couldn't find `docker` binary.")) args = [executable_path] + args |