From c28e4b526aed5c3dacee17729241c6a12859fc0b Mon Sep 17 00:00:00 2001 From: Joe Gordon Date: Tue, 21 Feb 2012 00:10:04 -0800 Subject: Exception cleanup Do not write "except:", use "except Exception:" at the very least Change-Id: I539c013132309791f18c46819232102e9232e917 --- .../064_change_instance_id_to_uuid_in_instance_actions.py | 2 +- nova/tests/test_SolidFireSanISCSIDriver.py | 4 ++-- nova/tests/test_compute.py | 4 ++-- nova/virt/baremetal/dom.py | 8 ++++---- nova/virt/baremetal/proxy.py | 4 ++-- nova/virt/baremetal/tilera.py | 2 +- nova/virt/libvirt/connection.py | 2 +- 7 files changed, 13 insertions(+), 13 deletions(-) (limited to 'nova') diff --git a/nova/db/sqlalchemy/migrate_repo/versions/064_change_instance_id_to_uuid_in_instance_actions.py b/nova/db/sqlalchemy/migrate_repo/versions/064_change_instance_id_to_uuid_in_instance_actions.py index a31c50d88..07f0aaa17 100644 --- a/nova/db/sqlalchemy/migrate_repo/versions/064_change_instance_id_to_uuid_in_instance_actions.py +++ b/nova/db/sqlalchemy/migrate_repo/versions/064_change_instance_id_to_uuid_in_instance_actions.py @@ -56,7 +56,7 @@ def upgrade(migrate_engine): ForeignKeyConstraint(columns=[instance_actions.c.instance_id], refcolumns=[instances.c.id], name=fkey_name).drop() - except: + except Exception: LOG.error(_("foreign key constraint couldn't be removed")) raise diff --git a/nova/tests/test_SolidFireSanISCSIDriver.py b/nova/tests/test_SolidFireSanISCSIDriver.py index 0f3addddc..2321052a3 100644 --- a/nova/tests/test_SolidFireSanISCSIDriver.py +++ b/nova/tests/test_SolidFireSanISCSIDriver.py @@ -111,7 +111,7 @@ class SolidFireVolumeTestCase(test.TestCase): try: sfv.create_volume(testvol) self.fail("Should have thrown Error") - except: + except Exception: pass def test_create_sfaccount(self): @@ -155,7 +155,7 @@ class SolidFireVolumeTestCase(test.TestCase): try: model_update = sfv.delete_volume(testvol) self.fail("Should have thrown Error") - except: + except Exception: pass def test_delete_volume_fails_account_lookup(self): diff --git a/nova/tests/test_compute.py b/nova/tests/test_compute.py index 30027eb67..d6d54227f 100644 --- a/nova/tests/test_compute.py +++ b/nova/tests/test_compute.py @@ -1522,7 +1522,7 @@ class ComputeTestCase(BaseTestCase): try: raise NotImplementedError('test') - except: + except Exception: exc_info = sys.exc_info() self.stubs.Set(nova.db, 'instance_fault_create', fake_db_fault_create) @@ -1550,7 +1550,7 @@ class ComputeTestCase(BaseTestCase): try: raise user_exc - except: + except Exception: exc_info = sys.exc_info() self.stubs.Set(nova.db, 'instance_fault_create', fake_db_fault_create) diff --git a/nova/virt/baremetal/dom.py b/nova/virt/baremetal/dom.py index 013a2dc2a..423d273e7 100644 --- a/nova/virt/baremetal/dom.py +++ b/nova/virt/baremetal/dom.py @@ -130,7 +130,7 @@ class BareMetalDom(object): try: self.baremetal_nodes.deactivate_node(fd['node_id']) - except: + except Exception: msg = _("Failed power down Bare-metal node %s") raise exception.NotFound(msg % fd['node_id']) self.change_domain_state(name, power_state.BUILDING) @@ -139,7 +139,7 @@ class BareMetalDom(object): node_ip, name, fd['mac_address'], fd['ip_address']) self.change_domain_state(name, state) return state - except: + except Exception: LOG.debug(_("deactivate -> activate fails")) self.destroy_domain(name) raise @@ -165,7 +165,7 @@ class BareMetalDom(object): self.store_domain() msg = _("After storing domains: %s") LOG.debug(msg % (self.domains)) - except: + except Exception: LOG.debug(_("deactivation/removing domain failed")) raise @@ -207,7 +207,7 @@ class BareMetalDom(object): node_ip, new_dom['name'], new_dom['mac_address'], new_dom['ip_address'], new_dom['user_data']) self.change_domain_state(new_dom['name'], state) - except: + except Exception: self.domains.remove(new_dom) self.baremetal_nodes.free_node(node_id) LOG.debug(_("Failed to boot Bare-metal node %s"), node_id) diff --git a/nova/virt/baremetal/proxy.py b/nova/virt/baremetal/proxy.py index 1d6502783..b651ee2c4 100644 --- a/nova/virt/baremetal/proxy.py +++ b/nova/virt/baremetal/proxy.py @@ -188,7 +188,7 @@ class ProxyConnection(driver.ComputeDriver): if state == power_state.RUNNING: LOG.debug(_('instance %s: rebooted'), instance['name']) timer.stop() - except: + except Exception: LOG.exception(_('_wait_for_reboot failed')) timer.stop() timer.f = _wait_for_reboot @@ -221,7 +221,7 @@ class ProxyConnection(driver.ComputeDriver): if state == power_state.RUNNING: LOG.debug(_('instance %s: rescued'), instance['name']) timer.stop() - except: + except Exception: LOG.exception(_('_wait_for_rescue failed')) timer.stop() timer.f = _wait_for_reboot diff --git a/nova/virt/baremetal/tilera.py b/nova/virt/baremetal/tilera.py index 3cc36d48f..d79ce153d 100644 --- a/nova/virt/baremetal/tilera.py +++ b/nova/virt/baremetal/tilera.py @@ -228,7 +228,7 @@ class BareMetalNodes(object): try: utils.execute('sudo', 'umount', '-f', pathx) utils.execute('sudo', 'rm', '-f', pathx) - except: + except Exception: LOG.debug(_("rootfs is already removed")) def network_set(self, node_ip, mac_address, ip_address): diff --git a/nova/virt/libvirt/connection.py b/nova/virt/libvirt/connection.py index 7e058e198..e8fdcd792 100644 --- a/nova/virt/libvirt/connection.py +++ b/nova/virt/libvirt/connection.py @@ -2167,7 +2167,7 @@ class LibvirtConnection(driver.ComputeDriver): utils.execute('rm', '-rf', inst_base) utils.execute('mv', inst_base_resize, inst_base) utils.execute('ssh', dest, 'rm', '-rf', inst_base) - except: + except Exception: pass raise e -- cgit