From 1079c0fa4c00ff0bc304c2e79a94bbf3a8a46146 Mon Sep 17 00:00:00 2001 From: Steve Noyes Date: Fri, 11 Sep 2015 11:11:46 -0400 Subject: [PATCH] Summary: drop use of str() on exception messages Description: - Oracle-Bug: 21810245 - drop use of strings on exception messages. When messages are in > 128 unicode, str() will throw an exception. --- kollacli/ansible/inventory.py | 9 +++++---- kollacli/sshutils.py | 4 ++-- kollacli/utils.py | 3 +-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/kollacli/ansible/inventory.py b/kollacli/ansible/inventory.py index 0c3b345..44f3daf 100644 --- a/kollacli/ansible/inventory.py +++ b/kollacli/ansible/inventory.py @@ -125,14 +125,14 @@ class Host(object): except Exception as e: raise exceptions.CommandError( 'ERROR: Host (%s) setup failed : %s' - % (self.name, str(e))) + % (self.name, e)) return True def check(self): kollacli_home = get_kollacli_home() command_string = 'sudo -u kolla ansible ' inventory_string = '-i ' + os.path.join(kollacli_home, - 'tools', 'json_generator.py') + 'tools', 'json_generator.py') ping_string = ' %s %s' % (self.name, '-m ping') cmd = (command_string + inventory_string + ping_string) @@ -140,11 +140,12 @@ class Host(object): if err_flag: raise exceptions.CommandError( 'ERROR: Host (%s) check failed : %s' - % (self.name, str(output))) + % (self.name, output)) else: self.log.info('Host (%s) check succeeded' % self.name) return True + class HostGroup(object): class_version = 1 @@ -292,7 +293,7 @@ class Inventory(object): shutil.copyfile(tmp_path, inventory_path) os.remove(tmp_path) except Exception as e: - raise Exception('ERROR: saving inventory : %s' % str(e)) + raise Exception('ERROR: saving inventory : %s' % e) finally: try: os.close(tmp_filehandle) diff --git a/kollacli/sshutils.py b/kollacli/sshutils.py index 0e9132d..fed760c 100644 --- a/kollacli/sshutils.py +++ b/kollacli/sshutils.py @@ -100,14 +100,14 @@ def _post_setup_checks(net_addr, log): ssh_client = ssh_connect(net_addr, get_admin_user(), '') except Exception as e: - raise CommandError("ERROR: remote login failed : %s" % str(e)) + raise CommandError("ERROR: remote login failed : %s" % e) try: # a basic test ssh_client.exec_command('ls') except Exception as e: - raise CommandError("ERROR: remote command 'ls' failed : %s" % str(e)) + raise CommandError("ERROR: remote command 'ls' failed : %s" % e) finally: _close_ssh_client(ssh_client) diff --git a/kollacli/utils.py b/kollacli/utils.py index b040d21..a8d404d 100644 --- a/kollacli/utils.py +++ b/kollacli/utils.py @@ -13,9 +13,8 @@ # under the License. import logging import os -import yaml import pexpect -import string +import yaml def get_kolla_home():