diff --git a/contrib/rackspace/rackspace/resources/cloud_loadbalancer.py b/contrib/rackspace/rackspace/resources/cloud_loadbalancer.py index a94846bfcf..60f5db12df 100644 --- a/contrib/rackspace/rackspace/resources/cloud_loadbalancer.py +++ b/contrib/rackspace/rackspace/resources/cloud_loadbalancer.py @@ -939,7 +939,7 @@ class CloudLoadBalancer(resource.Resource): def _public_ip(self, lb): for ip in lb.virtual_ips: if ip.type == 'PUBLIC': - return unicode(ip.address) + return six.text_type(ip.address) def _resolve_attribute(self, key): if self.resource_id: diff --git a/contrib/rackspace/rackspace/resources/cloudnetworks.py b/contrib/rackspace/rackspace/resources/cloudnetworks.py index 3869d9392d..30dd6aa837 100644 --- a/contrib/rackspace/rackspace/resources/cloudnetworks.py +++ b/contrib/rackspace/rackspace/resources/cloudnetworks.py @@ -22,6 +22,7 @@ from heat.engine import constraints from heat.engine import properties from heat.engine import resource from heat.engine import support +import six try: from pyrax.exceptions import NetworkInUse # noqa @@ -161,7 +162,7 @@ class CloudNetwork(resource.Resource): def _resolve_attribute(self, name): net = self.network() if net: - return unicode(getattr(net, name)) + return six.text_type(getattr(net, name)) return "" diff --git a/heat/common/exception.py b/heat/common/exception.py index ec565a7bb8..6a374b7a84 100644 --- a/heat/common/exception.py +++ b/heat/common/exception.py @@ -21,6 +21,7 @@ import sys from oslo_log import log as logging import six from six.moves.urllib import parse as urlparse +from six import reraise as raise_ from heat.common.i18n import _ from heat.common.i18n import _LE @@ -86,7 +87,7 @@ def wrap_exception(notifier=None, publisher_id=None, event_type=None, payload) # re-raise original exception since it may have been clobbered - raise exc_info[0], exc_info[1], exc_info[2] + raise_(exc_info[0], exc_info[1], exc_info[2]) return six.wraps(f)(wrapped) return inner @@ -116,13 +117,13 @@ class HeatException(Exception): LOG.error("%s: %s" % (name, value)) # noqa if _FATAL_EXCEPTION_FORMAT_ERRORS: - raise exc_info[0], exc_info[1], exc_info[2] + raise_(exc_info[0], exc_info[1], exc_info[2]) def __str__(self): - return unicode(self.message).encode('UTF-8') + return six.text_type(self.message).encode('UTF-8') def __unicode__(self): - return unicode(self.message) + return six.text_type(self.message) def __deepcopy__(self, memo): return self.__class__(**self.kwargs) diff --git a/heat/db/sqlalchemy/api.py b/heat/db/sqlalchemy/api.py index ad72a40a87..c1d6cea04f 100644 --- a/heat/db/sqlalchemy/api.py +++ b/heat/db/sqlalchemy/api.py @@ -245,7 +245,7 @@ def _decrypt(enc_value, method): decryptor = getattr(crypt, method) value = decryptor(enc_value) if value is not None: - return unicode(value, 'utf-8') + return six.text_type(value, 'utf-8') def resource_data_get_by_key(context, resource_id, key): diff --git a/heat/engine/cfn/functions.py b/heat/engine/cfn/functions.py index 95bf8c5060..205f937910 100644 --- a/heat/engine/cfn/functions.py +++ b/heat/engine/cfn/functions.py @@ -447,7 +447,7 @@ class Replace(function.Function): raise TypeError(_('"%s" params must be strings or numbers') % self.fn_name) - return string.replace(placeholder, unicode(value)) + return string.replace(placeholder, six.text_type(value)) return reduce(replace, six.iteritems(mapping), template) diff --git a/heat/engine/function.py b/heat/engine/function.py index d721bedf00..2ceaf95e2a 100644 --- a/heat/engine/function.py +++ b/heat/engine/function.py @@ -153,7 +153,7 @@ def dependencies(snippet, path=''): elif isinstance(snippet, collections.Mapping): def mkpath(key): - return '.'.join([path, unicode(key)]) + return '.'.join([path, six.text_type(key)]) deps = (dependencies(value, mkpath(key)) for key, value in snippet.items()) diff --git a/heat/engine/scheduler.py b/heat/engine/scheduler.py index a4a95b1d67..0a221461a2 100644 --- a/heat/engine/scheduler.py +++ b/heat/engine/scheduler.py @@ -22,6 +22,7 @@ from oslo_log import log as logging from oslo_utils import encodeutils from oslo_utils import excutils import six +from six import reraise as raise_ from heat.common.i18n import _ from heat.common.i18n import _LI @@ -118,8 +119,8 @@ class ExceptionGroup(Exception): self.exceptions = list(exceptions) def __str__(self): - return unicode([unicode(ex).encode('utf-8') - for ex in self.exceptions]).encode('utf-8') + return six.text_type([six.text_type(ex).encode('utf-8') + for ex in self.exceptions]).encode('utf-8') def __unicode__(self): return six.text_type(map(six.text_type, self.exceptions)) @@ -397,7 +398,7 @@ class DependencyTaskGroup(object): raise ExceptionGroup(v for t, v, tb in raised_exceptions) else: exc_type, exc_val, traceback = raised_exceptions[0] - raise exc_type, exc_val, traceback + raise_(exc_type, exc_val, traceback) def cancel_all(self, grace_period=None): for r in six.itervalues(self._runners):