diff --git a/trove/common/utils.py b/trove/common/utils.py index 2028b3165f..11c05c3984 100644 --- a/trove/common/utils.py +++ b/trove/common/utils.py @@ -210,7 +210,7 @@ class LoopingCall(object): if not self._running: break greenthread.sleep(interval) - except LoopingCallDone, e: + except LoopingCallDone as e: self.stop() done.send(e.retvalue) except Exception: diff --git a/trove/extensions/mgmt/instances/service.py b/trove/extensions/mgmt/instances/service.py index 16b26ed017..a21e189ed8 100644 --- a/trove/extensions/mgmt/instances/service.py +++ b/trove/extensions/mgmt/instances/service.py @@ -52,7 +52,7 @@ class MgmtInstanceController(InstanceController): deleted = False try: instances = models.load_mgmt_instances(context, deleted=deleted) - except nova_exceptions.ClientException, e: + except nova_exceptions.ClientException as e: LOG.error(e) return wsgi.Result(str(e), 403) @@ -139,7 +139,7 @@ class MgmtInstanceController(InstanceController): context = req.environ[wsgi.CONTEXT_KEY] try: server = instance_models.Instance.load(context=context, id=id) - except exception.TroveError, e: + except exception.TroveError as e: LOG.error(e) return wsgi.Result(str(e), 404) reh = mysql_models.RootHistory.load(context=context, instance_id=id) diff --git a/trove/extensions/security_group/models.py b/trove/extensions/security_group/models.py index ff59f12bf6..0c8c73c32d 100644 --- a/trove/extensions/security_group/models.py +++ b/trove/extensions/security_group/models.py @@ -64,7 +64,7 @@ class SecurityGroup(DatabaseModelBase): user=context.user, tenant_id=context.tenant) - except exception.SecurityGroupCreationError, e: + except exception.SecurityGroupCreationError as e: LOG.exception("Failed to create remote security group") raise e @@ -155,7 +155,7 @@ class SecurityGroupRule(DatabaseModelBase): cidr=cidr, group_id=sec_group['id']) - except exception.SecurityGroupRuleCreationError, e: + except exception.SecurityGroupRuleCreationError as e: LOG.exception("Failed to create remote security group") raise e @@ -203,9 +203,9 @@ class RemoteSecurityGroup(NovaRemoteModelBase): try: client = trove.common.remote.create_nova_client(context) self._data_object = client.security_groups.get(id) - except nova_exceptions.NotFound, e: + except nova_exceptions.NotFound as e: raise exception.NotFound(id=id) - except nova_exceptions.ClientException, e: + except nova_exceptions.ClientException as e: raise exception.TroveError(str(e)) else: self._data_object = security_group @@ -217,7 +217,7 @@ class RemoteSecurityGroup(NovaRemoteModelBase): try: sec_group = client.security_groups.create(name=name, description=description) - except nova_exceptions.ClientException, e: + except nova_exceptions.ClientException as e: LOG.exception('Failed to create remote security group') raise exception.SecurityGroupCreationError(str(e)) @@ -229,7 +229,7 @@ class RemoteSecurityGroup(NovaRemoteModelBase): try: client.security_groups.delete(sec_group_id) - except nova_exceptions.ClientException, e: + except nova_exceptions.ClientException as e: LOG.exception('Failed to delete remote security group') raise exception.SecurityGroupDeletionError(str(e)) @@ -248,7 +248,7 @@ class RemoteSecurityGroup(NovaRemoteModelBase): cidr=cidr) return sec_group_rule.id - except nova_exceptions.ClientException, e: + except nova_exceptions.ClientException as e: LOG.exception('Failed to add rule to remote security group') raise exception.SecurityGroupRuleCreationError(str(e)) @@ -259,6 +259,6 @@ class RemoteSecurityGroup(NovaRemoteModelBase): try: client.security_group_rules.delete(sec_group_rule_id) - except nova_exceptions.ClientException, e: + except nova_exceptions.ClientException as e: LOG.exception('Failed to delete rule to remote security group') raise exception.SecurityGroupRuleDeletionError(str(e)) diff --git a/trove/flavor/models.py b/trove/flavor/models.py index 79e3beeec1..4187f3ec74 100644 --- a/trove/flavor/models.py +++ b/trove/flavor/models.py @@ -38,9 +38,9 @@ class Flavor(object): try: client = create_nova_client(context) self.flavor = client.flavors.get(flavor_id) - except nova_exceptions.NotFound, e: + except nova_exceptions.NotFound as e: raise exception.NotFound(uuid=flavor_id) - except nova_exceptions.ClientException, e: + except nova_exceptions.ClientException as e: raise exception.TroveError(str(e)) return msg = ("Flavor is not defined, and" diff --git a/trove/guestagent/manager/mysql_service.py b/trove/guestagent/manager/mysql_service.py index 4ea42852e8..2337100583 100644 --- a/trove/guestagent/manager/mysql_service.py +++ b/trove/guestagent/manager/mysql_service.py @@ -563,7 +563,7 @@ class KeepAliveConnection(interfaces.PoolListener): dbapi_con.ping(False) except TypeError: dbapi_con.ping() - except dbapi_con.OperationalError, ex: + except dbapi_con.OperationalError as ex: if ex.args[0] in (2006, 2013, 2014, 2045, 2055): raise exc.DisconnectionError() else: @@ -818,7 +818,7 @@ class MySqlApp(object): # don't let a rouge process wander around. try: utils.execute_with_timeout("sudo", "pkill", "-9", "mysql") - except exception.ProcessExecutionError, p: + except exception.ProcessExecutionError as p: LOG.error("Error killing stalled mysql start command.") LOG.error(p) # There's nothing more we can do... @@ -869,7 +869,7 @@ class MySqlRootAccess(object): user.host = "%" user.password = generate_random_password() with LocalSqlClient(get_engine()) as client: - print client + print(client) try: cu = query.CreateUser(user.name, host=user.host) t = text(str(cu)) @@ -879,7 +879,7 @@ class MySqlRootAccess(object): # TODO(rnirmal): More fine grained error checking later on LOG.debug(err) with LocalSqlClient(get_engine()) as client: - print client + print(client) uu = query.UpdateUser(user.name, host=user.host, clear=user.password) t = text(str(uu)) diff --git a/trove/guestagent/strategies/storage/swift.py b/trove/guestagent/strategies/storage/swift.py index a8b6876da5..71c5dc80b1 100644 --- a/trove/guestagent/strategies/storage/swift.py +++ b/trove/guestagent/strategies/storage/swift.py @@ -59,7 +59,7 @@ class SwiftStorage(base.Storage): # Check each segment MD5 hash against swift etag # Raise an error and mark backup as failed if etag != stream.schecksum.hexdigest(): - print etag, stream.schecksum.hexdigest() + print("%s %s" % (etag, stream.schecksum.hexdigest())) return (False, "Error saving data to Swift!", None, None) checksum = stream.checksum.hexdigest() diff --git a/trove/instance/models.py b/trove/instance/models.py index 940580cea4..ed15bdf4c5 100644 --- a/trove/instance/models.py +++ b/trove/instance/models.py @@ -49,7 +49,7 @@ def load_server(context, instance_id, server_id): LOG.debug("Could not find nova server_id(%s)" % server_id) raise exception.ComputeInstanceNotFound(instance_id=instance_id, server_id=server_id) - except nova_exceptions.ClientException, e: + except nova_exceptions.ClientException as e: raise exception.TroveError(str(e)) return server diff --git a/trove/taskmanager/models.py b/trove/taskmanager/models.py index 5d7f88eab8..fc294261ef 100644 --- a/trove/taskmanager/models.py +++ b/trove/taskmanager/models.py @@ -496,7 +496,7 @@ class BuiltInstanceTasks(BuiltInstance, NotifyMixin): # when the reboot completes and MySQL is running. self._set_service_status_to_paused() LOG.debug("Successfully rebooted instance %s" % self.id) - except Exception, e: + except Exception as e: LOG.error("Failed to reboot instance %s: %s" % (self.id, str(e))) finally: LOG.debug("Rebooting FINALLY %s" % self.id) diff --git a/trove/tests/api/instances.py b/trove/tests/api/instances.py index dfbab06774..97dcebf11b 100644 --- a/trove/tests/api/instances.py +++ b/trove/tests/api/instances.py @@ -1178,7 +1178,7 @@ class CheckInstance(AttrCheck): return if self.volume_key_exists(): expected_attrs = ['size', 'used'] - print self.instance + print(self.instance) self.attrs_exist(self.instance['volume'], expected_attrs, msg="Volumes") @@ -1192,7 +1192,7 @@ class CheckInstance(AttrCheck): def addresses(self): expected_attrs = ['addr', 'version'] - print self.instance + print(self.instance) networks = ['usernet'] for network in networks: for address in self.instance['addresses'][network]: @@ -1251,11 +1251,11 @@ class BadInstanceStatusBug(): def verify_instance_is_active(): result = self.client.instances.get(id) - print result.status + print(result.status) return result.status == 'ACTIVE' def attempt_migrate(): - print 'attempting migration' + print('attempting migration') try: self.mgmt.migrate(id) except exceptions.UnprocessableEntity: diff --git a/trove/tests/api/mgmt/accounts.py b/trove/tests/api/mgmt/accounts.py index c42ccb3eac..cceed88691 100644 --- a/trove/tests/api/mgmt/accounts.py +++ b/trove/tests/api/mgmt/accounts.py @@ -145,7 +145,7 @@ class AllAccounts(object): except exceptions.NotFound: deleted_count += 1 except Exception: - print "Failed to delete instance" + print("Failed to delete instance") if deleted_count == len(user_instances): break @@ -201,7 +201,7 @@ class AccountWithBrokenInstance(object): lambda instance: instance.status == 'ERROR', time_out=10) self.instance = self.client.instances.get(self.response.id) - print "Status: %s" % self.instance.status + print("Status: %s" % self.instance.status) msg = "Instance did not drop to error after server prov failure." assert_equal(self.instance.status, "ERROR", msg) diff --git a/trove/tests/api/mgmt/instances_actions.py b/trove/tests/api/mgmt/instances_actions.py index 3563808c64..737c35ca8a 100644 --- a/trove/tests/api/mgmt/instances_actions.py +++ b/trove/tests/api/mgmt/instances_actions.py @@ -60,7 +60,7 @@ class MgmtInstanceBase(object): def _make_request(self, path='/', context=None, **kwargs): from webob import Request path = '/' - print "path:", path + print("path: %s" % path) return Request.blank(path=path, environ={'trove.context': context}, **kwargs) diff --git a/trove/tests/fakes/guestagent.py b/trove/tests/fakes/guestagent.py index 4567f6ecaa..2a59134cbb 100644 --- a/trove/tests/fakes/guestagent.py +++ b/trove/tests/fakes/guestagent.py @@ -102,7 +102,7 @@ class FakeGuest(object): if hostname is None: hostname = '%' self.users[(username, hostname)] = user - print "CREATING %s @ %s" % (username, hostname) + print("CREATING %s @ %s" % (username, hostname)) databases = [db['_name'] for db in user['_databases']] self.grant_access(username, hostname, databases) return user @@ -173,7 +173,7 @@ class FakeGuest(object): def get_user(self, username, hostname): self._check_username(username) for (u, h) in self.users: - print "%r @ %r" % (u, h) + print("%r @ %r" % (u, h)) if (username, hostname) not in self.users: raise rd_exception.UserNotFound( "User %s@%s cannot be found on the instance." diff --git a/trove/tests/fakes/nova.py b/trove/tests/fakes/nova.py index e719781464..b6210da506 100644 --- a/trove/tests/fakes/nova.py +++ b/trove/tests/fakes/nova.py @@ -571,9 +571,9 @@ class FakeHost(object): self.totalRAM = 2004 # 16384 self.usedRAM = 0 for server in self.servers.list(): - print server + print(server) if server.host != self.name: - print "\t...not on this host." + print("\t...not on this host.") continue self.instances.append({ 'uuid': server.id, diff --git a/trove/tests/unittests/api/common/test_limits.py b/trove/tests/unittests/api/common/test_limits.py index bcf4e3b3c9..69f067d600 100644 --- a/trove/tests/unittests/api/common/test_limits.py +++ b/trove/tests/unittests/api/common/test_limits.py @@ -329,7 +329,7 @@ class ParseLimitsTest(BaseLimitTestSuite): '(PUT, /foo*, /foo.*, 10, hour);' '(POST, /bar*, /bar.*, 5, second);' '(Say, /derp*, /derp.*, 1, day)') - except ValueError, e: + except ValueError as e: assert False, str(e) # Make sure the number of returned limits are correct diff --git a/trove/tests/unittests/guestagent/test_dbaas.py b/trove/tests/unittests/guestagent/test_dbaas.py index a3bcb8e371..7985d308b0 100644 --- a/trove/tests/unittests/guestagent/test_dbaas.py +++ b/trove/tests/unittests/guestagent/test_dbaas.py @@ -702,7 +702,7 @@ class TextClauseMatcher(matchers.Matcher): return "TextClause(%s)" % self.contains.sub def matches(self, arg): - print "Matching", arg.text + print("Matching %s" % arg.text) return self.contains.matches(arg.text) diff --git a/trove/tests/util/usage.py b/trove/tests/util/usage.py index b18a949039..4a784e28ea 100644 --- a/trove/tests/util/usage.py +++ b/trove/tests/util/usage.py @@ -40,7 +40,7 @@ class UsageVerifier(object): def check_message(self, resource_id, event_type, **attrs): messages = self.get_messages(resource_id) - print messages, resource_id + print("%s %s" % (messages, resource_id)) found = None for message in messages: if message['event_type'] == event_type: