virtinst: Run register_libvirt_error_handler on import

We basically want this everywhere, and transparently, so run it on
import like we do for gettext setup
This commit is contained in:
Cole Robinson 2019-06-07 16:56:57 -04:00
parent ca10e4094b
commit 7d17d5d03b
4 changed files with 16 additions and 13 deletions

View File

@ -103,7 +103,6 @@ class _URIs(object):
generally every test uses a fresh virConnect, or undoes the
persistent changes it makes.
"""
virtinst.util.register_libvirt_error_handler()
is_testdriver_xml = "/testdriver.xml" in uri
if not (is_testdriver_xml and self._testdriver_error):

View File

@ -21,7 +21,23 @@ def _setup_i18n():
gettext.install("virt-manager", _CLIConfig.gettext_dir)
gettext.bindtextdomain("virt-manager", _CLIConfig.gettext_dir)
def _set_libvirt_error_handler():
"""
Ignore libvirt error reporting, we just use exceptions
"""
import libvirt
def libvirt_callback(userdata, err):
ignore = userdata
ignore = err
ctx = None
libvirt.registerErrorHandler(libvirt_callback, ctx)
_setup_i18n()
_set_libvirt_error_handler()
from virtinst import util
from virtinst.uri import URI

View File

@ -185,8 +185,6 @@ def setupLogging(appname, debug_stdout, do_quiet, cli_app=True):
if streamHandler:
rootLogger.addHandler(streamHandler)
util.register_libvirt_error_handler()
# Log uncaught exceptions
def exception_log(typ, val, tb):
logging.debug("Uncaught exception:\n%s",

View File

@ -162,16 +162,6 @@ def get_cache_dir():
return os.path.join(ret, "virt-manager")
def register_libvirt_error_handler():
"""
Ignore libvirt error reporting, we just use exceptions
"""
def libvirt_callback(userdata, err):
ignore = userdata
ignore = err
libvirt.registerErrorHandler(f=libvirt_callback, ctx=None)
def ensure_meter(meter):
if meter:
return meter