Skip to content

Commit

Permalink
Fix for iteritems() python 3 compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
dukloi-stratoscale authored and ravidbro committed Jul 27, 2017
1 parent 13797c7 commit 99cb4cf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 7 deletions.
7 changes: 4 additions & 3 deletions skipper/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import os.path
import tabulate
import click
import six
from pkg_resources import get_distribution
from skipper import git
from skipper import runner
Expand Down Expand Up @@ -46,7 +47,7 @@ def build(ctx, images_to_build, container_context):
utils.logger.debug("Executing build command")

valid_images = ctx.obj.get('containers') or utils.get_images_from_dockerfiles()
valid_images = {image: os.path.abspath(dockerfile) for image, dockerfile in valid_images.iteritems()}
valid_images = {image: os.path.abspath(dockerfile) for image, dockerfile in six.iteritems(valid_images)}
valid_images_to_build = {}
if not images_to_build:
valid_images_to_build = valid_images
Expand All @@ -58,7 +59,7 @@ def build(ctx, images_to_build, container_context):
valid_images_to_build[image] = valid_images[image]

tag = git.get_hash()
for image, dockerfile in valid_images_to_build.iteritems():
for image, dockerfile in six.iteritems(valid_images_to_build):
utils.logger.info('Building image: %(image)s', dict(image=image))

if not os.path.exists(dockerfile):
Expand Down Expand Up @@ -296,7 +297,7 @@ def _validate_project_image(image):

def _expend_env(ctx, extra_env):
environment = []
for key, value in ctx.obj['env'].iteritems():
for key, value in six.iteritems(ctx.obj['env']):
utils.logger.debug("Adding %s=%s to environment", key, value)
environment.append("{}={}".format(key, value))
return environment + list(extra_env)
3 changes: 2 additions & 1 deletion skipper/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from collections import defaultdict
import os
import yaml
import six


def load_defaults():
Expand All @@ -18,7 +19,7 @@ def load_defaults():


def _normalize_config(config, normalized_config):
for key, value in config.iteritems():
for key, value in six.iteritems(config):
if isinstance(value, dict):
normalized_config[key] = {}
_normalize_config(value, normalized_config[key])
Expand Down
7 changes: 4 additions & 3 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import httplib
import unittest
import click
import six
from click import testing
from skipper import cli
from skipper import config
Expand Down Expand Up @@ -130,7 +131,7 @@ def test_subcommand_without_global_params(self):
'make': ['-f', 'Makefile', 'all'],
}

for subcmd, subcmd_params in subcmd_params_map.iteritems():
for subcmd, subcmd_params in six.iteritems(subcmd_params_map):
result = self._invoke_cli(
global_params=None,
subcmd=subcmd,
Expand Down Expand Up @@ -861,7 +862,7 @@ def test_run_with_defaults_and_env_from_config_file(self, skipper_runner_run_moc
subcmd='run',
subcmd_params=run_params
)
env = ["%s=%s" % (key, value) for key, value in CONFIG_ENV_EVALUATION.iteritems()]
env = ["%s=%s" % (key, value) for key, value in six.iteritems(CONFIG_ENV_EVALUATION)]
expected_fqdn_image = 'skipper-conf-build-container-image:skipper-conf-build-container-tag'
skipper_runner_run_mock.assert_called_once_with(command, fqdn_image=expected_fqdn_image, environment=env,
interactive=False, name=None, net='host', volumes=None, workdir=None)
Expand All @@ -880,7 +881,7 @@ def test_run_with_env_overriding_config_file(self, skipper_runner_run_mock, *arg
subcmd='run',
subcmd_params=run_params
)
env = ["%s=%s" % (key, value) for key, value in CONFIG_ENV_EVALUATION.iteritems()] + ENV
env = ["%s=%s" % (key, value) for key, value in six.iteritems(CONFIG_ENV_EVALUATION)] + ENV
expected_fqdn_image = 'skipper-conf-build-container-image:skipper-conf-build-container-tag'
skipper_runner_run_mock.assert_called_once_with(command, fqdn_image=expected_fqdn_image, environment=env,
interactive=False, name=None, net='host', volumes=None, workdir=None)
Expand Down

0 comments on commit 99cb4cf

Please sign in to comment.