diff options
-rw-r--r-- | ChangeLog | 10 | ||||
-rw-r--r-- | cmdline.py | 4 | ||||
-rw-r--r-- | constants.py | 14 | ||||
-rw-r--r-- | exception.py | 2 | ||||
-rwxr-xr-x | gui.py | 78 | ||||
-rw-r--r-- | text.py | 11 | ||||
-rw-r--r-- | ui/exn.glade | 204 |
7 files changed, 273 insertions, 50 deletions
@@ -9,6 +9,16 @@ * loader2/init.c (doklog): Don't copy null characters into the log file. + * ui/exn.glade: Added a glade file for exception dialogs. + * cmdline.py (InstallInterface.exceptionWindow): Rename params to + match other interfaces. + * constants.py: Remove exceptionTextNoFloppy, reword exceptionText. + * exception.py (handleException): Provide name of traceback file. + * gui.py (ExceptionWindow): Use glade for the UI and add the full + exception dump to the bottom of the dialog. + * text.py (InstallInterface.exceptionWindow): Rename params to match + other interfaces. Don't use exceptionTextNoFloppy. + 2005-09-19 Chris Lumens <clumens@redhat.com> * kickstartData.py: Add package header data. diff --git a/cmdline.py b/cmdline.py index ec22b9c6d..d975f5797 100644 --- a/cmdline.py +++ b/cmdline.py @@ -76,8 +76,8 @@ class InstallInterface: while 1: time.sleep(5) - def exceptionWindow(self, title, text): - print text + def exceptionWindow(self, shortText, longTextFile): + print shortText def partedExceptionWindow(self, exc): # if our only option is to cancel, let us handle the exception diff --git a/constants.py b/constants.py index d119a32d7..dd5898fb6 100644 --- a/constants.py +++ b/constants.py @@ -71,14 +71,6 @@ productPath = product.productPath bugzillaUrl = product.bugUrl exceptionText = _("An unhandled exception has occurred. This " - "is most likely a bug. Please copy the " - "full text of this exception or save the crash " - "dump to a floppy then file a detailed bug " - "report against anaconda at " - "%s") %(bugzillaUrl,) - -exceptionTextNoFloppy = _("An unhandled exception has occurred. This " - "is most likely a bug. Please copy the " - "full text of this exception and file a detailed " - "bug report against anaconda at " - "%s") %(bugzillaUrl,) + "is most likely a bug. Please save a copy of " + "the detailed exception and file a bug report " + "against anaconda at %s" %(bugzillaUrl,)) diff --git a/exception.py b/exception.py index 47ced6d5b..941ae9ae5 100644 --- a/exception.py +++ b/exception.py @@ -229,7 +229,7 @@ def handleException(dispatch, intf, (type, value, tb)): except: pass - rc = intf.exceptionWindow (_("Exception Occurred"), text) + rc = intf.exceptionWindow (text, "/tmp/anacdump.txt") if rc == 1: intf.__del__ () print text @@ -536,7 +536,7 @@ class ProgressWindow: rootPopBusyCursor() class ExceptionWindow: - def __init__ (self, text): + def __init__ (self, shortTraceback, longTracebackFile=None): try: floppyDevices = 0 for dev in kudzu.probe(kudzu.CLASS_FLOPPY, kudzu.BUS_UNSPEC, @@ -546,35 +546,51 @@ class ExceptionWindow: except: floppyDevices = 0 - win = gtk.Dialog(_("Exception Occurred"), mainWindow, gtk.DIALOG_MODAL) - win.add_button(_("_Debug"), 0) - if floppyDevices > 0 or DEBUG: - win.add_button(_("_Save to floppy"), 1) - win.add_button('gtk-ok', 2) - buffer = gtk.TextBuffer(None) - buffer.set_text(text) - textbox = gtk.TextView() - textbox.set_buffer(buffer) - textbox.set_property("editable", False) - textbox.set_property("cursor_visible", False) - sw = gtk.ScrolledWindow () - sw.add (textbox) - sw.set_policy (gtk.POLICY_AUTOMATIC, gtk.POLICY_AUTOMATIC) - - hbox = gtk.HBox (False) - - if floppyDevices > 0: - info = WrappingLabel(exceptionText) + # Get a bunch of widgets from the XML file. + exnxml = gtk.glade.XML(findGladeFile("exn.glade"), domain="anaconda") + win = exnxml.get_widget("exnDialog") + vbox = exnxml.get_widget("mainVBox") + shortExnView = exnxml.get_widget("shortExnView") + longExnView = exnxml.get_widget("longExnView") + expander = exnxml.get_widget("longViewExpander") + info = exnxml.get_widget("info") + + info.set_text(exceptionText) + + # Add the brief traceback message to the upper text view. + textbuf = gtk.TextBuffer() + textbuf.set_text(shortTraceback) + shortExnView.set_buffer(textbuf) + + # Remove the debug button if we don't need it. + if floppyDevices == 0 and not DEBUG: + buttonBox = exnxml.get_widget("buttonBox") + floppyButton = exnxml.get_widget("floppyButton") + buttonBox.remove(floppyButton) + + # If there's an anacdump.txt file, add it to the lower view in the + # expander. If not, remove the expander. + if longTracebackFile: + try: + f = open(longTracebackFile) + lines = f.readlines() + f.close() + + # Add text one line at a time to work around limits in + # set_text. + textbuf = gtk.TextBuffer() + iter = textbuf.get_start_iter() + + for line in lines: + textbuf.insert(iter, line) + + longExnView.set_buffer(textbuf) + except IOError: + log.error("Could not read %s, skipping" % longTraceback) + vbox.remove(expander) else: - info = WrappingLabel(exceptionTextNoFloppy) - - info.set_size_request (400, -1) + vbox.remove(expander) - hbox.pack_start (sw, True) - win.vbox.pack_start (info, False) - win.vbox.pack_start (hbox, True) - win.set_size_request (500, 300) - win.set_position (gtk.WIN_POS_CENTER) addFrame(win) win.show_all () self.window = win @@ -713,9 +729,9 @@ class InstallInterface: custom_buttons, custom_icon).getrc() return rc - def exceptionWindow(self, title, text): - log.critical(text) - win = ExceptionWindow (text) + def exceptionWindow(self, shortText, longTextFile): + log.critical(shortText) + win = ExceptionWindow (shortText, longTextFile) return win.getrc () def beep(self): @@ -218,7 +218,7 @@ class InstallInterface: from string import joinfields list = traceback.format_exception(type, value, tb) text = joinfields(list, "") - rc = self.exceptionWindow(_("Exception Occurred"), text) + rc = self.exceptionWindow(text) if rc: import pdb pdb.post_mortem(tb) @@ -282,7 +282,7 @@ class InstallInterface: return 0 - def exceptionWindow(self, title, text): + def exceptionWindow(self, shortText, longTextFile): try: floppyDevices = 0 for dev in kudzu.probe(kudzu.CLASS_FLOPPY, kudzu.BUS_UNSPEC, @@ -291,14 +291,15 @@ class InstallInterface: floppyDevices = floppyDevices + 1 except: floppyDevices = 0 + + ugh = "%s\n\n" % (exceptionText,) if floppyDevices > 0 or DEBUG: - ugh = "%s\n\n" % (exceptionText,) buttons=[TEXT_OK_BUTTON, _("Save"), _("Debug")] else: - ugh = "%s\n\n" % (exceptionTextNoFloppy,) buttons=[TEXT_OK_BUTTON, _("Debug")] - rc = ButtonChoiceWindow(self.screen, title, ugh + text, buttons) + rc = ButtonChoiceWindow(self.screen, _("Exception Occurred"), + ugh + shortText, buttons) if rc == string.lower(_("Debug")): return 1 elif rc == string.lower(_("Save")): diff --git a/ui/exn.glade b/ui/exn.glade new file mode 100644 index 000000000..44f18b1be --- /dev/null +++ b/ui/exn.glade @@ -0,0 +1,204 @@ +<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*--> +<!DOCTYPE glade-interface SYSTEM "http://glade.gnome.org/glade-2.0.dtd"> + +<glade-interface> + +<widget class="GtkDialog" id="exnDialog"> + <property name="visible">True</property> + <property name="title">Exception Occurred</property> + <property name="type">GTK_WINDOW_TOPLEVEL</property> + <property name="window_position">center</property> + <property name="modal">True</property> + <property name="default_width">500</property> + <property name="default_height">350</property> + <property name="resizable">True</property> + <property name="destroy_with_parent">False</property> + <property name="decorated">True</property> + <property name="skip_taskbar_hint">False</property> + <property name="skip_pager_hint">False</property> + <property name="type_hint">GDK_WINDOW_TYPE_HINT_DIALOG</property> + <property name="gravity">center</property> + <property name="focus_on_map">True</property> + <property name="has_separator">True</property> + + <child internal-child="vbox"> + <widget class="GtkVBox" id="exnDialog-vbox"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">0</property> + + <child internal-child="action_area"> + <widget class="GtkHButtonBox" id="buttonBox"> + <property name="visible">True</property> + <property name="layout_style">GTK_BUTTONBOX_END</property> + + <child> + <widget class="GtkButton" id="floppyButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label">_Save to floppy</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">1</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="debugButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label">_Debug</property> + <property name="use_underline">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">0</property> + </widget> + </child> + + <child> + <widget class="GtkButton" id="okButton"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="label">gtk-ok</property> + <property name="use_stock">True</property> + <property name="relief">GTK_RELIEF_NORMAL</property> + <property name="focus_on_click">True</property> + <property name="response_id">2</property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">True</property> + <property name="pack_type">GTK_PACK_END</property> + </packing> + </child> + + <child> + <widget class="GtkVBox" id="mainVBox"> + <property name="visible">True</property> + <property name="homogeneous">False</property> + <property name="spacing">5</property> + + <child> + <widget class="GtkLabel" id="info"> + <property name="width_request">400</property> + <property name="height_request">0</property> + <property name="visible">True</property> + <property name="label" translatable="yes"></property> + <property name="use_underline">False</property> + <property name="use_markup">False</property> + <property name="justify">GTK_JUSTIFY_LEFT</property> + <property name="wrap">True</property> + <property name="selectable">False</property> + <property name="xalign">0.5</property> + <property name="yalign">0.5</property> + <property name="xpad">0</property> + <property name="ypad">0</property> + <property name="ellipsize">PANGO_ELLIPSIZE_NONE</property> + <property name="width_chars">-1</property> + <property name="single_line_mode">False</property> + <property name="angle">0</property> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkScrolledWindow" id="scrolledwindow1"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">in</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + + <child> + <widget class="GtkTextView" id="shortExnView"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="overwrite">False</property> + <property name="accepts_tab">True</property> + <property name="justification">GTK_JUSTIFY_LEFT</property> + <property name="wrap_mode">GTK_WRAP_NONE</property> + <property name="cursor_visible">False</property> + <property name="pixels_above_lines">0</property> + <property name="pixels_below_lines">0</property> + <property name="pixels_inside_wrap">0</property> + <property name="left_margin">0</property> + <property name="right_margin">0</property> + <property name="indent">0</property> + <property name="text" translatable="yes"></property> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">False</property> + <property name="fill">False</property> + </packing> + </child> + + <child> + <widget class="GtkExpander" id="longViewExpander"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="expanded">False</property> + <property name="spacing">0</property> + <property name="label">Detailed exception</property> + + <child> + <widget class="GtkScrolledWindow" id="scrolledwindow2"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="hscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="vscrollbar_policy">GTK_POLICY_AUTOMATIC</property> + <property name="shadow_type">in</property> + <property name="window_placement">GTK_CORNER_TOP_LEFT</property> + + <child> + <widget class="GtkTextView" id="longExnView"> + <property name="visible">True</property> + <property name="can_focus">True</property> + <property name="editable">False</property> + <property name="overwrite">False</property> + <property name="accepts_tab">True</property> + <property name="justification">GTK_JUSTIFY_LEFT</property> + <property name="wrap_mode">GTK_WRAP_NONE</property> + <property name="cursor_visible">False</property> + <property name="pixels_above_lines">0</property> + <property name="pixels_below_lines">0</property> + <property name="pixels_inside_wrap">0</property> + <property name="left_margin">0</property> + <property name="right_margin">0</property> + <property name="indent">0</property> + <property name="text" translatable="yes"></property> + </widget> + </child> + </widget> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + <packing> + <property name="padding">0</property> + <property name="expand">True</property> + <property name="fill">True</property> + </packing> + </child> + </widget> + </child> +</widget> + +</glade-interface> |