mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Added an error dialog with expandable 'details' pane. Use this from connection error code. Patch from Richard Jones
This commit is contained in:
parent
81ac2eab87
commit
c426c9a8a2
1
AUTHORS
1
AUTHORS
@ -19,6 +19,7 @@ Further patches have been submitted by:
|
||||
Damien Durand <splinux25-at-gmail-dot-com>
|
||||
Charles Coffing <ccoffing-at-novell-dot-com>
|
||||
Mark Cave-Ayland <mark.cave-ayland-at-ilande-dot-co-dot-uk>
|
||||
Richard W.M. Jones <rjones-at-redhat-dot-com>
|
||||
|
||||
<...send a patch & get your name here...>
|
||||
|
||||
|
@ -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
|
||||
|
50
src/virtManager/error.py
Normal file
50
src/virtManager/error.py
Normal file
@ -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 ()
|
Loading…
Reference in New Issue
Block a user