diff --git a/AUTHORS b/AUTHORS index 33763f9da..aa728e3e2 100644 --- a/AUTHORS +++ b/AUTHORS @@ -19,6 +19,7 @@ Further patches have been submitted by: Damien Durand Charles Coffing Mark Cave-Ayland + Richard W.M. Jones <...send a patch & get your name here...> diff --git a/src/virtManager/engine.py b/src/virtManager/engine.py index 0cb8fece6..906411b24 100644 --- a/src/virtManager/engine.py +++ b/src/virtManager/engine.py @@ -34,6 +34,7 @@ from virtManager.console import vmmConsole 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 --git a/src/virtManager/error.py b/src/virtManager/error.py new file mode 100644 index 000000000..5a9d6319d --- /dev/null +++ b/src/virtManager/error.py @@ -0,0 +1,50 @@ +# 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): + 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: + # Expander section with details. + expander = gtk.Expander (_("Details")) + buffer = gtk.TextBuffer () + buffer.set_text (message_details) + sw = gtk.ScrolledWindow () + sw.set_shadow_type (gtk.SHADOW_IN) + sw.set_size_request (-1, 240) + sw.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) + details = gtk.TextView (buffer) + details.set_editable (False) + details.set_overwrite (False) + details.set_cursor_visible (False) + details.set_wrap_mode (gtk.WRAP_WORD) + sw.add (details) + details.show () + expander.add (sw) + sw.show () + self.vbox.pack_start (expander) + expander.show ()