diff --git a/mistral/db/v2/sqlalchemy/models.py b/mistral/db/v2/sqlalchemy/models.py index 5ec07aa9..500c28e6 100644 --- a/mistral/db/v2/sqlalchemy/models.py +++ b/mistral/db/v2/sqlalchemy/models.py @@ -282,7 +282,8 @@ def _get_hash_function_by(column_name): def calc_hash(context): d = context.current_parameters[column_name] or {} - return hashlib.sha256(json.dumps(sorted(d.items()))).hexdigest() + return hashlib.sha256(json.dumps(sorted(d.items())). + encode('utf-8')).hexdigest() return calc_hash diff --git a/mistral/engine/utils.py b/mistral/engine/utils.py index b8c3a228..aa0d1722 100644 --- a/mistral/engine/utils.py +++ b/mistral/engine/utils.py @@ -26,7 +26,7 @@ LOG = logging.getLogger(__name__) def validate_input(definition, input, spec=None): - input_param_names = copy.copy((input or {}).keys()) + input_param_names = copy.copy(list((input or {}).keys())) missing_param_names = [] spec_input = (spec.get_input() if spec else diff --git a/mistral/tests/base.py b/mistral/tests/base.py index cabecaaf..dc4411d8 100644 --- a/mistral/tests/base.py +++ b/mistral/tests/base.py @@ -125,9 +125,11 @@ class BaseTest(base.BaseTestCase): return True - filtered_items = filter(lambda item: _matches(item, **props), items) + filtered_items = list( + filter(lambda item: _matches(item, **props), items) + ) - found = len(list(filtered_items)) + found = len(filtered_items) if found != count: LOG.info("[failed test ctx] items=%s, expected_props=%s" % (str( diff --git a/mistral/workbook/base.py b/mistral/workbook/base.py index 470fce80..4eff8d40 100644 --- a/mistral/workbook/base.py +++ b/mistral/workbook/base.py @@ -263,7 +263,7 @@ class BaseSpec(object): @staticmethod def _as_tuple(val): - return val.items()[0] if isinstance(val, dict) else (val, '') + return list(val.items())[0] if isinstance(val, dict) else (val, '') @staticmethod def _parse_cmd_and_input(cmd_str): diff --git a/mistral/workbook/v2/workflows.py b/mistral/workbook/v2/workflows.py index ed98daea..88d4cde5 100644 --- a/mistral/workbook/v2/workflows.py +++ b/mistral/workbook/v2/workflows.py @@ -13,6 +13,8 @@ # See the License for the specific language governing permissions and # limitations under the License. +import six + from mistral import exceptions as exc from mistral import utils from mistral.workbook import types @@ -60,7 +62,7 @@ class WorkflowSpec(base.BaseSpec): # Inject 'type' here, so instantiate_spec function can recognize the # specific subclass of TaskSpec. - for task in self._data.get('tasks').itervalues(): + for task in six.itervalues(self._data.get('tasks')): task['type'] = self._type self._tasks = self._spec_property('tasks', tasks.TaskSpecList) diff --git a/mistral/workflow/data_flow.py b/mistral/workflow/data_flow.py index a0084a2d..8f6c6551 100644 --- a/mistral/workflow/data_flow.py +++ b/mistral/workflow/data_flow.py @@ -14,6 +14,7 @@ # limitations under the License. import copy +import six from oslo_config import cfg from oslo_log import log as logging @@ -135,7 +136,7 @@ class ProxyAwareDict(dict): return d def iteritems(self): - for k, _ in super(ProxyAwareDict, self).iteritems(): + for k, _ in six.iteritems(super(ProxyAwareDict, self)): yield k, self[k] def to_builtin_dict(self): @@ -263,7 +264,7 @@ def add_workflow_variables_to_context(wf_ex, wf_spec): def extract_task_result_proxies_to_context(ctx): ctx = ProxyAwareDict(copy.deepcopy(ctx)) - for task_ex_id, task_ex_name in ctx['__tasks'].iteritems(): + for task_ex_id, task_ex_name in six.iteritems(ctx['__tasks']): ctx[task_ex_name] = TaskResultProxy(task_ex_id) return ctx