Improve Python 3.x compatibility
A bit of mechanical translation to clean out the deprecated except x,y: construct Change-Id: I80883b6b0c014bdf4799e8b7b2c4a4a07d951a0b
This commit is contained in:
parent
0490eab24c
commit
98c4e04ac6
@ -397,7 +397,7 @@ def bm_interface_set_vif_uuid(context, if_id, vif_uuid):
|
|||||||
try:
|
try:
|
||||||
session.add(bm_interface)
|
session.add(bm_interface)
|
||||||
session.flush()
|
session.flush()
|
||||||
except db_exc.DBError, e:
|
except db_exc.DBError as e:
|
||||||
# TODO(deva): clean up when db layer raises DuplicateKeyError
|
# TODO(deva): clean up when db layer raises DuplicateKeyError
|
||||||
if str(e).find('IntegrityError') != -1:
|
if str(e).find('IntegrityError') != -1:
|
||||||
raise exception.NovaException(_("Baremetal interface %s "
|
raise exception.NovaException(_("Baremetal interface %s "
|
||||||
|
@ -307,7 +307,7 @@ class BareMetalDriver(driver.ComputeDriver):
|
|||||||
self._unplug_vifs(instance, network_info)
|
self._unplug_vifs(instance, network_info)
|
||||||
|
|
||||||
_update_state(context, node, None, baremetal_states.DELETED)
|
_update_state(context, node, None, baremetal_states.DELETED)
|
||||||
except Exception, e:
|
except Exception as e:
|
||||||
with excutils.save_and_reraise_exception():
|
with excutils.save_and_reraise_exception():
|
||||||
try:
|
try:
|
||||||
LOG.error(_("Error from baremetal driver "
|
LOG.error(_("Error from baremetal driver "
|
||||||
|
@ -45,7 +45,7 @@ def inject_into_image(image, key, net, metadata, admin_password,
|
|||||||
def unlink_without_raise(path):
|
def unlink_without_raise(path):
|
||||||
try:
|
try:
|
||||||
os.unlink(path)
|
os.unlink(path)
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
if e.errno == errno.ENOENT:
|
if e.errno == errno.ENOENT:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
@ -56,7 +56,7 @@ def rmtree_without_raise(path):
|
|||||||
try:
|
try:
|
||||||
if os.path.isdir(path):
|
if os.path.isdir(path):
|
||||||
shutil.rmtree(path)
|
shutil.rmtree(path)
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
LOG.warn(_("Failed to remove dir %(path)s, error: %(e)s") % locals())
|
LOG.warn(_("Failed to remove dir %(path)s, error: %(e)s") % locals())
|
||||||
|
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ def write_to_file(path, contents):
|
|||||||
def create_link_without_raise(source, link):
|
def create_link_without_raise(source, link):
|
||||||
try:
|
try:
|
||||||
os.symlink(source, link)
|
os.symlink(source, link)
|
||||||
except OSError, e:
|
except OSError as e:
|
||||||
if e.errno == errno.EEXIST:
|
if e.errno == errno.EEXIST:
|
||||||
return
|
return
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user