Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

Commit

Permalink
Do not check for docker-py dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
vshlapakov committed Nov 23, 2016
1 parent f44a916 commit 08444e4
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 56 deletions.
47 changes: 15 additions & 32 deletions shub_image/tool.py
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
import click
import importlib
import shub_image
from shub_image.utils import missing_modules


def missingmod_cmd(modules):
modlist = ", ".join(modules)

@click.command(help="*DISABLED* - requires %s" % modlist)
@click.pass_context
def cmd(ctx):
click.echo("Error: '%s' command requires %s" %
(ctx.info_name, modlist))
ctx.exit(1)
return cmd


@click.group(help="Scrapinghub release tool")
Expand All @@ -22,22 +9,18 @@ def cli():
pass


module_deps = {
"init": [],
"build": ["docker"],
"list": ["docker"],
"test": ["docker"],
"push": ["docker"],
"deploy": ["docker"],
"upload": ["docker"],
"check": [],
}

for command, modules in module_deps.items():
m = missing_modules(*modules)
if m:
cli.add_command(missingmod_cmd(m), command)
else:
module_path = "shub_image." + command
command_module = importlib.import_module(module_path)
cli.add_command(command_module.cli, command)
module_deps = [
"init",
"build",
"list",
"test",
"push",
"deploy",
"upload",
"check",
]

for command in module_deps:
module_path = "shub_image." + command
command_module = importlib.import_module(module_path)
cli.add_command(command_module.cli, command)
15 changes: 0 additions & 15 deletions shub_image/utils.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import os
import re
import click
import importlib
import contextlib

import yaml
Expand Down Expand Up @@ -82,20 +81,6 @@ def load_release_config():
return shub_config.load_shub_config()


def missing_modules(*modules):
"""Receives a list of module names and returns those which are missing"""
missing = []
for module_name in modules:
try:
importlib.import_module(module_name)
except ImportError:
if module_name == 'docker':
missing.append('docker-py')
else:
missing.append(module_name)
return missing


def get_project_dir():
""" A helper to get project root dir.
Used by init/build command to locate Dockerfile.
Expand Down
8 changes: 0 additions & 8 deletions tests/test_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
import pytest
from shub import exceptions as shub_exceptions

from shub_image.utils import missing_modules
from shub_image.utils import get_project_dir
from shub_image.utils import get_docker_client
from shub_image.utils import format_image_name
Expand All @@ -27,13 +26,6 @@

class ReleaseUtilsTest(TestCase):

def test_missing_modules(self):
assert missing_modules() == []
assert missing_modules('os', 'non-existing-module') == \
['non-existing-module']
assert missing_modules('os', 'six', 'xxx11', 'xxx22') == \
['xxx11', 'xxx22']

def test_get_project_dir(self):
self.assertRaises(
shub_exceptions.BadConfigException, get_project_dir)
Expand Down
1 change: 0 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ deps =
flake8
pytest
pytest-cov
docker-py>=1.10.0
Scrapy==1.0.5
install_command=pip install --process-dependency-links {opts} {packages}
commands =
Expand Down

0 comments on commit 08444e4

Please sign in to comment.