From f1fc1d7a16d2d35f172bd615873ad910ae4e47dc Mon Sep 17 00:00:00 2001 From: Igor Ch Date: Sat, 28 Feb 2015 23:26:20 +0200 Subject: [PATCH] Move several steps closer to python3 compatibility Signed-off-by: Igor Ch --- compose/cli/command.py | 2 +- compose/cli/log_printer.py | 2 +- compose/container.py | 1 + compose/project.py | 1 + compose/service.py | 4 ++-- requirements.txt | 2 +- tests/integration/service_test.py | 6 +++--- 7 files changed, 10 insertions(+), 8 deletions(-) diff --git a/compose/cli/command.py b/compose/cli/command.py index 67b77f31b..c26f3bc38 100644 --- a/compose/cli/command.py +++ b/compose/cli/command.py @@ -25,7 +25,7 @@ class Command(DocoptCommand): def dispatch(self, *args, **kwargs): try: super(Command, self).dispatch(*args, **kwargs) - except SSLError, e: + except SSLError as e: raise errors.UserError('SSL error: %s' % e) except ConnectionError: if call_silently(['which', 'docker']) != 0: diff --git a/compose/cli/log_printer.py b/compose/cli/log_printer.py index 77fa49ae3..ce7e10653 100644 --- a/compose/cli/log_printer.py +++ b/compose/cli/log_printer.py @@ -46,7 +46,7 @@ class LogPrinter(object): if monochrome: color_fn = no_color else: - color_fn = color_fns.next() + color_fn = next(color_fns) generators.append(self._make_log_generator(container, color_fn)) return generators diff --git a/compose/container.py b/compose/container.py index 692145988..1d044a421 100644 --- a/compose/container.py +++ b/compose/container.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals from __future__ import absolute_import import six +from functools import reduce class Container(object): diff --git a/compose/project.py b/compose/project.py index 601604474..f2fa6a7ee 100644 --- a/compose/project.py +++ b/compose/project.py @@ -2,6 +2,7 @@ from __future__ import unicode_literals from __future__ import absolute_import import logging +from functools import reduce from .service import Service from .container import Container from docker.errors import APIError diff --git a/compose/service.py b/compose/service.py index eb6e86fb5..a21b78b76 100644 --- a/compose/service.py +++ b/compose/service.py @@ -482,7 +482,7 @@ class Service(object): try: all_events = stream_output(build_output, sys.stdout) - except StreamOutputError, e: + except StreamOutputError as e: raise BuildError(self, unicode(e)) image_id = None @@ -641,7 +641,7 @@ def merge_environment(options): else: env.update(options['environment']) - return dict(resolve_env(k, v) for k, v in env.iteritems()) + return dict(resolve_env(k, v) for k, v in env.items()) def split_env(env): diff --git a/requirements.txt b/requirements.txt index a31a19ae9..80b494562 100644 --- a/requirements.txt +++ b/requirements.txt @@ -4,5 +4,5 @@ dockerpty==0.3.2 docopt==0.6.1 requests==2.2.1 six==1.7.3 -texttable==0.8.1 +texttable==0.8.2 websocket-client==0.11.0 diff --git a/tests/integration/service_test.py b/tests/integration/service_test.py index 5904eb4ea..7b95b870f 100644 --- a/tests/integration/service_test.py +++ b/tests/integration/service_test.py @@ -472,13 +472,13 @@ class ServiceTest(DockerClientTestCase): def test_split_env(self): service = self.create_service('web', environment=['NORMAL=F1', 'CONTAINS_EQUALS=F=2', 'TRAILING_EQUALS=']) env = create_and_start_container(service).environment - for k,v in {'NORMAL': 'F1', 'CONTAINS_EQUALS': 'F=2', 'TRAILING_EQUALS': ''}.iteritems(): + for k,v in {'NORMAL': 'F1', 'CONTAINS_EQUALS': 'F=2', 'TRAILING_EQUALS': ''}.items(): self.assertEqual(env[k], v) def test_env_from_file_combined_with_env(self): service = self.create_service('web', environment=['ONE=1', 'TWO=2', 'THREE=3'], env_file=['tests/fixtures/env/one.env', 'tests/fixtures/env/two.env']) env = create_and_start_container(service).environment - for k,v in {'ONE': '1', 'TWO': '2', 'THREE': '3', 'FOO': 'baz', 'DOO': 'dah'}.iteritems(): + for k,v in {'ONE': '1', 'TWO': '2', 'THREE': '3', 'FOO': 'baz', 'DOO': 'dah'}.items(): self.assertEqual(env[k], v) def test_resolve_env(self): @@ -488,7 +488,7 @@ class ServiceTest(DockerClientTestCase): os.environ['ENV_DEF'] = 'E3' try: env = create_and_start_container(service).environment - for k,v in {'FILE_DEF': 'F1', 'FILE_DEF_EMPTY': '', 'ENV_DEF': 'E3', 'NO_DEF': ''}.iteritems(): + for k,v in {'FILE_DEF': 'F1', 'FILE_DEF_EMPTY': '', 'ENV_DEF': 'E3', 'NO_DEF': ''}.items(): self.assertEqual(env[k], v) finally: del os.environ['FILE_DEF']