Merge "Use Python 3.x compatible except: construct"
This commit is contained in:
commit
87bec5dc70
@ -472,7 +472,7 @@ class StorageManagerCommands(object):
|
||||
db.sm_flavor_create(context.get_admin_context(),
|
||||
dict(label=label,
|
||||
description=desc))
|
||||
except exception.DBError, e:
|
||||
except exception.DBError as e:
|
||||
_db_error(e)
|
||||
|
||||
@args('label', help='label of flavor to be deleted')
|
||||
@ -480,7 +480,7 @@ class StorageManagerCommands(object):
|
||||
try:
|
||||
db.sm_flavor_delete(context.get_admin_context(), label)
|
||||
|
||||
except exception.DBError, e:
|
||||
except exception.DBError as e:
|
||||
_db_error(e)
|
||||
|
||||
def _splitfun(self, item):
|
||||
@ -541,7 +541,7 @@ class StorageManagerCommands(object):
|
||||
sr_uuid = params['sr_uuid']
|
||||
try:
|
||||
backend = db.sm_backend_conf_get_by_sr(ctxt, sr_uuid)
|
||||
except exception.DBError, e:
|
||||
except exception.DBError as e:
|
||||
_db_error(e)
|
||||
|
||||
if backend:
|
||||
@ -556,7 +556,7 @@ class StorageManagerCommands(object):
|
||||
flavor_id=flavors['id'],
|
||||
sr_type=sr_type,
|
||||
config_params=config_params))
|
||||
except exception.DBError, e:
|
||||
except exception.DBError as e:
|
||||
_db_error(e)
|
||||
return
|
||||
|
||||
@ -572,7 +572,7 @@ class StorageManagerCommands(object):
|
||||
sr_uuid=sr_uuid,
|
||||
sr_type=sr_type,
|
||||
config_params=config_params))
|
||||
except exception.DBError, e:
|
||||
except exception.DBError as e:
|
||||
_db_error(e)
|
||||
|
||||
@args('backend_conf_id')
|
||||
@ -581,7 +581,7 @@ class StorageManagerCommands(object):
|
||||
db.sm_backend_conf_delete(context.get_admin_context(),
|
||||
backend_conf_id)
|
||||
|
||||
except exception.DBError, e:
|
||||
except exception.DBError as e:
|
||||
_db_error(e)
|
||||
|
||||
|
||||
|
@ -82,7 +82,7 @@ if __name__ == '__main__':
|
||||
try:
|
||||
cinder.volume.utils.notify_usage_exists(admin_context,
|
||||
volume_ref)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print traceback.format_exc(e)
|
||||
|
||||
snapshots = db.snapshot_get_active_by_window(admin_context,
|
||||
@ -95,7 +95,7 @@ if __name__ == '__main__':
|
||||
snapshot_ref,
|
||||
'exists',
|
||||
extra_info)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print traceback.fromat_exc(e)
|
||||
|
||||
print _("Volume usage audit completed")
|
||||
|
@ -82,7 +82,7 @@ class AdminController(wsgi.Controller):
|
||||
'update': update})
|
||||
try:
|
||||
self._update(context, id, update)
|
||||
except exception.NotFound, e:
|
||||
except exception.NotFound as e:
|
||||
raise exc.HTTPNotFound(e)
|
||||
return webob.Response(status_int=202)
|
||||
|
||||
|
@ -164,7 +164,7 @@ class VolumeActionsController(wsgi.Controller):
|
||||
force = params.get('force', False)
|
||||
try:
|
||||
volume = self.volume_api.get(context, id)
|
||||
except exception.VolumeNotFound, error:
|
||||
except exception.VolumeNotFound as error:
|
||||
raise webob.exc.HTTPNotFound(explanation=unicode(error))
|
||||
authorize(context, "upload_image")
|
||||
image_metadata = {"container_format": params.get("container_format",
|
||||
@ -176,9 +176,9 @@ class VolumeActionsController(wsgi.Controller):
|
||||
volume,
|
||||
image_metadata,
|
||||
force)
|
||||
except exception.InvalidVolume, error:
|
||||
except exception.InvalidVolume as error:
|
||||
raise webob.exc.HTTPBadRequest(explanation=unicode(error))
|
||||
except ValueError, error:
|
||||
except ValueError as error:
|
||||
raise webob.exc.HTTPBadRequest(explanation=unicode(error))
|
||||
except rpc_common.RemoteError as error:
|
||||
msg = "%(err_type)s: %(err_msg)s" % {'err_type': error.exc_type,
|
||||
|
@ -894,7 +894,7 @@ class Resource(wsgi.Application):
|
||||
try:
|
||||
msg_dict = dict(url=request.url, status=response.status_int)
|
||||
msg = _("%(url)s returned with HTTP %(status)d") % msg_dict
|
||||
except AttributeError, e:
|
||||
except AttributeError as e:
|
||||
msg_dict = dict(url=request.url, e=e)
|
||||
msg = _("%(url)s returned a fault: %(e)s") % msg_dict
|
||||
|
||||
|
@ -1479,7 +1479,7 @@ def volume_type_create(context, values):
|
||||
volume_type_ref = models.VolumeTypes()
|
||||
volume_type_ref.update(values)
|
||||
volume_type_ref.save()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
raise db_exc.DBError(e)
|
||||
return volume_type_ref
|
||||
|
||||
@ -1629,7 +1629,7 @@ def volume_type_extra_specs_update_or_create(context, volume_type_id,
|
||||
try:
|
||||
spec_ref = volume_type_extra_specs_get_item(
|
||||
context, volume_type_id, key, session)
|
||||
except exception.VolumeTypeExtraSpecsNotFound, e:
|
||||
except exception.VolumeTypeExtraSpecsNotFound as e:
|
||||
spec_ref = models.VolumeTypeExtraSpecs()
|
||||
spec_ref.update({"key": key, "value": value,
|
||||
"volume_type_id": volume_type_id,
|
||||
|
@ -66,7 +66,7 @@ class SchedulerOptions(object):
|
||||
"""Get the last modified datetime. Broken out for testing."""
|
||||
try:
|
||||
return os.path.getmtime(filename)
|
||||
except os.error, e:
|
||||
except os.error as e:
|
||||
LOG.exception(_("Could not stat scheduler options file "
|
||||
"%(filename)s: '%(e)s'"), locals())
|
||||
raise
|
||||
@ -75,7 +75,7 @@ class SchedulerOptions(object):
|
||||
"""Decode the JSON file. Broken out for testing."""
|
||||
try:
|
||||
return json.load(handle)
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
LOG.exception(_("Could not decode scheduler options: "
|
||||
"'%(e)s'") % locals())
|
||||
return {}
|
||||
|
@ -370,7 +370,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
|
||||
|
@ -370,7 +370,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
|
||||
|
@ -133,7 +133,7 @@ class TestMigrations(test.TestCase):
|
||||
for key, value in defaults.items():
|
||||
self.test_databases[key] = value
|
||||
self.snake_walk = cp.getboolean('walk_style', 'snake_walk')
|
||||
except ConfigParser.ParsingError, e:
|
||||
except ConfigParser.ParsingError as e:
|
||||
self.fail("Failed to read test_migrations.conf config "
|
||||
"file. Got error: %s" % e)
|
||||
else:
|
||||
|
@ -220,7 +220,7 @@ def trycmd(*args, **kwargs):
|
||||
try:
|
||||
out, err = execute(*args, **kwargs)
|
||||
failed = False
|
||||
except exception.ProcessExecutionError, exn:
|
||||
except exception.ProcessExecutionError as exn:
|
||||
out, err = '', str(exn)
|
||||
LOG.debug(err)
|
||||
failed = True
|
||||
@ -620,7 +620,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:
|
||||
@ -1062,7 +1062,7 @@ def tempdir(**kwargs):
|
||||
finally:
|
||||
try:
|
||||
shutil.rmtree(tmpdir)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
LOG.debug(_('Could not remove tmpdir: %s'), str(e))
|
||||
|
||||
|
||||
|
@ -328,7 +328,7 @@ class CoraidDriver(driver.VolumeDriver):
|
||||
% snapshot['id'])
|
||||
try:
|
||||
self.esm.create_snapshot(volume_name, snapshot_name)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
msg = _('Failed to Create Snapshot %(snapname)s')
|
||||
LOG.debug(msg % dict(snapname=snapshot_name))
|
||||
raise
|
||||
|
@ -169,7 +169,7 @@ class GlusterfsDriver(nfs.RemoteFsDriver):
|
||||
try:
|
||||
self._ensure_share_mounted(share)
|
||||
self._mounted_shares.append(share)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.warning(_('Exception during mounting %s') % (exc,))
|
||||
|
||||
LOG.debug('Available shares %s' % str(self._mounted_shares))
|
||||
|
@ -310,7 +310,7 @@ class NfsDriver(RemoteFsDriver):
|
||||
try:
|
||||
self._ensure_share_mounted(share)
|
||||
self._mounted_shares.append(share)
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
LOG.warning(_('Exception during mounting %s') % (exc,))
|
||||
|
||||
LOG.debug('Available shares %s' % str(self._mounted_shares))
|
||||
|
@ -145,7 +145,7 @@ class SolidFire(SanISCSIDriver):
|
||||
data = response.read()
|
||||
try:
|
||||
data = json.loads(data)
|
||||
except (TypeError, ValueError), exc:
|
||||
except (TypeError, ValueError) as exc:
|
||||
connection.close()
|
||||
msg = _("Call to json.loads() raised "
|
||||
"an exception: %s") % exc
|
||||
|
@ -645,7 +645,7 @@ class VolumeManager(manager.SchedulerDependentManager):
|
||||
image_meta)
|
||||
LOG.debug(_("Uploaded volume %(volume_id)s to "
|
||||
"image (%(image_id)s) successfully") % locals())
|
||||
except Exception, error:
|
||||
except Exception as error:
|
||||
with excutils.save_and_reraise_exception():
|
||||
payload['message'] = unicode(error)
|
||||
finally:
|
||||
|
@ -125,7 +125,7 @@ def get_default_volume_type():
|
||||
ctxt = context.get_admin_context()
|
||||
try:
|
||||
vol_type = get_volume_type_by_name(ctxt, name)
|
||||
except exception.VolumeTypeNotFoundByName, e:
|
||||
except exception.VolumeTypeNotFoundByName as e:
|
||||
# Couldn't find volume type with the name in default_volume_type
|
||||
# flag, record this issue and move on
|
||||
#TODO(zhiteng) consider add notification to warn admin
|
||||
|
@ -155,7 +155,7 @@ class Server(object):
|
||||
if use_ssl:
|
||||
sock = wrap_ssl(sock)
|
||||
|
||||
except socket.error, err:
|
||||
except socket.error as err:
|
||||
if err.args[0] != errno.EADDRINUSE:
|
||||
raise
|
||||
eventlet.sleep(0.1)
|
||||
|
@ -79,7 +79,7 @@ def _print_module(mod_str):
|
||||
mod_str = mod_str[:mod_str.rfind(".")]
|
||||
try:
|
||||
mod_obj = importutils.import_module(mod_str)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
sys.stderr.write("Failed to collect options from module %s: %s\n" % (
|
||||
mod_str, str(e)))
|
||||
return
|
||||
@ -153,7 +153,7 @@ def _print_opt(opt):
|
||||
opt_type = None
|
||||
try:
|
||||
opt_type = OPTION_REGEX.search(str(type(opt))).group(0)
|
||||
except (ValueError, AttributeError), err:
|
||||
except (ValueError, AttributeError) as err:
|
||||
sys.stderr.write("%s\n" % str(err))
|
||||
sys.exit(1)
|
||||
opt_help += ' (' + OPT_TYPES[opt_type] + ')'
|
||||
|
Loading…
x
Reference in New Issue
Block a user