This patch adds a new dialog class, vmmErrorDialog, derived from gtk.MessageDialog, which has a "Show details" button to show the true reason for a failure. It modifies the exception handler for connections to give the underlying reason and a stack trace.
Also attached, two screenshots so you can see what I mean without needing to apply the patch.
Rich. -- Emerging Technologies, Red Hat http://et.redhat.com/~rjones/ 64 Baker Street, London, W1U 7DF Mobile: +44 7866 314 421 "[Negative numbers] darken the very whole doctrines of the equations and make dark of the things which are in their nature excessively obvious and simple" (Francis Maseres FRS, mathematician, 1759)
# HG changeset patch # User rjones@xxxxxxxxxxxxxxxxxxxxx # Date 1174589613 0 # Node ID ad883fefaf0468f0db6e22bc96f46af1613215f9 # Parent f1254be4fc9310b381f18beb3098f9bbe5ede8d2 Add error dialog with "Details" toggle button, and changed connection to use this so we can see the real error. diff -r f1254be4fc93 -r ad883fefaf04 src/virtManager/engine.py --- a/src/virtManager/engine.py Thu Mar 22 11:11:25 2007 -0400 +++ b/src/virtManager/engine.py Thu Mar 22 18:53:33 2007 +0000 @@ -34,6 +34,7 @@ from virtManager.asyncjob import vmmAsyn from virtManager.asyncjob import vmmAsyncJob from virtManager.create import vmmCreate from virtManager.serialcon import vmmSerialConsole +from virtManager.error import vmmErrorDialog class vmmEngine: def __init__(self, config): @@ -66,21 +67,32 @@ class vmmEngine: conn = self.get_connection(uri, readOnly) self.show_manager(uri) except: - logging.error((("Unable to open connection to hypervisor URI '%s'") % str(uri)) + \ - ": " + str(sys.exc_info()[0]) + " " + str(sys.exc_info()[1]) + "\n" + \ - traceback.format_exc(sys.exc_info()[2])) - + (type, value, stacktrace) = sys.exc_info () + + # Detailed error message, in English so it can be Googled. + details = \ + ("Unable to open connection to hypervisor URI '%s':\n" % + str(uri)) + \ + str(type) + " " + str(value) + "\n" + \ + traceback.format_exc (stacktrace) + logging.error (details) + + # Error dialog. if uri is None: uri = "xen" if uri == "xen": - dg = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, - _("Unable to open a connection to the Xen hypervisor/daemon.\n\n" + \ - "Verify that:\n" + \ - " - A Xen host kernel was booted\n" + \ - " - The Xen service has been started\n")) + dg = vmmErrorDialog (None, 0, gtk.MESSAGE_ERROR, + gtk.BUTTONS_CLOSE, + _("Unable to open a connection to the Xen hypervisor/daemon.\n\n" + + "Verify that:\n" + + " - A Xen host kernel was booted\n" + + " - The Xen service has been started\n"), + details) else: - dg = gtk.MessageDialog(None, 0, gtk.MESSAGE_ERROR, gtk.BUTTONS_CLOSE, - _("Unable to open connection to hypervisor '%s'") % str(uri)) + dg = vmmErrorDialog (None, 0, gtk.MESSAGE_ERROR, + gtk.BUTTONS_CLOSE, + _("Unable to open connection to hypervisor '%s'") % str(uri), + details) dg.set_title(_("Virtual Machine Manager Connection Failure")) dg.run() dg.hide() @@ -135,7 +147,7 @@ class vmmEngine: except KeyboardInterrupt: raise KeyboardInterrupt except: - logging.error(("Could not refresh connection %s" % (uri)) + str(sys.exc_info()[0]) + \ + logging.error(("Could not refresh connection %s\n" % (uri)) + str(sys.exc_info()[0]) + \ " " + str(sys.exc_info()[1]) + "\n" + \ traceback.format_exc(sys.exc_info()[2])) return 1 diff -r f1254be4fc93 -r ad883fefaf04 src/virtManager/error.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/virtManager/error.py Thu Mar 22 18:53:33 2007 +0000 @@ -0,0 +1,67 @@ +# Error dialog with extensible "details" button. +# +# Copyright (C) 2007 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +import gtk +import gtk.glade +import pango + +class vmmErrorDialog (gtk.MessageDialog): + show_label = _("Show details >>>") + hide_label = _("Hide details") + + def __init__ (self, parent=None, flags=0, type=gtk.MESSAGE_INFO, + buttons=gtk.BUTTONS_NONE, message_format=None, + message_details=None): + gtk.MessageDialog.__init__ (self, + parent, flags, type, buttons, + message_format) + + if not message_details is None: + # Details button. + hbox = gtk.HBox (False, 0); + self.details = gtk.ToggleButton (label = self.show_label) + hbox.pack_end (self.details, expand=False, fill=False) + self.vbox.pack_start (hbox, expand=True, fill=True) + self.details.show () + hbox.show () + + # Details label. + self.details_lbl = gtk.Label (message_details) + self.details_lbl.set_alignment (0.0, 0.0) + self.details_lbl.set_line_wrap (True) + self.details_lbl.set_selectable (True) + + # Set the details in courier. + courier = pango.AttrFamily ("courier", end_index=len(message_details)) + attrlist = pango.AttrList () + attrlist.insert (courier) + self.details_lbl.set_attributes (attrlist) + + # Pack details label. + self.vbox.pack_start (self.details_lbl) + + # Details button activates/deactivates details. + self.details.connect ("toggled", self.toggle_details) + + def toggle_details (self, button): + if button.get_active (): + self.details.set_label (self.hide_label) + self.details_lbl.show () + else: + self.details.set_label (self.show_label) + self.details_lbl.hide ()
Attachment:
smime.p7s
Description: S/MIME Cryptographic Signature