Checks that docker is installed

The current error when docker is missing is not very helpful:

 ERROR: Operation failed, aborting dox.

The debug one doesn't help more, this change start 'docker version'
command earlier to have a clear error message.

Change-Id: I1e6ac247b0a619915600f604d5f316d5f053e8c1
This commit is contained in:
Mehdi Abaakouk 2014-09-08 07:04:33 +02:00 committed by Mehdi Abaakouk
parent 00458699fb
commit 7c08b582de
2 changed files with 15 additions and 0 deletions

View File

@ -15,6 +15,7 @@
import argparse
import logging
import sys
import dox.commands
import dox.config.cmdline
@ -75,6 +76,8 @@ def main():
def run_dox(args):
if not dox.runner.Runner(args).is_docker_installed():
sys.exit(1)
# Get Image
image = args.image

View File

@ -37,6 +37,18 @@ class Runner(object):
self.base_image_name = 'dox_%s_base' % self.project
self.test_image_name = 'dox_%s_test' % self.project
def is_docker_installed(self):
try:
self._docker_cmd("version")
except OSError as e:
msg = 'docker does not seem installed'
if e.errno == 2 and not self.args.debug:
logger.error(msg)
else:
logger.exception(msg)
return False
return True
def _docker_build(self, image, image_dir='.'):
logger.info('Building image %s' % image)
self._docker_cmd('build', '-t', image, image_dir)