'except:' to 'except Exception:' as per HACKING

Change-Id: I6e372152946dc7b51a4d84d6f4b893774e7d1a1d
This commit is contained in:
Joe Gordon
2011-12-27 12:07:06 -08:00
parent cff2ddcbd5
commit 51e7bcf5f4
8 changed files with 13 additions and 13 deletions

View File

@@ -157,10 +157,10 @@ class SimpleTenantUsageController(object):
return dtstr return dtstr
try: try:
return datetime.strptime(dtstr, "%Y-%m-%dT%H:%M:%S") return datetime.strptime(dtstr, "%Y-%m-%dT%H:%M:%S")
except: except Exception:
try: try:
return datetime.strptime(dtstr, "%Y-%m-%dT%H:%M:%S.%f") return datetime.strptime(dtstr, "%Y-%m-%dT%H:%M:%S.%f")
except: except Exception:
return datetime.strptime(dtstr, "%Y-%m-%d %H:%M:%S.%f") return datetime.strptime(dtstr, "%Y-%m-%d %H:%M:%S.%f")
def _get_datetime_range(self, req): def _get_datetime_range(self, req):

View File

@@ -323,7 +323,7 @@ class ComputeManager(manager.SchedulerDependentManager):
if instance['task_state'] == task_states.DELETING: if instance['task_state'] == task_states.DELETING:
return True return True
return False return False
except: except Exception:
return True return True
def _shutdown_instance_even_if_deleted(self, context, instance_uuid): def _shutdown_instance_even_if_deleted(self, context, instance_uuid):
@@ -362,7 +362,7 @@ class ComputeManager(manager.SchedulerDependentManager):
instance = self._spawn(context, instance, image_meta, instance = self._spawn(context, instance, image_meta,
network_info, block_device_info, network_info, block_device_info,
injected_files, admin_password) injected_files, admin_password)
except: except Exception:
with utils.save_and_reraise_exception(): with utils.save_and_reraise_exception():
self._deallocate_network(context, instance) self._deallocate_network(context, instance)
self._notify_about_instance_usage(instance) self._notify_about_instance_usage(instance)
@@ -460,7 +460,7 @@ class ComputeManager(manager.SchedulerDependentManager):
network_info = self.network_api.allocate_for_instance( network_info = self.network_api.allocate_for_instance(
context, instance, vpn=is_vpn, context, instance, vpn=is_vpn,
requested_networks=requested_networks) requested_networks=requested_networks)
except: except Exception:
msg = _("Instance %s failed network setup") msg = _("Instance %s failed network setup")
LOG.exception(msg % instance['uuid']) LOG.exception(msg % instance['uuid'])
raise raise
@@ -475,7 +475,7 @@ class ComputeManager(manager.SchedulerDependentManager):
try: try:
mapping = self._setup_block_device_mapping(context, instance) mapping = self._setup_block_device_mapping(context, instance)
swap, ephemerals, block_device_mapping = mapping swap, ephemerals, block_device_mapping = mapping
except: except Exception:
msg = _("Instance %s failed block device setup") msg = _("Instance %s failed block device setup")
LOG.exception(msg % instance['uuid']) LOG.exception(msg % instance['uuid'])
raise raise
@@ -495,7 +495,7 @@ class ComputeManager(manager.SchedulerDependentManager):
try: try:
self.driver.spawn(context, instance, image_meta, self.driver.spawn(context, instance, image_meta,
network_info, block_device_info) network_info, block_device_info)
except: except Exception:
msg = _("Instance %s failed to spawn") msg = _("Instance %s failed to spawn")
LOG.exception(msg % instance['uuid']) LOG.exception(msg % instance['uuid'])
raise raise

View File

@@ -107,7 +107,7 @@ class _AnsiColorizer(object):
except curses.error: except curses.error:
curses.setupterm() curses.setupterm()
return curses.tigetnum("colors") > 2 return curses.tigetnum("colors") > 2
except: except Exception:
raise raise
# guess false in case of error # guess false in case of error
return False return False

View File

@@ -1090,7 +1090,7 @@ def save_and_reraise_exception():
type_, value, traceback = sys.exc_info() type_, value, traceback = sys.exc_info()
try: try:
yield yield
except: except Exception:
LOG.exception(_('Original exception being dropped'), LOG.exception(_('Original exception being dropped'),
exc_info=(type_, value, traceback)) exc_info=(type_, value, traceback))
raise raise

View File

@@ -482,7 +482,7 @@ class VMHelper(HelperBase):
# 4. Create VBD between instance VM and swap VDI # 4. Create VBD between instance VM and swap VDI
volume_utils.VolumeHelper.create_vbd( volume_utils.VolumeHelper.create_vbd(
session, vm_ref, vdi_ref, userdevice, bootable=False) session, vm_ref, vdi_ref, userdevice, bootable=False)
except: except Exception:
with utils.save_and_reraise_exception(): with utils.save_and_reraise_exception():
cls.destroy_vdi(session, vdi_ref) cls.destroy_vdi(session, vdi_ref)

View File

@@ -870,7 +870,7 @@ class ZadaraBEDriver(ISCSIDriver):
volume['host']) volume['host'])
try: try:
ret = self._common_be_export(context, volume, iscsi_target) ret = self._common_be_export(context, volume, iscsi_target)
except: except Exception:
raise exception.ProcessExecutionError raise exception.ProcessExecutionError
return ret return ret

View File

@@ -253,7 +253,7 @@ class API(base.Base):
volume_type=vol_type, volume_type=vol_type,
metadata=dict(to_vsa_id=str(vsa_id)), metadata=dict(to_vsa_id=str(vsa_id)),
availability_zone=availability_zone) availability_zone=availability_zone)
except: except Exception:
self.update_vsa_status(context, vsa_id, self.update_vsa_status(context, vsa_id,
status=VsaState.PARTIAL) status=VsaState.PARTIAL)
raise raise

View File

@@ -55,7 +55,7 @@ try:
BuildDoc.run(self) BuildDoc.run(self)
nova_cmdclass['build_sphinx'] = local_BuildDoc nova_cmdclass['build_sphinx'] = local_BuildDoc
except: except Exception:
pass pass