Commit 9e0b7110 authored by Jenkins's avatar Jenkins Committed by Gerrit Code Review

Merge "Fix unicode issues with Python 3"

parents 6f28fbf5 b25f60ff
......@@ -28,6 +28,7 @@ from cliff import commandmanager
from keystoneclient import client as keystone_client
from keystoneclient import exceptions as keystone_exceptions
from oslo_utils import encodeutils
import six
from blazarclient import client as blazar_client
from blazarclient import exception
......@@ -321,10 +322,10 @@ class BlazarShell(app.App):
except Exception as err:
if self.options.debug:
self.log.exception(unicode(err))
self.log.exception(six.text_type(err))
raise
else:
self.log.error(unicode(err))
self.log.error(six.text_type(err))
return 1
if self.interactive_mode:
_argv = [sys.argv[0]]
......@@ -347,16 +348,17 @@ class BlazarShell(app.App):
return run_command(cmd, cmd_parser, sub_argv)
except Exception as err:
if self.options.debug:
self.log.exception(unicode(err))
self.log.exception(six.text_type(err))
else:
self.log.error(unicode(err))
self.log.error(six.text_type(err))
try:
self.clean_up(cmd, result, err)
except Exception as err2:
if self.options.debug:
self.log.exception(unicode(err2))
self.log.exception(six.text_type(err2))
else:
self.log.error('Could not clean up: %s', unicode(err2))
self.log.error('Could not clean up: %s',
six.text_type(err2))
if self.options.debug:
raise
else:
......@@ -364,9 +366,10 @@ class BlazarShell(app.App):
self.clean_up(cmd, result, None)
except Exception as err3:
if self.options.debug:
self.log.exception(unicode(err3))
self.log.exception(six.text_type(err3))
else:
self.log.error('Could not clean up: %s', unicode(err3))
self.log.error('Could not clean up: %s',
six.text_type(err3))
return result
def authenticate_user(self):
......@@ -446,7 +449,7 @@ class BlazarShell(app.App):
def clean_up(self, cmd, result, err):
self.log.debug('clean_up %s', cmd.__class__.__name__)
if err:
self.log.debug('got an error: %s', unicode(err))
self.log.debug('got an error: %s', six.text_type(err))
def configure_logging(self):
"""Create logging handlers for any log output."""
......@@ -480,7 +483,7 @@ def main(argv=sys.argv[1:]):
except exception.BlazarClientException:
return 1
except Exception as e:
print(unicode(e))
print(six.text_type(e))
return 1
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment