From e4df67e265fa023eed99d4609d45821196255851 Mon Sep 17 00:00:00 2001 From: ricolin Date: Wed, 12 Apr 2017 14:51:10 +0800 Subject: [PATCH] Fix undefined basestring and unicode in py35 In py3 basestring and unicode are no longer valid, and should use `str` instead. In order to cover py2 and py3, we change to use six lib to cover both. Closes-Bug: #1682015 Change-Id: I3159470965e3a20161ff0e997af625b45ebe21fa --- .../heat-config-docker-cmd/install.d/hook-docker-cmd.py | 3 ++- .../install.d/hook-docker-compose.py | 3 ++- .../heat-config/os-refresh-config/configure.d/55-heat-config | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/hot/software-config/elements/heat-config-docker-cmd/install.d/hook-docker-cmd.py b/hot/software-config/elements/heat-config-docker-cmd/install.d/hook-docker-cmd.py index ae028875..8e9e89fd 100755 --- a/hot/software-config/elements/heat-config-docker-cmd/install.d/hook-docker-cmd.py +++ b/hot/software-config/elements/heat-config-docker-cmd/install.d/hook-docker-cmd.py @@ -15,6 +15,7 @@ import json import logging import os +import six import subprocess import sys import yaml @@ -99,7 +100,7 @@ def main(argv=sys.argv): if key in ['environment', 'volumes', 'volumes_from']: for value in config[container][key]: # Somehow the lists get empty values sometimes - if type(value) is unicode and not value.strip(): + if type(value) is six.text_type and not value.strip(): continue cmd.append(docker_arg_map(key, value)) elif key == 'image': diff --git a/hot/software-config/elements/heat-config-docker-compose/install.d/hook-docker-compose.py b/hot/software-config/elements/heat-config-docker-compose/install.d/hook-docker-compose.py index 41219efb..0ccd51a4 100755 --- a/hot/software-config/elements/heat-config-docker-compose/install.d/hook-docker-compose.py +++ b/hot/software-config/elements/heat-config-docker-compose/install.d/hook-docker-compose.py @@ -17,6 +17,7 @@ import dpath import json import logging import os +import six import subprocess import sys import yaml @@ -87,7 +88,7 @@ def main(argv=sys.argv): for value in dpath.util.values(config, '*/env_file'): if isinstance(value, list): compose_env_files.extend(value) - elif isinstance(value, basestring): + elif isinstance(value, six.string_types): compose_env_files.extend([value]) input_env_files = {} diff --git a/hot/software-config/elements/heat-config/os-refresh-config/configure.d/55-heat-config b/hot/software-config/elements/heat-config/os-refresh-config/configure.d/55-heat-config index 9cc0df15..cbb36ae1 100755 --- a/hot/software-config/elements/heat-config/os-refresh-config/configure.d/55-heat-config +++ b/hot/software-config/elements/heat-config/os-refresh-config/configure.d/55-heat-config @@ -21,6 +21,7 @@ import subprocess import sys import requests +import six HOOKS_DIR_PATHS = ( os.environ.get('HEAT_CONFIG_HOOKS'), @@ -93,7 +94,7 @@ def invoke_hook(c, log): hot_inputs = c.get('inputs', []) for hot_input in hot_inputs: if hot_input.get('type', None) == 'String' and \ - not isinstance(hot_input['value'], basestring): + not isinstance(hot_input['value'], six.text_type): hot_input['value'] = str(hot_input['value']) iv = dict((i['name'], i['value']) for i in c['inputs']) # The group property indicates whether it is softwarecomponent or