mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-08 21:18:04 +03:00
Switch to python3 style 'except X as Y' notation
Which also works with python2.7
This commit is contained in:
parent
fcebefd3bb
commit
62feeb02a8
@ -162,7 +162,7 @@ class Command(object):
|
||||
ret = virtconvert.main(conn=conn)
|
||||
elif app.count("virt-xml"):
|
||||
ret = virtxml.main(conn=conn)
|
||||
except SystemExit, sys_e:
|
||||
except SystemExit as sys_e:
|
||||
ret = sys_e.code
|
||||
except Exception:
|
||||
ret = -1
|
||||
@ -193,7 +193,7 @@ class Command(object):
|
||||
|
||||
logging.debug(output + "\n")
|
||||
return code, output
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return (-1, "".join(traceback.format_exc()) + str(e))
|
||||
|
||||
def _check_support(self, tests, conn, check, skipmsg):
|
||||
@ -264,7 +264,7 @@ class Command(object):
|
||||
|
||||
utils.diff_compare(output, filename)
|
||||
|
||||
except AssertionError, e:
|
||||
except AssertionError as e:
|
||||
err = self.cmdstr + "\n" + str(e)
|
||||
|
||||
if err:
|
||||
|
@ -134,7 +134,7 @@ class TestClone(unittest.TestCase):
|
||||
# We shouldn't succeed, so test fails
|
||||
raise AssertionError("Remote clone with storage passed "
|
||||
"when it shouldn't.")
|
||||
except (ValueError, RuntimeError), e:
|
||||
except (ValueError, RuntimeError) as e:
|
||||
# Exception expected
|
||||
logging.debug("Received expected exception: %s", str(e))
|
||||
|
||||
|
@ -90,7 +90,7 @@ def _fetch_distro(distro):
|
||||
cleanup.append(initrd)
|
||||
distro.kernel = kernel
|
||||
distro.initrd = initrd
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print "fetching distro=%s failed: %s" % (distro.name, e)
|
||||
finally:
|
||||
fetcher.cleanupLocation()
|
||||
|
@ -200,7 +200,7 @@ def _storeForDistro(fetcher, guest):
|
||||
for ignore in range(0, 10):
|
||||
try:
|
||||
return urlfetcher.getDistroStore(guest, fetcher)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if str(e).count("502"):
|
||||
logging.debug("Caught proxy error: %s", str(e))
|
||||
time.sleep(.5)
|
||||
|
@ -41,7 +41,7 @@ class _FuzzyPredicate(dogtail.predicate.Predicate):
|
||||
if not self._labeller_pattern.match(node.labeller.text):
|
||||
return
|
||||
return True
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print "got predicate exception: %s" % e
|
||||
|
||||
|
||||
@ -159,7 +159,7 @@ def print_nodes(root):
|
||||
def _walk(node):
|
||||
try:
|
||||
print node_string(node)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print "got exception: %s" % e
|
||||
|
||||
root.findChildren(_walk, isLambda=True)
|
||||
@ -173,7 +173,7 @@ def focused_nodes(root):
|
||||
try:
|
||||
if node.focused:
|
||||
return node
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
print "got exception: %s" % e
|
||||
|
||||
return root.findChildren(_walk, isLambda=True)
|
||||
|
@ -146,7 +146,7 @@ def test_create(testconn, xml, define_func="defineXML"):
|
||||
try:
|
||||
func = getattr(testconn, define_func)
|
||||
obj = func(xml)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
raise RuntimeError(str(e) + "\n" + xml)
|
||||
|
||||
try:
|
||||
|
@ -52,7 +52,7 @@ def get_original_guest(guest_name, origfile, design):
|
||||
try:
|
||||
design.original_xml = origxml
|
||||
return
|
||||
except (ValueError, RuntimeError), e:
|
||||
except (ValueError, RuntimeError) as e:
|
||||
fail(e)
|
||||
|
||||
if not guest_name:
|
||||
@ -219,9 +219,9 @@ def main(conn=None):
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
sys.exit(main())
|
||||
except SystemExit, sys_e:
|
||||
except SystemExit as sys_e:
|
||||
sys.exit(sys_e.code)
|
||||
except KeyboardInterrupt:
|
||||
print_stderr(_("Installation aborted at user request"))
|
||||
except Exception, main_e:
|
||||
except Exception as main_e:
|
||||
fail(main_e)
|
||||
|
@ -133,9 +133,9 @@ def main(conn=None):
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
sys.exit(main())
|
||||
except SystemExit, sys_e:
|
||||
except SystemExit as sys_e:
|
||||
sys.exit(sys_e.code)
|
||||
except KeyboardInterrupt:
|
||||
print_stderr(_("Aborted at user request"))
|
||||
except Exception, main_e:
|
||||
except Exception as main_e:
|
||||
fail(main_e)
|
||||
|
14
virt-install
14
virt-install
@ -367,7 +367,7 @@ def get_guest(conn, options):
|
||||
arch=arch,
|
||||
typ=req_hv_type,
|
||||
machine=options.machine)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
fail(e)
|
||||
|
||||
if (not req_virt_type and
|
||||
@ -400,7 +400,7 @@ def set_install_media(guest, location, cdpath, distro_variant):
|
||||
guest.os_variant = guest.installer.detect_distro(guest)
|
||||
elif distro_variant != "none":
|
||||
guest.os_variant = distro_variant
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
fail(_("Error validating install location: %s") % str(e))
|
||||
|
||||
|
||||
@ -627,7 +627,7 @@ def build_guest_instance(conn, options):
|
||||
guest.os.nvram is None):
|
||||
try:
|
||||
guest.set_uefi_default()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error setting UEFI default for aarch64",
|
||||
exc_info=True)
|
||||
logging.warn("Couldn't configure UEFI: %s", e)
|
||||
@ -713,7 +713,7 @@ def start_install(guest, options):
|
||||
logging.debug("", exc_info=True)
|
||||
print_stderr(_("Domain install interrupted."))
|
||||
raise
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
fail(e, do_exit=False)
|
||||
if guest.domain is None:
|
||||
guest.cleanup_created_disks(meter)
|
||||
@ -736,7 +736,7 @@ def check_domain(guest, conscb, transient,
|
||||
fail(_("Domain has crashed."))
|
||||
|
||||
return not guest.domain.isActive()
|
||||
except libvirt.libvirtError, e:
|
||||
except libvirt.libvirtError as e:
|
||||
if transient and e.get_error_code() == libvirt.VIR_ERR_NO_DOMAIN:
|
||||
logging.debug("transient VM shutdown and disappeared.")
|
||||
return True
|
||||
@ -995,10 +995,10 @@ def main(conn=None):
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
sys.exit(main())
|
||||
except SystemExit, sys_e:
|
||||
except SystemExit as sys_e:
|
||||
sys.exit(sys_e.code)
|
||||
except KeyboardInterrupt:
|
||||
logging.debug("", exc_info=True)
|
||||
print_stderr(_("Installation aborted at user request"))
|
||||
except Exception, main_e:
|
||||
except Exception as main_e:
|
||||
fail(main_e)
|
||||
|
@ -85,7 +85,7 @@ def _import_gtk(leftovers):
|
||||
globals()["Gtk"] = Gtk
|
||||
import virtManager.config
|
||||
ignore = virtManager.config
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
# Don't just let the exception raise here. abrt reports bugs
|
||||
# when users mess up su/sudo and DISPLAY isn't set. Printing
|
||||
# it avoids the issue
|
||||
@ -282,7 +282,7 @@ if __name__ == "__main__":
|
||||
logging.debug("Received KeyboardInterrupt. Exiting application.")
|
||||
except SystemExit:
|
||||
raise
|
||||
except Exception, run_e:
|
||||
except Exception as run_e:
|
||||
if "Gtk" not in globals():
|
||||
raise
|
||||
_show_startup_error(str(run_e), "".join(traceback.format_exc()))
|
||||
|
8
virt-xml
8
virt-xml
@ -94,7 +94,7 @@ def get_domain_and_guest(conn, domstr):
|
||||
domain = conn.lookupByUUIDString(domstr)
|
||||
else:
|
||||
domain = conn.lookupByName(domstr)
|
||||
except libvirt.libvirtError, e:
|
||||
except libvirt.libvirtError as e:
|
||||
fail(_("Could not find domain '%s': %s") % (domstr, e))
|
||||
|
||||
state = domain.info()[0]
|
||||
@ -295,7 +295,7 @@ def update_changes(domain, devs, action, confirm):
|
||||
domain.detachDeviceFlags(xml, libvirt.VIR_DOMAIN_AFFECT_LIVE)
|
||||
elif action == "update":
|
||||
domain.updateDeviceFlags(xml, libvirt.VIR_DOMAIN_AFFECT_LIVE)
|
||||
except libvirt.libvirtError, e:
|
||||
except libvirt.libvirtError as e:
|
||||
fail(_("Error attempting device %s: %s") % (action, e))
|
||||
|
||||
print_stdout(_("Device %s successful.") % action)
|
||||
@ -476,10 +476,10 @@ def main(conn=None):
|
||||
if __name__ == "__main__":
|
||||
try:
|
||||
sys.exit(main())
|
||||
except SystemExit, sys_e:
|
||||
except SystemExit as sys_e:
|
||||
sys.exit(sys_e.code)
|
||||
except KeyboardInterrupt:
|
||||
logging.debug("", exc_info=True)
|
||||
print_stderr(_("Aborted at user request"))
|
||||
except Exception, main_e:
|
||||
except Exception as main_e:
|
||||
fail(main_e)
|
||||
|
@ -779,7 +779,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
else:
|
||||
# Guest XML editing
|
||||
define_func(**define_args)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
err.show_err((_("Error changing VM configuration: %s") %
|
||||
str(e)))
|
||||
return False
|
||||
@ -797,7 +797,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
elif hotplug_args:
|
||||
did_hotplug = True
|
||||
vm.hotplug(**hotplug_args)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
did_hotplug = True
|
||||
logging.debug("Hotplug failed: %s", str(e))
|
||||
hotplug_err = ((str(e), "".join(traceback.format_exc())))
|
||||
@ -1311,7 +1311,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
if controller is not None:
|
||||
self.vm.attach_device(controller)
|
||||
self.vm.attach_device(self._dev)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Device could not be hotplugged: %s", str(e))
|
||||
attach_err = (str(e), "".join(traceback.format_exc()))
|
||||
|
||||
@ -1335,7 +1335,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
if controller is not None:
|
||||
self.vm.add_device(controller)
|
||||
self.vm.add_device(self._dev)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error adding device: %s") % str(e))
|
||||
return True
|
||||
|
||||
@ -1346,7 +1346,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
if not error:
|
||||
try:
|
||||
failure = self._add_device()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
failure = True
|
||||
error = _("Unable to add device: %s") % str(e)
|
||||
details = "".join(traceback.format_exc())
|
||||
@ -1364,7 +1364,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
try:
|
||||
if self._validate() is False:
|
||||
return
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Uncaught error validating hardware "
|
||||
"input: %s") % str(e))
|
||||
return
|
||||
@ -1485,7 +1485,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
try:
|
||||
disk = self.addstorage.validate_storage(self.vm.get_name(),
|
||||
collidelist=collidelist, device=device)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Storage parameter error."), e)
|
||||
|
||||
if disk is False:
|
||||
@ -1508,7 +1508,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
disk, controller_model, disks)
|
||||
|
||||
disk.generate_target(used, prefer_ctrl)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Storage parameter error."), e)
|
||||
|
||||
if self.addstorage.validate_disk_object(disk) is False:
|
||||
@ -1568,7 +1568,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
raise ValueError(_("invalid listen type"))
|
||||
if keymap:
|
||||
self._dev.keymap = keymap
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
self.err.val_err(_("Graphics device parameter error"), e)
|
||||
|
||||
def _validate_page_sound(self):
|
||||
@ -1577,7 +1577,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
try:
|
||||
self._dev = virtinst.VirtualAudio(self.conn.get_backend())
|
||||
self._dev.model = smodel
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Sound device parameter error"), e)
|
||||
|
||||
def _validate_page_hostdev(self):
|
||||
@ -1603,7 +1603,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
return False
|
||||
dev.set_from_nodedev(nodedev)
|
||||
self._dev = dev
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Host device parameter error"), e)
|
||||
|
||||
def _validate_page_char(self):
|
||||
@ -1668,7 +1668,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
|
||||
# Dump XML for sanity checking
|
||||
self._dev.get_xml_config()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(
|
||||
_("%s device parameter error") %
|
||||
char_class.virtual_device_type.capitalize(), e)
|
||||
@ -1680,7 +1680,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
try:
|
||||
self._dev = VirtualVideoDevice(conn)
|
||||
self._dev.model = model
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Video device parameter error"), e)
|
||||
|
||||
def _validate_page_watchdog(self):
|
||||
@ -1692,7 +1692,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
self._dev = VirtualWatchdog(conn)
|
||||
self._dev.model = model
|
||||
self._dev.action = action
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Watchdog parameter error"), e)
|
||||
|
||||
def _validate_page_filesystem(self):
|
||||
@ -1707,7 +1707,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
try:
|
||||
self._dev = VirtualSmartCardDevice(conn)
|
||||
self._dev.mode = mode
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Smartcard device parameter error"), e)
|
||||
|
||||
def _validate_page_usbredir(self):
|
||||
@ -1726,7 +1726,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
self._dev.host = host
|
||||
if service:
|
||||
self._dev.service = service
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("USB redirected device parameter error"),
|
||||
str(e))
|
||||
|
||||
@ -1746,7 +1746,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
for param_name, val in value_mappings.items():
|
||||
if self._dev.supports_property(param_name):
|
||||
setattr(self._dev, param_name, val)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("TPM device parameter error"), e)
|
||||
|
||||
def _validate_page_panic(self):
|
||||
@ -1764,7 +1764,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
iobase = self._dev.IOBASE_DEFAULT
|
||||
for param_name, val in value_mappings.items():
|
||||
setattr(self._dev, param_name, val)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Panic device parameter error"), e)
|
||||
|
||||
def _validate_page_controller(self):
|
||||
@ -1857,7 +1857,7 @@ class vmmAddHardware(vmmGObjectUI):
|
||||
for param_name, val in value_mappings.items():
|
||||
if self._dev.supports_property(param_name):
|
||||
setattr(self._dev, param_name, val)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("RNG device parameter error"), e)
|
||||
|
||||
|
||||
|
@ -117,7 +117,7 @@ class vmmAddStorage(vmmGObjectUI):
|
||||
try:
|
||||
default_pool.start()
|
||||
logging.info("Started pool '%s'", default_pool.get_name())
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.show_err(_("Could not start storage_pool "
|
||||
"'%s': %s") %
|
||||
(default_pool.get_name(), str(e)))
|
||||
|
@ -86,7 +86,7 @@ class vmmMeter(virtinst.progress.BaseMeter):
|
||||
def cb_wrapper(callback, asyncjob, *args, **kwargs):
|
||||
try:
|
||||
callback(asyncjob, *args, **kwargs)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
# If job is cancelled, don't report error to user.
|
||||
if (isinstance(e, libvirt.libvirtError) and
|
||||
asyncjob.can_cancel() and
|
||||
|
@ -116,7 +116,7 @@ class vmmChooseCD(vmmGObjectUI):
|
||||
|
||||
try:
|
||||
self.disk.path = path
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Invalid Media Path"), e)
|
||||
|
||||
names = self.disk.is_conflict_disk()
|
||||
|
@ -405,7 +405,7 @@ class vmmCloneVM(vmmGObjectUI):
|
||||
try:
|
||||
cd.skip_target = skip_targets
|
||||
cd.setup_original()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception("Disk target '%s' caused clone error",
|
||||
force_target)
|
||||
storage_add(str(e))
|
||||
@ -432,7 +432,7 @@ class vmmCloneVM(vmmGObjectUI):
|
||||
|
||||
cd.clone_paths = clone_path
|
||||
size = cd.original_disks[0].get_size()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception("Error setting generated path '%s'",
|
||||
clone_path)
|
||||
storage_add(str(e))
|
||||
@ -469,7 +469,7 @@ class vmmCloneVM(vmmGObjectUI):
|
||||
try:
|
||||
newpath = self.generate_clone_path_name(origpath, newname)
|
||||
row[STORAGE_INFO_NEW_PATH] = newpath
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Generating new path from clone name failed: " +
|
||||
str(e))
|
||||
|
||||
@ -592,7 +592,7 @@ class vmmCloneVM(vmmGObjectUI):
|
||||
self.clone_design.skip_target = skip_targets
|
||||
try:
|
||||
self.clone_design.clone_paths = new_disks
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
# Just log the error and go on. The UI will fail later if needed
|
||||
logging.debug("Error setting clone_paths: %s", str(e))
|
||||
|
||||
@ -695,7 +695,7 @@ class vmmCloneVM(vmmGObjectUI):
|
||||
if msg:
|
||||
raise RuntimeError(msg)
|
||||
row[NETWORK_INFO_NEW_MAC] = new
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error changing MAC address: %s") % str(e))
|
||||
return
|
||||
|
||||
@ -735,7 +735,7 @@ class vmmCloneVM(vmmGObjectUI):
|
||||
row[STORAGE_INFO_NEW_PATH] = new_path
|
||||
row[STORAGE_INFO_MANUAL_PATH] = True
|
||||
self.populate_storage_lists()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error changing storage path: %s") % str(e))
|
||||
return
|
||||
|
||||
@ -818,7 +818,7 @@ class vmmCloneVM(vmmGObjectUI):
|
||||
try:
|
||||
if not self.validate():
|
||||
return
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Uncaught error validating input: %s") % str(e))
|
||||
return
|
||||
|
||||
|
@ -99,7 +99,7 @@ class vmmConnect(vmmGObjectUI):
|
||||
# Call any API, so we detect if avahi is even available or not
|
||||
self.avahiserver.GetAPIVersion()
|
||||
logging.debug("Connected to avahi")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.dbus = None
|
||||
self.avahiserver = None
|
||||
logging.debug("Couldn't contact avahi: %s", str(e))
|
||||
@ -232,7 +232,7 @@ class vmmConnect(vmmGObjectUI):
|
||||
|
||||
sig = resint.connect("g-signal", cb)
|
||||
self.browser_sigs.append((resint, sig))
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
|
||||
def remove_service(self, interface, protocol, name, typ, domain, flags):
|
||||
@ -248,7 +248,7 @@ class vmmConnect(vmmGObjectUI):
|
||||
for row in model:
|
||||
if row[0] == name:
|
||||
model.remove(row.iter)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
|
||||
def add_conn_to_list(self, interface, protocol, name, typ, domain,
|
||||
@ -271,7 +271,7 @@ class vmmConnect(vmmGObjectUI):
|
||||
|
||||
host = self.sanitize_hostname(str(host))
|
||||
model.append([str(address), str(host), str(name)])
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
|
||||
def start_browse(self):
|
||||
|
@ -161,7 +161,7 @@ def acquire_tgt():
|
||||
"/org/gnome/KrbAuthDialog",
|
||||
"org.freedesktop.KrbAuthDialog", None)
|
||||
ret = ka.acquireTgt("(s)", "")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.info("Cannot acquire tgt" + str(e))
|
||||
ret = False
|
||||
return ret
|
||||
|
@ -281,7 +281,7 @@ class vmmConnection(vmmGObject):
|
||||
for vol in pool.get_volumes():
|
||||
try:
|
||||
ret.append(vol.get_xmlobj(refresh_if_nec=False))
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Fetching volume XML failed: %s", e)
|
||||
return ret
|
||||
self._backend.cb_fetch_all_vols = fetch_all_vols
|
||||
@ -550,7 +550,7 @@ class vmmConnection(vmmGObject):
|
||||
try:
|
||||
if vol.get_target_path() == path:
|
||||
return vol
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
# Errors can happen if the volume disappeared, bug 1092739
|
||||
logging.debug("Error looking up volume from path=%s: %s",
|
||||
path, e)
|
||||
@ -625,7 +625,7 @@ class vmmConnection(vmmGObject):
|
||||
for dev in self.list_nodedevs():
|
||||
try:
|
||||
xmlobj = dev.get_xmlobj()
|
||||
except libvirt.libvirtError, e:
|
||||
except libvirt.libvirtError as e:
|
||||
# Libvirt nodedev XML fetching can be busted
|
||||
# https://bugzilla.redhat.com/show_bug.cgi?id=1225771
|
||||
if e.get_error_code() != libvirt.VIR_ERR_NO_NODE_DEVICE:
|
||||
@ -700,12 +700,12 @@ class vmmConnection(vmmGObject):
|
||||
try:
|
||||
# Redefine new domain
|
||||
newobj = define_cb(newxml)
|
||||
except Exception, renameerr:
|
||||
except Exception as renameerr:
|
||||
try:
|
||||
logging.debug("Error defining new name %s XML",
|
||||
obj.class_name(), exc_info=True)
|
||||
newobj = define_cb(origxml)
|
||||
except Exception, fixerr:
|
||||
except Exception as fixerr:
|
||||
logging.debug("Failed to redefine original %s!",
|
||||
obj.class_name(), exc_info=True)
|
||||
raise RuntimeError(
|
||||
@ -840,7 +840,7 @@ class vmmConnection(vmmGObject):
|
||||
self._domain_lifecycle_event, None))
|
||||
self.using_domain_events = True
|
||||
logging.debug("Using domain events")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.using_domain_events = False
|
||||
logging.debug("Error registering domain events: %s", e)
|
||||
|
||||
@ -851,7 +851,7 @@ class vmmConnection(vmmGObject):
|
||||
self._domain_cb_ids.append(
|
||||
self.get_backend().domainEventRegisterAny(
|
||||
None, eventid, self._domain_xml_misc_event, None))
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error registering domain %s event: %s",
|
||||
typestr, e)
|
||||
|
||||
@ -877,7 +877,7 @@ class vmmConnection(vmmGObject):
|
||||
None, eventid, self._network_lifecycle_event, None))
|
||||
self.using_network_events = True
|
||||
logging.debug("Using network events")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.using_network_events = False
|
||||
logging.debug("Error registering network events: %s", e)
|
||||
|
||||
@ -897,7 +897,7 @@ class vmmConnection(vmmGObject):
|
||||
None, refreshid, self._storage_pool_refresh_event, None))
|
||||
self.using_storage_pool_events = True
|
||||
logging.debug("Using storage pool events")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.using_storage_pool_events = False
|
||||
logging.debug("Error registering storage pool events: %s", e)
|
||||
|
||||
@ -916,7 +916,7 @@ class vmmConnection(vmmGObject):
|
||||
|
||||
self.using_node_device_events = True
|
||||
logging.debug("Using node device events")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.using_network_events = False
|
||||
logging.debug("Error registering node device events: %s", e)
|
||||
|
||||
@ -1000,7 +1000,7 @@ class vmmConnection(vmmGObject):
|
||||
try:
|
||||
self._backend.open(self._do_creds_password)
|
||||
return True, None
|
||||
except Exception, exc:
|
||||
except Exception as exc:
|
||||
tb = "".join(traceback.format_exc())
|
||||
if isinstance(exc, libvirt.libvirtError):
|
||||
# pylint: disable=no-member
|
||||
@ -1043,7 +1043,7 @@ class vmmConnection(vmmGObject):
|
||||
# We want this before events setup to save some needless polling
|
||||
try:
|
||||
virtinst.StoragePool.build_default_pool(self.get_backend())
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Building default pool failed: %s", str(e))
|
||||
|
||||
self._add_conn_events()
|
||||
@ -1053,7 +1053,7 @@ class vmmConnection(vmmGObject):
|
||||
|
||||
try:
|
||||
self._backend.setKeepAlive(20, 1)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if (type(e) is not AttributeError and
|
||||
not util.is_error_nosupport(e)):
|
||||
raise
|
||||
@ -1085,7 +1085,7 @@ class vmmConnection(vmmGObject):
|
||||
|
||||
self.idle_add(self._change_state, is_active and
|
||||
self._STATE_ACTIVE or self._STATE_DISCONNECTED)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
is_active = False
|
||||
self._schedule_close()
|
||||
connectError = (str(e), "".join(traceback.format_exc()), False)
|
||||
@ -1311,7 +1311,7 @@ class vmmConnection(vmmGObject):
|
||||
continue
|
||||
|
||||
obj.tick(stats_update=stats_update)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception("Tick for %s failed", obj)
|
||||
if (isinstance(e, libvirt.libvirtError) and
|
||||
(getattr(e, "get_error_code")() ==
|
||||
@ -1400,7 +1400,7 @@ class vmmConnection(vmmGObject):
|
||||
self._tick(*args, **kwargs)
|
||||
except KeyboardInterrupt:
|
||||
raise
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
pass
|
||||
|
||||
if e is None:
|
||||
|
@ -690,7 +690,7 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
gdev = gdevs and gdevs[0] or None
|
||||
if gdev:
|
||||
ginfo = ConnectionInfo(self.vm.conn, gdev)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
# We can fail here if VM is destroyed: xen is a bit racy
|
||||
# and can't handle domain lookups that soon after
|
||||
logging.exception("Getting graphics console failed: %s", str(e))
|
||||
@ -733,7 +733,7 @@ class vmmConsolePages(vmmGObjectUI):
|
||||
self._refresh_enable_accel()
|
||||
|
||||
self._viewer.console_open()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception("Error connection to graphical console")
|
||||
self._activate_unavailable_page(
|
||||
_("Error connecting to graphical console") + ":\n%s" % e)
|
||||
|
@ -467,7 +467,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
guest.set_uefi_default()
|
||||
installable_arch = True
|
||||
logging.debug("UEFI found for aarch64, setting it as default.")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
installable_arch = False
|
||||
logging.debug("Error checking for aarch64 UEFI default",
|
||||
exc_info=True)
|
||||
@ -700,7 +700,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
|
||||
try:
|
||||
self._populate_conn_state()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception("Error setting create wizard conn state.")
|
||||
return self._show_startup_error(str(e))
|
||||
|
||||
@ -1733,7 +1733,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
elif pagenum == PAGE_FINISH:
|
||||
try:
|
||||
self._populate_summary()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error populating summary page: %s") %
|
||||
str(e))
|
||||
return
|
||||
@ -1767,7 +1767,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
# Generate UUID (makes customize dialog happy)
|
||||
try:
|
||||
guest.uuid = util.randomUUID(guest.conn)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error setting UUID: %s") % str(e))
|
||||
return None
|
||||
|
||||
@ -1775,7 +1775,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
try:
|
||||
if variant:
|
||||
guest.os_variant = variant
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
self.err.val_err(_("Error setting OS information."), str(e))
|
||||
return None
|
||||
|
||||
@ -1797,7 +1797,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
for_cpu=True)
|
||||
|
||||
guest.add_default_devices()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error setting up default devices:") + str(e))
|
||||
return None
|
||||
|
||||
@ -1815,7 +1815,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
return self._validate_storage_page()
|
||||
elif pagenum == PAGE_FINISH:
|
||||
return self._validate_final_page()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Uncaught error validating install "
|
||||
"parameters: %s") % str(e))
|
||||
return
|
||||
@ -1935,7 +1935,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
if not self._guest:
|
||||
return False
|
||||
self._guest.installer = installer
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(
|
||||
_("Error setting installer parameters."), e)
|
||||
|
||||
@ -1965,7 +1965,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
fsdev.source = template
|
||||
self._guest.add_device(fsdev)
|
||||
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(
|
||||
_("Error setting install media location."), e)
|
||||
|
||||
@ -1998,7 +1998,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
name = self._generate_default_name(distro, variant)
|
||||
self.widget("create-vm-name").set_text(name)
|
||||
self._guest.name = name
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Error setting default name."), e)
|
||||
|
||||
# Kind of wonky, run storage validation now, which will assign
|
||||
@ -2053,14 +2053,14 @@ class vmmCreate(vmmGObjectUI):
|
||||
# VCPUS
|
||||
try:
|
||||
self._guest.vcpus = int(cpus)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Error setting CPUs."), e)
|
||||
|
||||
# Memory
|
||||
try:
|
||||
self._guest.memory = int(mem) * 1024
|
||||
self._guest.maxmemory = int(mem) * 1024
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Error setting guest memory."), e)
|
||||
|
||||
return True
|
||||
@ -2101,7 +2101,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
if storage_enabled:
|
||||
disk = self._addstorage.validate_storage(self._guest.name,
|
||||
path=path)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Storage parameter error."), e)
|
||||
|
||||
if disk is False:
|
||||
@ -2132,7 +2132,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
if name != self._guest.name:
|
||||
try:
|
||||
self._guest.name = name
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Invalid guest name"), str(e))
|
||||
if self._is_default_storage():
|
||||
logging.debug("User changed VM name and using default "
|
||||
@ -2318,7 +2318,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
logging.debug("User requested 'customize', launching dialog")
|
||||
try:
|
||||
self._show_customize_dialog(guest)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.reset_finish_cursor()
|
||||
self.err.show_err(_("Error starting installation: ") + str(e))
|
||||
return
|
||||
@ -2471,7 +2471,7 @@ class vmmCreate(vmmGObjectUI):
|
||||
try:
|
||||
logging.debug("Install should be completed, starting VM.")
|
||||
vm.startup()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error continue install: %s") % str(e))
|
||||
|
||||
return True
|
||||
|
@ -549,7 +549,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
||||
key = Interface(self.conn.get_backend())
|
||||
key.type = Interface.INTERFACE_TYPE_ETHERNET
|
||||
key.name = name
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error creating stub interface '%s': %s",
|
||||
name, e)
|
||||
continue
|
||||
@ -907,7 +907,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
||||
elif pagenum == PAGE_DETAILS:
|
||||
return self.validate_details_page()
|
||||
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Uncaught error validating install "
|
||||
"parameters: %s") % str(e))
|
||||
return
|
||||
@ -1011,7 +1011,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
||||
iobj.validate()
|
||||
|
||||
self.interface = iobj
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(
|
||||
_("Error setting interface parameters."), e)
|
||||
|
||||
@ -1078,7 +1078,7 @@ class vmmCreateInterface(vmmGObjectUI):
|
||||
def validate_ip_info(self):
|
||||
try:
|
||||
self.build_ip_info()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error validating IP configuration: %s") %
|
||||
str(e))
|
||||
return False
|
||||
|
@ -301,7 +301,7 @@ class vmmCreateNetwork(vmmGObjectUI):
|
||||
try:
|
||||
net = self._build_xmlstub()
|
||||
net.name = self.widget("net-name").get_text()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Invalid network name"), str(e))
|
||||
|
||||
return True
|
||||
@ -823,7 +823,7 @@ class vmmCreateNetwork(vmmGObjectUI):
|
||||
|
||||
try:
|
||||
net = self._build_xmlobj()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error generating network xml: %s") % str(e))
|
||||
return
|
||||
|
||||
|
@ -398,7 +398,7 @@ class vmmCreatePool(vmmGObjectUI):
|
||||
self.finish()
|
||||
else:
|
||||
notebook.next_page()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Uncaught error validating input: %s") % str(e))
|
||||
return
|
||||
|
||||
@ -495,7 +495,7 @@ class vmmCreatePool(vmmGObjectUI):
|
||||
else:
|
||||
self._pool = self._make_stub_pool()
|
||||
self._pool.name = self.get_config_name()
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
return self.err.val_err(_("Pool Parameter Error"), e)
|
||||
|
||||
return True
|
||||
@ -525,7 +525,7 @@ class vmmCreatePool(vmmGObjectUI):
|
||||
self._pool.source_name = source_name
|
||||
|
||||
self._pool.validate()
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
return self.err.val_err(_("Pool Parameter Error"), e)
|
||||
|
||||
buildval = self.widget("pool-build").get_active()
|
||||
|
@ -289,7 +289,7 @@ class vmmCreateVolume(vmmGObjectUI):
|
||||
try:
|
||||
if not self.validate():
|
||||
return
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.show_err(_("Uncaught error validating input: %s") % str(e))
|
||||
return
|
||||
|
||||
@ -337,7 +337,7 @@ class vmmCreateVolume(vmmGObjectUI):
|
||||
if fmt:
|
||||
self.vol.format = fmt
|
||||
self.vol.validate()
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
return self.val_err(_("Volume Parameter Error"), e)
|
||||
return True
|
||||
|
||||
|
@ -176,7 +176,7 @@ class vmmDeleteDialog(vmmGObjectUI):
|
||||
logging.debug("Deleting path: %s", path)
|
||||
meter.start(text=_("Deleting path '%s'") % path)
|
||||
self._async_delete_path(conn, path, meter)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
storage_errors.append((str(e),
|
||||
"".join(traceback.format_exc())))
|
||||
meter.end(0)
|
||||
@ -184,7 +184,7 @@ class vmmDeleteDialog(vmmGObjectUI):
|
||||
logging.debug("Removing VM '%s'", self.vm.get_name())
|
||||
self.vm.delete()
|
||||
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
error = (_("Error deleting virtual machine '%s': %s") %
|
||||
(self.vm.get_name(), str(e)))
|
||||
details = "".join(traceback.format_exc())
|
||||
@ -390,7 +390,7 @@ def do_we_default(conn, vm_name, vol, path, ro, shared, is_media):
|
||||
namestr = append_str(namestr, name, delim="\n- ")
|
||||
info = append_str(info, _("Storage is in use by the following "
|
||||
"virtual machines:\n- %s " % namestr))
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception("Failed checking disk conflict: %s", str(e))
|
||||
|
||||
return (not info, info)
|
||||
|
@ -1226,7 +1226,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
self.refresh_panic_page()
|
||||
else:
|
||||
pagetype = -1
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error refreshing hardware page: %s") % str(e))
|
||||
# Don't return, we want the rest of the bits to run regardless
|
||||
|
||||
@ -1415,7 +1415,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
self.addhw = vmmAddHardware(self.vm, self.is_customize_dialog)
|
||||
|
||||
self.addhw.show(self.topwin)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err((_("Error launching hardware dialog: %s") %
|
||||
str(e)))
|
||||
|
||||
@ -1496,7 +1496,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
ignore = src
|
||||
try:
|
||||
return self._take_screenshot()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error taking screenshot: %s") % str(e))
|
||||
|
||||
def control_vm_usb_redirection(self, src):
|
||||
@ -1833,7 +1833,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
def _eject_media(self, disk):
|
||||
try:
|
||||
self._change_storage_media(disk, None)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err((_("Error disconnecting media: %s") % e))
|
||||
|
||||
def _insert_media(self, disk):
|
||||
@ -1854,7 +1854,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
dialog.disk = disk
|
||||
|
||||
dialog.show(self.topwin)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err((_("Error launching media dialog: %s") % e))
|
||||
return
|
||||
|
||||
@ -1920,7 +1920,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
ret = self.config_hostdev_apply(key)
|
||||
else:
|
||||
ret = False
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.show_err(_("Error apply changes: %s") % e)
|
||||
|
||||
if ret is not False:
|
||||
@ -2052,7 +2052,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
auto = self.widget("boot-autostart")
|
||||
try:
|
||||
self.vm.set_autostart(auto.get_active())
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(
|
||||
(_("Error changing autostart value: %s") % str(e)))
|
||||
return False
|
||||
@ -2289,7 +2289,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
# Define the change
|
||||
try:
|
||||
self.vm.remove_device(devobj)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error Removing Device: %s") % str(e))
|
||||
return
|
||||
|
||||
@ -2298,7 +2298,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
try:
|
||||
if self.vm.is_active():
|
||||
self.vm.detach_device(devobj)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Device could not be hotUNplugged: %s", str(e))
|
||||
detach_err = (str(e), "".join(traceback.format_exc()))
|
||||
|
||||
@ -2328,7 +2328,7 @@ class vmmDetails(vmmGObjectUI):
|
||||
try:
|
||||
if self.is_visible():
|
||||
self.vm.ensure_latest_xml()
|
||||
except libvirt.libvirtError, e:
|
||||
except libvirt.libvirtError as e:
|
||||
if util.exception_is_libvirt_error(e, "VIR_ERR_NO_DOMAIN"):
|
||||
self.close()
|
||||
return
|
||||
|
@ -1538,7 +1538,7 @@ class vmmDomain(vmmLibvirtObject):
|
||||
if self._has_managed_save is None:
|
||||
try:
|
||||
self._has_managed_save = self._backend.hasManagedSaveImage(0)
|
||||
except libvirt.libvirtError, e:
|
||||
except libvirt.libvirtError as e:
|
||||
if not util.exception_is_libvirt_error(e, "VIR_ERR_NO_DOMAIN"):
|
||||
raise
|
||||
return False
|
||||
@ -1853,7 +1853,7 @@ class vmmDomain(vmmLibvirtObject):
|
||||
if io:
|
||||
rx += io[0]
|
||||
tx += io[4]
|
||||
except libvirt.libvirtError, err:
|
||||
except libvirt.libvirtError as err:
|
||||
if util.is_error_nosupport(err):
|
||||
logging.debug("Net stats not supported: %s", err)
|
||||
self._stats_net_supported = False
|
||||
@ -1903,7 +1903,7 @@ class vmmDomain(vmmLibvirtObject):
|
||||
if io:
|
||||
rd += io[1]
|
||||
wr += io[3]
|
||||
except libvirt.libvirtError, err:
|
||||
except libvirt.libvirtError as err:
|
||||
if util.is_error_nosupport(err):
|
||||
logging.debug("Disk stats not supported: %s", err)
|
||||
self._stats_disk_supported = False
|
||||
@ -1935,7 +1935,7 @@ class vmmDomain(vmmLibvirtObject):
|
||||
secs = 5
|
||||
self._backend.setMemoryStatsPeriod(secs,
|
||||
libvirt.VIR_DOMAIN_AFFECT_LIVE)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error setting memstats period: %s", e)
|
||||
|
||||
def _sample_mem_stats(self):
|
||||
@ -1958,7 +1958,7 @@ class vmmDomain(vmmLibvirtObject):
|
||||
|
||||
if "unused" in stats:
|
||||
curmem = max(0, totalmem - stats.get("unused", totalmem))
|
||||
except libvirt.libvirtError, err:
|
||||
except libvirt.libvirtError as err:
|
||||
logging.error("Error reading mem stats: %s", err)
|
||||
|
||||
pcentCurrMem = (curmem / float(totalmem)) * 100
|
||||
|
@ -383,7 +383,7 @@ class vmmEngine(vmmGObject):
|
||||
ignore1, ignore2, conn, kwargs = self._tick_queue.get()
|
||||
try:
|
||||
conn.tick_from_engine(**kwargs)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
tb = "".join(traceback.format_exc())
|
||||
error_msg = (_("Error polling connection '%s': %s")
|
||||
% (conn.get_uri(), e))
|
||||
@ -717,7 +717,7 @@ class vmmEngine(vmmGObject):
|
||||
if self.windowAbout is None:
|
||||
self.windowAbout = vmmAbout()
|
||||
self.windowAbout.show()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
src.err.show_err(_("Error launching 'About' dialog: %s") % str(e))
|
||||
|
||||
def _get_preferences(self):
|
||||
@ -731,7 +731,7 @@ class vmmEngine(vmmGObject):
|
||||
def _do_show_preferences(self, src):
|
||||
try:
|
||||
self._get_preferences().show(src.topwin)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
src.err.show_err(_("Error launching preferences: %s") % str(e))
|
||||
|
||||
def _get_host_dialog(self, uri):
|
||||
@ -752,7 +752,7 @@ class vmmEngine(vmmGObject):
|
||||
def _do_show_host(self, src, uri):
|
||||
try:
|
||||
self._get_host_dialog(uri).show()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
src.err.show_err(_("Error launching host dialog: %s") % str(e))
|
||||
|
||||
|
||||
@ -778,7 +778,7 @@ class vmmEngine(vmmGObject):
|
||||
def _do_show_connect(self, src, reset_state=True):
|
||||
try:
|
||||
self._get_connect_dialog().show(src.topwin, reset_state)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
src.err.show_err(_("Error launching connect dialog: %s") % str(e))
|
||||
|
||||
def _do_edit_connect(self, src, connection):
|
||||
@ -830,7 +830,7 @@ class vmmEngine(vmmGObject):
|
||||
details.activate_default_page()
|
||||
|
||||
details.show()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
src.err.show_err(_("Error launching details: %s") % str(e))
|
||||
|
||||
def _do_show_vm(self, src, uri, connkey):
|
||||
@ -882,7 +882,7 @@ class vmmEngine(vmmGObject):
|
||||
try:
|
||||
manager = self.get_manager()
|
||||
manager.show()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
if not src:
|
||||
raise
|
||||
src.err.show_err(_("Error launching manager: %s") % str(e))
|
||||
@ -901,7 +901,7 @@ class vmmEngine(vmmGObject):
|
||||
def _do_show_create(self, src, uri):
|
||||
try:
|
||||
self._get_create_dialog().show(src.topwin, uri)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
src.err.show_err(_("Error launching manager: %s") % str(e))
|
||||
|
||||
def _do_show_migrate(self, src, uri, connkey):
|
||||
@ -913,7 +913,7 @@ class vmmEngine(vmmGObject):
|
||||
self.windowMigrate = vmmMigrateDialog(self)
|
||||
|
||||
self.windowMigrate.show(src.topwin, vm)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
src.err.show_err(_("Error launching migrate dialog: %s") % str(e))
|
||||
|
||||
def _do_show_clone(self, src, uri, connkey):
|
||||
@ -929,7 +929,7 @@ class vmmEngine(vmmGObject):
|
||||
clone_window.set_orig_vm(orig_vm)
|
||||
|
||||
clone_window.show(src.topwin)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
src.err.show_err(_("Error setting clone parameters: %s") % str(e))
|
||||
|
||||
def _do_refresh_inspection(self, src_ignore, uri, connkey):
|
||||
@ -1109,7 +1109,7 @@ class vmmEngine(vmmGObject):
|
||||
|
||||
try:
|
||||
vm.abort_job()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception("Error cancelling save job")
|
||||
asyncjob.show_warning(_("Error cancelling save job: %s") % str(e))
|
||||
return
|
||||
@ -1182,7 +1182,7 @@ class vmmEngine(vmmGObject):
|
||||
try:
|
||||
vm.remove_saved_image()
|
||||
self._do_run_domain(src, uri, connkey)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
src.err.show_err(_("Error removing domain state: %s")
|
||||
% str(e))
|
||||
|
||||
@ -1250,5 +1250,5 @@ class vmmEngine(vmmGObject):
|
||||
if not self.delete_dialog:
|
||||
self.delete_dialog = vmmDeleteDialog()
|
||||
self.delete_dialog.show(vm, src.topwin)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
src.err.show_err(_("Error launching delete dialog: %s") % str(e))
|
||||
|
@ -321,7 +321,7 @@ class vmmFSDetails(vmmGObjectUI):
|
||||
self._dev.format = fsformat
|
||||
if wrpolicy:
|
||||
self._dev.wrpolicy = wrpolicy
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Filesystem parameter error"), e)
|
||||
|
||||
def _browse_file(self, textent, isdir=False):
|
||||
|
@ -407,7 +407,7 @@ class vmmHost(vmmGObjectUI):
|
||||
if self.addnet is None:
|
||||
self.addnet = vmmCreateNetwork(self.conn)
|
||||
self.addnet.show(self.topwin)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error launching network wizard: %s") % str(e))
|
||||
|
||||
def net_apply(self):
|
||||
@ -450,7 +450,7 @@ class vmmHost(vmmGObjectUI):
|
||||
dialog_type=Gtk.MessageType.INFO)
|
||||
|
||||
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error changing network settings: %s") % str(e))
|
||||
return
|
||||
finally:
|
||||
@ -518,7 +518,7 @@ class vmmHost(vmmGObjectUI):
|
||||
try:
|
||||
net = self.conn.get_net(connkey)
|
||||
self.populate_net_state(net)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
self.set_net_error_page(_("Error selecting network: %s") % e)
|
||||
finally:
|
||||
@ -754,7 +754,7 @@ class vmmHost(vmmGObjectUI):
|
||||
if self.addinterface is None:
|
||||
self.addinterface = vmmCreateInterface(self.conn)
|
||||
self.addinterface.show(self.topwin)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error launching interface wizard: %s") %
|
||||
str(e))
|
||||
|
||||
@ -781,7 +781,7 @@ class vmmHost(vmmGObjectUI):
|
||||
interface.get_name())
|
||||
try:
|
||||
interface.set_startmode(newmode)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error setting interface startmode: %s") %
|
||||
str(e))
|
||||
return
|
||||
@ -807,7 +807,7 @@ class vmmHost(vmmGObjectUI):
|
||||
|
||||
try:
|
||||
self.populate_interface_state(connkey)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
self.set_interface_error_page(_("Error selecting interface: %s") %
|
||||
e)
|
||||
@ -859,7 +859,7 @@ class vmmHost(vmmGObjectUI):
|
||||
used_by = None
|
||||
try:
|
||||
used_by = vmmCreateInterface.iface_in_use_by(self.conn, name)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error looking up iface usage: %s", e)
|
||||
self.widget("interface-inuseby").set_text(used_by or "-")
|
||||
|
||||
|
@ -278,7 +278,7 @@ class vmmLibvirtObject(vmmGObject):
|
||||
# status = None forces a signal to be emitted
|
||||
self.__status = None
|
||||
self._refresh_status()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
# If we hit an exception here, it's often that the object
|
||||
# disappeared, so request the poll loop to be updated
|
||||
logging.debug("Error refreshing %s from events: %s", self, e)
|
||||
|
@ -744,7 +744,7 @@ class vmmManager(vmmGObjectUI):
|
||||
|
||||
desc = vm.get_description()
|
||||
row[ROW_HINT] = util.xml_escape(desc)
|
||||
except libvirt.libvirtError, e:
|
||||
except libvirt.libvirtError as e:
|
||||
if util.exception_is_libvirt_error(e, "VIR_ERR_NO_DOMAIN"):
|
||||
return
|
||||
raise
|
||||
|
@ -376,7 +376,7 @@ class vmmMigrateDialog(vmmGObjectUI):
|
||||
uri = self.widget("migrate-tunnel-uri").get_text()
|
||||
else:
|
||||
uri = self._build_regular_migrate_uri()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
details = "".join(traceback.format_exc())
|
||||
self.err.show_err((_("Uncaught error validating input: %s") %
|
||||
str(e)),
|
||||
@ -409,7 +409,7 @@ class vmmMigrateDialog(vmmGObjectUI):
|
||||
|
||||
try:
|
||||
vm.abort_job()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception("Error cancelling migrate job")
|
||||
asyncjob.show_warning(_("Error cancelling migrate job: %s") % e)
|
||||
return
|
||||
|
@ -363,7 +363,7 @@ class vmmNetworkList(vmmGObjectUI):
|
||||
try:
|
||||
netobj.start()
|
||||
logging.info("Started network '%s'", devname)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.show_err(_("Could not start virtual network "
|
||||
"'%s': %s") % (devname, str(e)))
|
||||
|
||||
@ -388,7 +388,7 @@ class vmmNetworkList(vmmGObjectUI):
|
||||
net.virtualport.typeid = vport_typeid or None
|
||||
net.virtualport.typeidversion = vport_idver or None
|
||||
net.virtualport.instanceid = vport_instid or None
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Error with network parameters."), e)
|
||||
|
||||
# Make sure there is no mac address collision
|
||||
|
@ -61,7 +61,7 @@ def check_packagekit(parent, errbox, packages):
|
||||
packagekit_install(parent, packages)
|
||||
else:
|
||||
logging.debug("Nothing to install")
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
# PackageKit frontend should report an error for us, so just log
|
||||
# the actual error
|
||||
logging.debug("Error talking to PackageKit: %s", str(e), exc_info=True)
|
||||
|
@ -411,7 +411,7 @@ class vmmSerialConsole(vmmGObject):
|
||||
self.console.open(self.lookup_dev(), self.terminal)
|
||||
self.box.set_current_page(0)
|
||||
return True
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception("Error opening serial console")
|
||||
self.show_error(_("Error connecting to text console: %s") % e)
|
||||
try:
|
||||
|
@ -222,7 +222,7 @@ class vmmSnapshotPage(vmmGObjectUI):
|
||||
|
||||
try:
|
||||
snapshots = self.vm.list_snapshots()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
self._set_error_page(_("Error refreshing snapshot list: %s") %
|
||||
str(e))
|
||||
@ -480,7 +480,7 @@ class vmmSnapshotPage(vmmGObjectUI):
|
||||
newsnap.validate()
|
||||
newsnap.get_xml_config()
|
||||
return newsnap
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
return self.err.val_err(_("Error validating snapshot: %s") % e)
|
||||
|
||||
def _get_screenshot_data_for_save(self):
|
||||
@ -663,6 +663,6 @@ class vmmSnapshotPage(vmmGObjectUI):
|
||||
|
||||
try:
|
||||
self._set_snapshot_state(snap[0])
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
self._set_error_page(_("Error selecting snapshot: %s") % str(e))
|
||||
|
@ -509,7 +509,7 @@ class vmmStorageList(vmmGObjectUI):
|
||||
|
||||
try:
|
||||
self._populate_pool_state(connkey)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception(e)
|
||||
self._set_storage_error_page(_("Error selecting pool: %s") % e)
|
||||
self._disable_pool_apply()
|
||||
@ -616,7 +616,7 @@ class vmmStorageList(vmmGObjectUI):
|
||||
self._addpool = vmmCreatePool(self.conn)
|
||||
self._addpool.connect("pool-created", self._pool_created)
|
||||
self._addpool.show(self.topwin)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error launching pool wizard: %s") % str(e))
|
||||
|
||||
def _pool_delete(self, src):
|
||||
@ -660,7 +660,7 @@ class vmmStorageList(vmmGObjectUI):
|
||||
if EDIT_POOL_NAME in self._active_edits:
|
||||
pool.define_name(self.widget("pool-name-entry").get_text())
|
||||
self.idle_add(self._populate_pools)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error changing pool settings: %s") % str(e))
|
||||
return
|
||||
|
||||
@ -699,7 +699,7 @@ class vmmStorageList(vmmGObjectUI):
|
||||
self._addvol.set_modal(self.topwin.get_modal())
|
||||
self._addvol.set_name_hint(self._name_hint)
|
||||
self._addvol.show(self.topwin)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self.err.show_err(_("Error launching volume wizard: %s") % str(e))
|
||||
|
||||
def _vol_delete(self, src_ignore):
|
||||
|
@ -47,7 +47,7 @@ class vmmStorageVolume(vmmLibvirtObject):
|
||||
def _XMLDesc(self, flags):
|
||||
try:
|
||||
return self._backend.XMLDesc(flags)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("XMLDesc for vol=%s failed: %s",
|
||||
self._backend.key(), e)
|
||||
raise
|
||||
|
@ -419,7 +419,7 @@ class VNCViewer(Viewer):
|
||||
|
||||
seq = GtkVnc.GrabSequence.new(keys)
|
||||
self._display.set_grab_keys(seq)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error when getting the grab keys combination: %s",
|
||||
str(e))
|
||||
|
||||
@ -473,7 +473,7 @@ class VNCViewer(Viewer):
|
||||
sock = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
sock.connect(self._ginfo.gsocket)
|
||||
self._sockfd = sock
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
raise RuntimeError(_("Error opening socket path '%s': %s") %
|
||||
(self._ginfo.gsocket, e))
|
||||
|
||||
@ -685,7 +685,7 @@ class SpiceViewer(Viewer):
|
||||
|
||||
seq = SpiceClientGtk.GrabSequence.new(keys)
|
||||
self._display.set_grab_keys(seq)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error when getting the grab keys combination: %s",
|
||||
str(e))
|
||||
|
||||
|
@ -370,7 +370,7 @@ class ovf_parser(parser_class):
|
||||
|
||||
try:
|
||||
return _xml_parse_wrapper(xml, parse_cb)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error parsing OVF XML: %s", str(e))
|
||||
|
||||
return False
|
||||
|
@ -83,7 +83,7 @@ class _VMXFile(object):
|
||||
try:
|
||||
lineobj = _VMXLine(line)
|
||||
self.lines.append(lineobj)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
raise Exception(_("Syntax error at line %d: %s\n%s") %
|
||||
(len(self.lines) + 1, line.strip(), e))
|
||||
|
||||
|
@ -196,7 +196,7 @@ def setupLogging(appname, debug_stdout, do_quiet, cli_app=True):
|
||||
|
||||
try:
|
||||
os.makedirs(vi_dir, 0751)
|
||||
except IOError, e:
|
||||
except IOError as e:
|
||||
raise RuntimeError("Could not create directory %s: %s" %
|
||||
(vi_dir, e))
|
||||
|
||||
@ -204,7 +204,7 @@ def setupLogging(appname, debug_stdout, do_quiet, cli_app=True):
|
||||
os.path.exists(logfile) and
|
||||
not os.access(logfile, os.W_OK)):
|
||||
raise RuntimeError("No write access to logfile %s" % logfile)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.warning("Error setting up logfile: %s", e)
|
||||
logfile = None
|
||||
|
||||
@ -473,7 +473,7 @@ def connect_console(guest, consolecb, wait):
|
||||
# If we connected the console, wait for it to finish
|
||||
try:
|
||||
os.waitpid(child, 0)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
logging.debug("waitpid: %s: %s", e.errno, e.message)
|
||||
|
||||
|
||||
@ -1207,7 +1207,7 @@ class VirtCLIParser(object):
|
||||
self.guest.add_child(obj)
|
||||
|
||||
ret += util.listify(objs)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Exception parsing inst=%s optstr=%s",
|
||||
inst, self.optstr, exc_info=True)
|
||||
fail(_("Error: --%(cli_arg_name)s %(options)s: %(err)s") %
|
||||
@ -1238,7 +1238,7 @@ class VirtCLIParser(object):
|
||||
if valid:
|
||||
ret.append(inst)
|
||||
self._check_leftover_opts(optdict)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Exception parsing inst=%s optstr=%s",
|
||||
inst, self.optstr, exc_info=True)
|
||||
fail(_("Error: --%(cli_arg_name)s %(options)s: %(err)s") %
|
||||
@ -1943,7 +1943,7 @@ class ParserDisk(VirtCLIParser):
|
||||
return None
|
||||
try:
|
||||
return float(val)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
fail(_("Improper value for 'size': %s") % str(e))
|
||||
|
||||
def convert_perms(val):
|
||||
|
@ -105,7 +105,7 @@ class Cloner(object):
|
||||
Guest.validate_name(self.conn, name,
|
||||
check_collision=not self.replace,
|
||||
validate=False)
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
raise ValueError(_("Invalid name for new guest: %s") % e)
|
||||
|
||||
self._clone_name = name
|
||||
@ -115,7 +115,7 @@ class Cloner(object):
|
||||
def set_clone_uuid(self, uuid):
|
||||
try:
|
||||
util.validate_uuid(uuid)
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
raise ValueError(_("Invalid uuid for new guest: %s") % e)
|
||||
|
||||
if util.vm_uuid_collision(self.conn, uuid):
|
||||
@ -147,7 +147,7 @@ class Cloner(object):
|
||||
disk.set_vol_install(vol_install)
|
||||
disk.validate()
|
||||
disklist.append(disk)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error setting clone path.", exc_info=True)
|
||||
raise ValueError(_("Could not use path '%s' for cloning: %s") %
|
||||
(path, str(e)))
|
||||
@ -486,7 +486,7 @@ class Cloner(object):
|
||||
dst_dev.setup(meter=meter)
|
||||
if self._nvram_disk:
|
||||
self._nvram_disk.setup(meter=meter)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Duplicate failed: %s", str(e))
|
||||
if dom:
|
||||
dom.undefine()
|
||||
@ -580,7 +580,7 @@ class Cloner(object):
|
||||
if newd.wants_storage_creation():
|
||||
raise ValueError(_("Disk path '%s' does not exist.") %
|
||||
newd.path)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Exception creating clone disk objects",
|
||||
exc_info=True)
|
||||
raise ValueError(_("Could not determine original disk "
|
||||
|
@ -238,7 +238,7 @@ class VirtualConnection(object):
|
||||
try:
|
||||
xml = vol.XMLDesc(0)
|
||||
ret.append(StorageVolume(weakref.ref(self), parsexml=xml))
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Fetching volume XML failed: %s", e)
|
||||
|
||||
if self.cache_object_fetch:
|
||||
|
@ -212,7 +212,7 @@ class VirtualDisk(VirtualDevice):
|
||||
try:
|
||||
# Get UID for string name
|
||||
uid = pwd.getpwnam(username)[2]
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error looking up username: %s", str(e))
|
||||
return []
|
||||
|
||||
@ -316,7 +316,7 @@ class VirtualDisk(VirtualDevice):
|
||||
|
||||
logging.debug("setfacl failed, trying old fashioned way")
|
||||
fix_perms(dirname, useacl)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
errdict[dirname] = str(e)
|
||||
|
||||
return errdict
|
||||
@ -785,7 +785,7 @@ class VirtualDisk(VirtualDevice):
|
||||
parent_pool = conn.storagePoolLookupByName(self.source_pool)
|
||||
vol_object = parent_pool.storageVolLookupByName(
|
||||
self.source_volume)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
self._source_volume_err = str(e)
|
||||
logging.debug("Error fetching source pool=%s vol=%s",
|
||||
self.source_pool, self.source_volume, exc_info=True)
|
||||
|
@ -55,7 +55,7 @@ def _lookup_vol_by_path(conn, path):
|
||||
vol = conn.storageVolLookupByPath(path)
|
||||
vol.info()
|
||||
return vol, None
|
||||
except libvirt.libvirtError, e:
|
||||
except libvirt.libvirtError as e:
|
||||
if (hasattr(libvirt, "VIR_ERR_NO_STORAGE_VOL") and
|
||||
e.get_error_code() != libvirt.VIR_ERR_NO_STORAGE_VOL):
|
||||
raise
|
||||
@ -123,7 +123,7 @@ def check_if_path_managed(conn, path):
|
||||
vol = _lookup_vol_by_basename(pool, path)
|
||||
except:
|
||||
pass
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
vol = None
|
||||
pool = None
|
||||
verr = str(e)
|
||||
@ -475,7 +475,7 @@ class CloneStorageCreator(_StorageCreator):
|
||||
i += s
|
||||
if i < size_bytes:
|
||||
meter.update(i)
|
||||
except OSError, e:
|
||||
except OSError as e:
|
||||
raise RuntimeError(_("Error cloning diskimage %s to %s: %s") %
|
||||
(self._input_path, self._output_path, str(e)))
|
||||
finally:
|
||||
|
@ -187,7 +187,7 @@ class DistroInstaller(Installer):
|
||||
dev.validate()
|
||||
|
||||
val = dev.path
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error validating install location", exc_info=True)
|
||||
raise ValueError(_("Validating install media '%s' failed: %s") %
|
||||
(str(val), e))
|
||||
@ -209,7 +209,7 @@ class DistroInstaller(Installer):
|
||||
try:
|
||||
try:
|
||||
fetcher.prepareLocation()
|
||||
except ValueError, e:
|
||||
except ValueError as e:
|
||||
logging.debug("Error preparing install location",
|
||||
exc_info=True)
|
||||
raise ValueError(_("Invalid install location: ") + str(e))
|
||||
|
@ -85,7 +85,7 @@ class Guest(XMLBuilder):
|
||||
|
||||
logging.info("Undefining guest '%s'", name)
|
||||
vm.undefine()
|
||||
except libvirt.libvirtError, e:
|
||||
except libvirt.libvirtError as e:
|
||||
raise RuntimeError(_("Could not remove old vm '%s': %s") %
|
||||
(str(e)))
|
||||
|
||||
@ -438,7 +438,7 @@ class Guest(XMLBuilder):
|
||||
try:
|
||||
logging.debug("XML fetched from libvirt object:\n%s",
|
||||
self.domain.XMLDesc(0))
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error fetching XML from libvirt object: %s", e)
|
||||
|
||||
|
||||
@ -451,7 +451,7 @@ class Guest(XMLBuilder):
|
||||
|
||||
try:
|
||||
self.domain.setAutostart(True)
|
||||
except libvirt.libvirtError, e:
|
||||
except libvirt.libvirtError as e:
|
||||
if util.is_error_nosupport(e):
|
||||
logging.warn("Could not set autostart flag: libvirt "
|
||||
"connection does not support autostart.")
|
||||
@ -527,7 +527,7 @@ class Guest(XMLBuilder):
|
||||
os.unlink(disk.path)
|
||||
|
||||
meter.end(0)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Failed to remove disk '%s'",
|
||||
name, exc_info=True)
|
||||
logging.error("Failed to remove disk '%s': %s", name, e)
|
||||
|
@ -117,7 +117,7 @@ def _default_keymap():
|
||||
logging.debug("Found keymap=%s in %s", kt, path)
|
||||
break
|
||||
logging.debug("Didn't find keymap in '%s'", path)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error parsing '%s': %s", path, str(e))
|
||||
|
||||
if kt is None:
|
||||
|
@ -254,21 +254,21 @@ class Interface(XMLBuilder):
|
||||
|
||||
try:
|
||||
iface = self.conn.interfaceDefineXML(xml, 0)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
raise RuntimeError(_("Could not define interface: %s") % str(e))
|
||||
|
||||
errmsg = None
|
||||
if create and not errmsg:
|
||||
try:
|
||||
iface.create(0)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
errmsg = _("Could not create interface: %s") % str(e)
|
||||
|
||||
if errmsg:
|
||||
# Try and clean up the leftover pool
|
||||
try:
|
||||
iface.undefine()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error cleaning up interface after failure: " +
|
||||
"%s" % str(e))
|
||||
raise RuntimeError(errmsg)
|
||||
|
@ -35,7 +35,7 @@ def _new_poll_helper(origmap, typename, listfunc, buildfunc):
|
||||
|
||||
try:
|
||||
objs = listfunc()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Unable to list all %ss: %s", typename, e)
|
||||
|
||||
for obj in objs:
|
||||
@ -75,11 +75,11 @@ def _old_poll_helper(origmap, typename,
|
||||
|
||||
try:
|
||||
newActiveNames = active_list()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Unable to list active %ss: %s", typename, e)
|
||||
try:
|
||||
newInactiveNames = inactive_list()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Unable to list inactive %ss: %s", typename, e)
|
||||
|
||||
def check_obj(name):
|
||||
@ -89,7 +89,7 @@ def _old_poll_helper(origmap, typename,
|
||||
if connkey not in origmap:
|
||||
try:
|
||||
obj = lookup_func(name)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Could not fetch %s '%s': %s",
|
||||
typename, connkey, e)
|
||||
return
|
||||
@ -217,12 +217,12 @@ def _old_fetch_vms(backend, origmap, build_func):
|
||||
|
||||
try:
|
||||
newActiveIDs = backend.listDomainsID()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Unable to list active domains: %s", e)
|
||||
|
||||
try:
|
||||
newInactiveNames = backend.listDefinedDomains()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.exception("Unable to list inactive domains: %s", e)
|
||||
|
||||
def add_vm(vm):
|
||||
|
@ -160,7 +160,7 @@ class StoragePool(_StorageObject):
|
||||
|
||||
try:
|
||||
xml = conn.findStoragePoolSources(pool_type, source_xml, 0)
|
||||
except libvirt.libvirtError, e:
|
||||
except libvirt.libvirtError as e:
|
||||
if util.is_error_nosupport(e):
|
||||
return []
|
||||
raise
|
||||
@ -228,7 +228,7 @@ class StoragePool(_StorageObject):
|
||||
defpool.install(build=True, create=True, autostart=True)
|
||||
conn.clear_cache(pools=True)
|
||||
return defpool
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
raise RuntimeError(
|
||||
_("Couldn't create default storage pool '%s': %s") %
|
||||
(path, str(e)))
|
||||
@ -529,33 +529,33 @@ class StoragePool(_StorageObject):
|
||||
|
||||
try:
|
||||
pool = self.conn.storagePoolDefineXML(xml, 0)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
raise RuntimeError(_("Could not define storage pool: %s") % str(e))
|
||||
|
||||
errmsg = None
|
||||
if build:
|
||||
try:
|
||||
pool.build(libvirt.VIR_STORAGE_POOL_BUILD_NEW)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
errmsg = _("Could not build storage pool: %s") % str(e)
|
||||
|
||||
if create and not errmsg:
|
||||
try:
|
||||
pool.create(0)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
errmsg = _("Could not start storage pool: %s") % str(e)
|
||||
|
||||
if autostart and not errmsg:
|
||||
try:
|
||||
pool.setAutostart(True)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
errmsg = _("Could not set pool autostart flag: %s") % str(e)
|
||||
|
||||
if errmsg:
|
||||
# Try and clean up the leftover pool
|
||||
try:
|
||||
pool.undefine()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error cleaning up pool after failure: " +
|
||||
"%s" % str(e))
|
||||
raise RuntimeError(errmsg)
|
||||
@ -846,7 +846,7 @@ class StorageVolume(_StorageObject):
|
||||
logging.debug("Storage volume '%s' install complete.",
|
||||
self.name)
|
||||
return vol
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("Error creating storage volume", exc_info=True)
|
||||
raise RuntimeError("Couldn't create storage volume "
|
||||
"'%s': '%s'" % (self.name, str(e)))
|
||||
|
@ -56,13 +56,13 @@ def _get_flag(flag_name):
|
||||
def _try_command(func, run_args, check_all_error=False):
|
||||
try:
|
||||
func(*run_args)
|
||||
except libvirt.libvirtError, e:
|
||||
except libvirt.libvirtError as e:
|
||||
if util.is_error_nosupport(e):
|
||||
return False
|
||||
|
||||
if check_all_error:
|
||||
return False
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
# Other python exceptions likely mean the bindings are horked
|
||||
return False
|
||||
return True
|
||||
|
@ -83,7 +83,7 @@ class _URLFetcher(object):
|
||||
|
||||
try:
|
||||
urlobj, size = self._grabber(url)
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
raise ValueError(_("Couldn't acquire file %s: %s") %
|
||||
(url, str(e)))
|
||||
|
||||
@ -182,7 +182,7 @@ class _HTTPURLFetcher(_URLFetcher):
|
||||
try:
|
||||
response = requests.head(url, allow_redirects=True)
|
||||
response.raise_for_status()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
logging.debug("HTTP hasFile request failed: %s", str(e))
|
||||
return False
|
||||
return True
|
||||
@ -224,7 +224,7 @@ class _FTPURLFetcher(_URLFetcher):
|
||||
self._ftp = ftplib.FTP()
|
||||
self._ftp.connect(parsed.hostname, parsed.port)
|
||||
self._ftp.login()
|
||||
except Exception, e:
|
||||
except Exception as e:
|
||||
raise ValueError(_("Opening URL %s failed: %s.") %
|
||||
(self.location, str(e)))
|
||||
|
||||
@ -259,7 +259,7 @@ class _FTPURLFetcher(_URLFetcher):
|
||||
except ftplib.all_errors:
|
||||
# If it's a dir
|
||||
self._ftp.cwd(path)
|
||||
except ftplib.all_errors, e:
|
||||
except ftplib.all_errors as e:
|
||||
logging.debug("FTP hasFile: couldn't access %s: %s",
|
||||
url, str(e))
|
||||
return False
|
||||
@ -707,14 +707,14 @@ class GenericDistro(Distro):
|
||||
self._getTreeinfoMedia("kernel"),
|
||||
self._getTreeinfoMedia("initrd"))
|
||||
except (ConfigParser.NoSectionError,
|
||||
ConfigParser.NoOptionError), e:
|
||||
ConfigParser.NoOptionError) as e:
|
||||
logging.debug(e)
|
||||
|
||||
if self.treeinfo.has_section(isoSection):
|
||||
try:
|
||||
self._valid_iso_path = self.treeinfo.get(isoSection,
|
||||
"boot.iso")
|
||||
except ConfigParser.NoOptionError, e:
|
||||
except ConfigParser.NoOptionError as e:
|
||||
logging.debug(e)
|
||||
|
||||
if self.type == "xen":
|
||||
|
Loading…
Reference in New Issue
Block a user