diff options
author | Matt Wilson <msw@redhat.com> | 2000-07-12 20:05:46 +0000 |
---|---|---|
committer | Matt Wilson <msw@redhat.com> | 2000-07-12 20:05:46 +0000 |
commit | f9b0aace80f9b2068e7f7882c3071c5069ae2b53 (patch) | |
tree | 81c96f35a6897e784dd04fdfc641120144ba7c08 | |
parent | 4c8bdafebc9299559041cec222f33512dfb3577e (diff) | |
download | anaconda-f9b0aace80f9b2068e7f7882c3071c5069ae2b53.tar.gz anaconda-f9b0aace80f9b2068e7f7882c3071c5069ae2b53.tar.xz anaconda-f9b0aace80f9b2068e7f7882c3071c5069ae2b53.zip |
rework exception handling in GUI so we can catch during the todo.doinstall, use pc104 as default kbd
-rwxr-xr-x | anaconda | 72 | ||||
-rw-r--r-- | exception.py | 82 | ||||
-rwxr-xr-x | gui.py | 121 | ||||
-rw-r--r-- | iw/progress_gui.py | 8 | ||||
-rw-r--r-- | kbd.py | 4 |
5 files changed, 163 insertions, 124 deletions
@@ -33,11 +33,11 @@ if len(sys.argv) > 1: import traceback import string -from cPickle import Pickler import isys import iutil from translate import _ +from exception import handleException setverPath = None @@ -424,74 +424,6 @@ try: except SystemExit, code: intf.shutdown() except: - (type, value, tb) = sys.exc_info() - from string import joinfields - list = traceback.format_exception (type, value, tb) - text = joinfields (list, "") - rc = intf.exceptionWindow (_("Exception Occurred"), text) - if rc == 1: - intf.__del__ () - print text - import pdb - pdb.post_mortem (tb) - elif not rc: - intf.__del__ () - os._exit(1) - - while 1: - rc = intf.dumpWindow() - if rc: - intf.__del__ () - os._exit(1) - - device = todo.fdDevice - file = "/tmp/floppy" - try: - isys.makeDevInode(device, file) - except SystemError: - pass - try: - fd = os.open(file, os.O_RDONLY) - except: - continue - - os.close(fd) - - args = [ "mkdosfs", '/tmp/floppy' ] - - cmd = "/usr/sbin/mkdosfs" - if os.access("/sbin/mkdosfs", os.X_OK): - cmd = "/sbin/mkdosfs" - - iutil.execWithRedirect (cmd, args, - stdout = '/dev/tty5', stderr = '/dev/tty5') - isys.mount(device, "/tmp/crash", fstype = "vfat") - - out = open("/tmp/crash/anacdump.txt", "w") - p = Pickler(out) - - out.write(text) - - trace = tb - while trace.tb_next: - trace = trace.tb_next - frame = trace.tb_frame - out.write ("\nLocal variables in innermost frame:\n") - for (key, value) in frame.f_locals.items(): - out.write ("%s: %s\n" % (key, value)) - - out.write("\nToDo object:\n") - todo.intf = None - todo.fstab = None - todo.comps = None - todo.hdList = None - - p.dump(todo) - - out.close() - isys.umount("/tmp/crash") - - intf.__del__ () - os._exit (1) + handleException(todo, sys.exc_info()) del intf diff --git a/exception.py b/exception.py new file mode 100644 index 000000000..c15edd4ed --- /dev/null +++ b/exception.py @@ -0,0 +1,82 @@ +import isys +import os +import signal +from string import joinfields +import traceback +from cPickle import Pickler +from translate import _ +import iutil + +def handleException(todo, (type, value, tb)): + list = traceback.format_exception (type, value, tb) + text = joinfields (list, "") + rc = todo.intf.exceptionWindow (_("Exception Occurred"), text) + if rc == 1: + todo.intf.__del__ () + print text + import pdb + pdb.post_mortem (tb) + os.kill(os.getpid(), signal.SIGKILL) + elif not rc: + todo.intf.__del__ () + os.kill(os.getpid(), signal.SIGKILL) + + while 1: + rc = todo.intf.dumpWindow() + if rc: + todo.intf.__del__ () + os.kill(os.getpid(), signal.SIGKILL) + + device = todo.fdDevice + file = "/tmp/floppy" + try: + isys.makeDevInode(device, file) + except SystemError: + pass + try: + fd = os.open(file, os.O_RDONLY) + except: + continue + + os.close(fd) + + args = [ "mkdosfs", 'mkdosfs', '/tmp/floppy' ] + + cmd = "/usr/sbin/mkdosfs" + if os.access("/sbin/mkdosfs", os.X_OK): + cmd = "/sbin/mkdosfs" + + iutil.execWithRedirect (cmd, args, + stdout = '/dev/tty5', stderr = '/dev/tty5') + try: + isys.mount(device, "/tmp/crash", fstype = "vfat") + except SystemError: + continue + + out = open("/tmp/crash/anacdump.txt", "w") + p = Pickler(out) + + out.write(text) + + trace = tb + while trace.tb_next: + trace = trace.tb_next + frame = trace.tb_frame + out.write ("\nLocal variables in innermost frame:\n") + for (key, value) in frame.f_locals.items(): + out.write ("%s: %s\n" % (key, value)) + + out.write("\nToDo object:\n") + intf = todo.intf + todo.intf = None + todo.fstab = None + todo.comps = None + todo.hdList = None + + p.dump(todo) + + out.close() + isys.umount("/tmp/crash") + + intf.__del__ () + os.kill(os.getpid(), signal.SIGKILL) @@ -119,56 +119,74 @@ class ProgressWindow: self.window.destroy () threads_leave () -def ExceptionWindow(text): - win = GnomeDialog ("Exception Occured") - win.append_button ("Debug") - win.append_button ("Save to floppy") - win.append_button_with_pixmap ("OK", STOCK_BUTTON_OK) - textbox = GtkText() - textbox.insert_defaults (text) - sw = GtkScrolledWindow () - sw.add (textbox) - sw.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC) - - hbox = GtkHBox (FALSE) - # XXX fix me, use util function when we upgrade pygnome - # s = unconditional_pixmap_file ("gnome-error.png") - if s: - hbox.pack_start (GnomePixmap ('/usr/share/pixmaps/gnome-warning.png'), - FALSE) - - info = GtkLabel (_("An exceptional condition has occured. This " - "is most likely a bug. Please copy the " - "full text of this exception and file a bug " - "report at " - "http://bugzilla.redhat.com/bugzilla")) - info.set_line_wrap (TRUE) - info.set_usize (350, -1) - - hbox.pack_start (sw, TRUE) - win.vbox.pack_start (info, FALSE) - win.vbox.pack_start (hbox, TRUE) - win.set_usize (500, 300) - win.set_position (WIN_POS_CENTER) - win.show_all () - rc = win.run () - threads_leave() - # I did it this way for future expantion - # 0 is debug - if rc == 0: - import isys - try: - # switch to VC1 so we can debug - isys.vtActivate (1) - except SystemError: - pass - return 1 - # 1 is save - if rc == 1: - return 2 - # 2 is OK - elif rc == 2: - return 0 +class ExceptionWindow: + def __init__ (self, text): + win = GnomeDialog ("Exception Occured") + win.connect ("clicked", self.quit) + win.append_button ("Debug") + win.append_button ("Save to floppy") + win.append_button_with_pixmap ("OK", STOCK_BUTTON_OK) + textbox = GtkText() + textbox.insert_defaults (text) + sw = GtkScrolledWindow () + sw.add (textbox) + sw.set_policy (POLICY_AUTOMATIC, POLICY_AUTOMATIC) + + hbox = GtkHBox (FALSE) + # XXX fix me, use util function when we upgrade pygnome + # s = unconditional_pixmap_file ("gnome-error.png") + if s: + hbox.pack_start (GnomePixmap ('/usr/share/pixmaps/gnome-warning.png'), + FALSE) + + info = GtkLabel (_("An exceptional condition has occured. This " + "is most likely a bug. Please copy the " + "full text of this exception and file a bug " + "report at " + "http://bugzilla.redhat.com/bugzilla")) + info.set_line_wrap (TRUE) + info.set_usize (350, -1) + + hbox.pack_start (sw, TRUE) + win.vbox.pack_start (info, FALSE) + win.vbox.pack_start (hbox, TRUE) + win.set_usize (500, 300) + win.set_position (WIN_POS_CENTER) + win.show_all () + self.window = win + + thread = currentThread () + if thread.getName () == "gtk_main": + self.mutex = None + self.rc = self.window.run () + threads_leave() + else: + threads_leave () + self.mutex = Event () + self.mutex.wait () + + def quit (self, dialog, button): + self.rc = button + if self.mutex: + self.mutex.set () + + def getrc (self): + # I did it this way for future expantion + # 0 is debug + if self.rc == 0: + import isys + try: + # switch to VC1 so we can debug + isys.vtActivate (1) + except SystemError: + pass + return 1 + # 1 is save + if self.rc == 1: + return 2 + # 2 is OK + elif self.rc == 2: + return 0 class MessageWindow: def quit (self, dialog, button): @@ -245,7 +263,8 @@ class InstallInterface: def exceptionWindow(self, title, text): print text - return ExceptionWindow (text) + win = ExceptionWindow (text) + return win.getrc () def dumpWindow(self): window = MessageWindow("Save Crash Dump", diff --git a/iw/progress_gui.py b/iw/progress_gui.py index c228e0f7e..7631ed935 100644 --- a/iw/progress_gui.py +++ b/iw/progress_gui.py @@ -5,6 +5,7 @@ import rpm import time from threading import * from translate import _ +import sys class DoInstall (Thread): def __init__ (self, icw, todo): @@ -13,7 +14,12 @@ class DoInstall (Thread): Thread.__init__ (self) def run (self): - rc = self.todo.doInstall () + from exception import handleException + try: + rc = self.todo.doInstall () + except: + threads_enter () + handleException(self.todo, sys.exc_info()) threads_enter () if rc: self.icw.prevClicked () @@ -43,8 +43,8 @@ class Keyboard (SimpleConfigFile): ("ru2" , ('pc102', 'ru')), ("ru_win" , ('pc105', 'ru')), ("se-latin1" , ('pc102', 'se')), - ("uk" , ('pc101', 'gb')), - ("us" , ('pc101', 'us')), + ("uk" , ('pc104', 'gb')), + ("us" , ('pc104', 'us')), ] console2xsun = { |