From 01d6a8114fc52e8d7c581d54feb35363f1b1f017 Mon Sep 17 00:00:00 2001 From: Artem Tiumentcev Date: Thu, 24 Nov 2016 19:11:39 +0300 Subject: [PATCH] Fixed issues on Python 3 Change-Id: Ib41255ba8b2ddbe9b05c8503a90e5271ed74a7d6 --- muranoagent/common/messaging/message.py | 2 ++ muranoagent/execution_plan_runner.py | 2 +- muranoagent/executors/application/__init__.py | 6 ++++-- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/muranoagent/common/messaging/message.py b/muranoagent/common/messaging/message.py index 131479b5..22dd0653 100644 --- a/muranoagent/common/messaging/message.py +++ b/muranoagent/common/messaging/message.py @@ -33,6 +33,8 @@ class Message(object): try: if message_handle: + if isinstance(message_handle.body, bytes): + message_handle.body = message_handle.body.decode('utf-8') self.body = anyjson.loads(message_handle.body) else: self.body = None diff --git a/muranoagent/execution_plan_runner.py b/muranoagent/execution_plan_runner.py index d4aefc75..bd14b333 100644 --- a/muranoagent/execution_plan_runner.py +++ b/muranoagent/execution_plan_runner.py @@ -43,7 +43,7 @@ class ExecutionPlanRunner(object): @staticmethod def _unindent(script, initial_indent): lines = script.expandtabs(4).split('\n') - min_indent = sys.maxint + min_indent = six.MAXSIZE for line in lines: indent = -1 for i, c in enumerate(line): diff --git a/muranoagent/executors/application/__init__.py b/muranoagent/executors/application/__init__.py index 0c5af791..bfd570fd 100644 --- a/muranoagent/executors/application/__init__.py +++ b/muranoagent/executors/application/__init__.py @@ -70,11 +70,13 @@ class ApplicationExecutor(object): LOG.debug("Script {0} execution finished " "with retcode: {1}".format(script_name, retcode)) if stdout is not None: - stdout = stdout.decode('utf-8') + if hasattr(stdout, 'decode'): + stdout = stdout.decode('utf-8') LOG.debug(u"'{0}' execution stdout: " u"'{1}'".format(script_name, stdout)) if stderr is not None: - stderr = stderr.decode('utf-8') + if hasattr(stderr, 'decode'): + stderr = stderr.decode('utf-8') LOG.debug(u"'{0}' execution stderr: " u"'{1}'".format(script_name, stderr)) result = {