Replace unicode with six.text_type to support python3.X

Python 3 doesn't support unicode(), use six.text_type instead.
Partial-Bug: #1284677

Change-Id: I2737c62e3bc1dc758033d488e6324ca7bfbc4881
This commit is contained in:
Fengqian Gao 2014-02-28 11:07:44 +08:00
parent 28c4dba09e
commit aa0e4ea3c7
2 changed files with 7 additions and 5 deletions

View File

@ -15,6 +15,7 @@ import pecan
import wsme
from pecan import rest
import six
from wsmeext import pecan as wsme_pecan
from tuskar.api.controllers.v1 import models
@ -94,7 +95,7 @@ def process_stack(attributes, counts, create=False):
try:
overcloud = template_tools.merge_templates(parse_counts(counts))
except Exception as e:
raise exception.HeatTemplateCreateFailed(unicode(e))
raise exception.HeatTemplateCreateFailed(six.text_type(e))
heat_client = HeatClient()
@ -102,7 +103,7 @@ def process_stack(attributes, counts, create=False):
try:
allowed_data = heat_client.validate_template(overcloud)
except Exception as e:
raise exception.HeatTemplateValidateFailed(unicode(e))
raise exception.HeatTemplateValidateFailed(six.text_type(e))
if stack_exists and create:
raise exception.StackAlreadyCreated()
@ -120,9 +121,9 @@ def process_stack(attributes, counts, create=False):
filter_template_attributes(allowed_data, attributes))
except Exception as e:
if create:
raise exception.HeatStackCreateFailed(unicode(e))
raise exception.HeatStackCreateFailed(six.text_type(e))
else:
raise exception.HeatStackUpdateFailed(unicode(e))
raise exception.HeatStackUpdateFailed(six.text_type(e))
class OvercloudsController(rest.RestController):

View File

@ -20,6 +20,7 @@ SHOULD include dedicated exception logging.
"""
from oslo.config import cfg
import six
from tuskar.openstack.common.gettextutils import _ # noqa
from tuskar.openstack.common import log as logging
@ -110,7 +111,7 @@ class TuskarException(Exception):
if self.__class__.__name__.endswith('_Remote'):
return self.args[0]
else:
return unicode(self)
return six.text_type(self)
class NotAuthorized(TuskarException):