[et-mgmt-tools] [PATCH] For connection errors, show full details (version 2)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Following on from https://www.redhat.com/archives/et-mgmt-tools/2007-March/msg00174.html, this is a second version of the patch which more or less follows the design of error dialogs used by 'pup'. I converted pup's glade-based configuration file to direct code (the direct code is much shorter for a start).

Two screenshots show what it looks like.

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)

PNG image

PNG image

diff -r f1254be4fc93 -r 1f1add5ce5e2 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 20:13:43 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 1f1add5ce5e2 src/virtManager/error.py
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/virtManager/error.py	Thu Mar 22 20:13:43 2007 +0000
@@ -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 ()

Attachment: smime.p7s
Description: S/MIME Cryptographic Signature


[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux