def handleException(self, dump_info): """ Our own handleException method doing some additional stuff before calling the original python-meh's one. :type dump_info: an instance of the meh.DumpInfo class :see: python-meh's ExceptionHandler.handleException """ log.debug("running handleException") ty = dump_info.exc_info.type value = dump_info.exc_info.value if (issubclass(ty, blivet.errors.StorageError) and value.hardware_fault) \ or (issubclass(ty, OSError) and value.errno == errno.EIO): # hardware fault or '[Errno 5] Input/Output error' hw_error_msg = _("The installation was stopped due to what " "seems to be a problem with your hardware. " "The exact error message is:\n\n%s.\n\n " "The installer will now terminate.") % str(value) self.intf.messageWindow(_("Hardware error occured"), hw_error_msg) sys.exit(0) else: try: from gi.repository import Gtk # XXX: Gtk stopped raising RuntimeError if it fails to # initialize. Horay! But will it stay like this? Let's be # cautious and raise the exception on our own to work in both # cases initialized = Gtk.init_check(None)[0] if not initialized: raise RuntimeError() if Gtk.main_level() > 0: # main loop is running, don't crash it by running another one # potentially from a different thread log.debug("Gtk running, queuing exception handler to the " "main loop") GLib.idle_add(self.run_handleException, dump_info) else: log.debug("Gtk not running, starting Gtk and running " "exception handler in it") super(AnacondaExceptionHandler, self).handleException( dump_info) except RuntimeError: log.debug("Gtk cannot be initialized") # X not running (Gtk cannot be initialized) if threadMgr.in_main_thread(): log.debug("In the main thread, running exception handler") print "An unknown error has occured, look at the "\ "/tmp/anaconda-tb* file(s) for more details" # in the main thread, run exception handler super(AnacondaExceptionHandler, self).handleException( dump_info) else: log.debug("In a non-main thread, sending a message with " "exception data") # not in the main thread, just send message with exception # data and let message handler run the exception handler in # the main thread exc_info = dump_info.exc_info hubQ.send_exception((exc_info.type, exc_info.value, exc_info.stack))
def handleException(self, dump_info): """ Our own handleException method doing some additional stuff before calling the original python-meh's one. :type dump_info: an instance of the meh.DumpInfo class :see: python-meh's ExceptionHandler.handleException """ log.debug("running handleException") exception_lines = traceback.format_exception(*dump_info.exc_info) log.critical("\n".join(exception_lines)) ty = dump_info.exc_info.type value = dump_info.exc_info.value try: gi.require_version("Gtk", "3.0") from gi.repository import Gtk # XXX: Gtk stopped raising RuntimeError if it fails to # initialize. Horay! But will it stay like this? Let's be # cautious and raise the exception on our own to work in both # cases initialized = Gtk.init_check(None)[0] if not initialized: raise RuntimeError() # Attempt to grab the GUI initializing lock, do not block if not self._gui_lock.acquire(False): # the graphical interface is running, don't crash it by # running another one potentially from a different thread log.debug("Gtk running, queuing exception handler to the " "main loop") GLib.idle_add(self._main_loop_handleException, dump_info) else: log.debug("Gtk not running, starting Gtk and running " "exception handler in it") self._main_loop_handleException(dump_info) except (RuntimeError, ImportError, ValueError): log.debug("Gtk cannot be initialized") # X not running (Gtk cannot be initialized) if threadMgr.in_main_thread(): log.debug("In the main thread, running exception handler") if issubclass(ty, CmdlineError) or not self._interactive: if issubclass(ty, CmdlineError): cmdline_error_msg = _( "\nThe installation was stopped due to " "incomplete spokes detected while running " "in non-interactive cmdline mode. Since there " "cannot be any questions in cmdline mode, " "edit your kickstart file and retry " "installation.\nThe exact error message is: " "\n\n%s.\n\nThe installer will now terminate." ) % str(value) else: cmdline_error_msg = _( "\nRunning in cmdline mode, no interactive debugging " "allowed.\nThe exact error message is: " "\n\n%s.\n\nThe installer will now terminate." ) % str(value) # since there is no UI in cmdline mode and it is completely # non-interactive, we can't show a message window asking the user # to acknowledge the error; instead, print the error out and sleep # for a few seconds before exiting the installer print(cmdline_error_msg) time.sleep(10) sys.exit(1) else: print("\nAn unknown error has occured, look at the " "/tmp/anaconda-tb* file(s) for more details") # in the main thread, run exception handler self._main_loop_handleException(dump_info) else: log.debug("In a non-main thread, sending a message with " "exception data") # not in the main thread, just send message with exception # data and let message handler run the exception handler in # the main thread exc_info = dump_info.exc_info hubQ.send_exception((exc_info.type, exc_info.value, exc_info.stack))
def handleException(self, dump_info): """ Our own handleException method doing some additional stuff before calling the original python-meh's one. :type dump_info: an instance of the meh.DumpInfo class :see: python-meh's ExceptionHandler.handleException """ log.debug("running handleException") exception_lines = traceback.format_exception(*dump_info.exc_info) log.critical("\n".join(exception_lines)) ty = dump_info.exc_info.type value = dump_info.exc_info.value try: gi.require_version("Gtk", "3.0") from gi.repository import Gtk # XXX: Gtk stopped raising RuntimeError if it fails to # initialize. Horay! But will it stay like this? Let's be # cautious and raise the exception on our own to work in both # cases initialized = Gtk.init_check(None)[0] if not initialized: raise RuntimeError() # Attempt to grab the GUI initializing lock, do not block if not self._gui_lock.acquire(False): # the graphical interface is running, don't crash it by # running another one potentially from a different thread log.debug( "Gtk running, queuing exception handler to the main loop") run_in_loop(self._main_loop_handleException, dump_info) else: log.debug( "Gtk not running, starting Gtk and running exception handler in it" ) self._main_loop_handleException(dump_info) except (RuntimeError, ImportError, ValueError): log.debug("Gtk cannot be initialized") # X not running (Gtk cannot be initialized) if threadMgr.in_main_thread(): log.debug("In the main thread, running exception handler") if issubclass(ty, NonInteractiveError) or not self._interactive: if issubclass(ty, NonInteractiveError): cmdline_error_msg = _( "\nThe installation was stopped due to an " "error which occurred while running in " "non-interactive cmdline mode. Since there " "cannot be any questions in cmdline mode, edit " "your kickstart file and retry installation. " "\nThe exact error message is: \n\n%s. \n\nThe " "installer will now terminate.") % str(value) else: cmdline_error_msg = _( "\nRunning in cmdline mode, no interactive " "debugging allowed.\nThe exact error message is: " "\n\n%s.\n\nThe installer will now terminate." ) % str(value) # since there is no UI in cmdline mode and it is completely # non-interactive, we can't show a message window asking the user # to acknowledge the error; instead, print the error out and sleep # for a few seconds before exiting the installer print(cmdline_error_msg) time.sleep(180) sys.exit(1) else: print("\nAn unknown error has occured, look at the " "/tmp/anaconda-tb* file(s) for more details") # in the main thread, run exception handler self._main_loop_handleException(dump_info) else: log.debug( "In a non-main thread, sending a message with exception data" ) # not in the main thread, just send message with exception # data and let message handler run the exception handler in # the main thread exc_info = dump_info.exc_info # new Simpleline package is now used in TUI. Look if Simpleline is # initialized or if this is some fallback from GTK or other stuff. if App.is_initialized(): # if Simpleline is initialized enqueue exception there loop = App.get_event_loop() loop.enqueue_signal( ExceptionSignal(App.get_scheduler(), exception_info=exc_info)) else: hubQ.send_exception( (exc_info.type, exc_info.value, exc_info.stack))
def handleException(self, dump_info): """ Our own handleException method doing some additional stuff before calling the original python-meh's one. :type dump_info: an instance of the meh.DumpInfo class :see: python-meh's ExceptionHandler.handleException """ log.debug("running handleException") exception_lines = traceback.format_exception(*dump_info.exc_info) log.debug("\n".join(exception_lines)) ty = dump_info.exc_info.type value = dump_info.exc_info.value if (issubclass(ty, blivet.errors.StorageError) and value.hardware_fault) \ or (issubclass(ty, OSError) and value.errno == errno.EIO): # hardware fault or '[Errno 5] Input/Output error' hw_error_msg = _("The installation was stopped due to what " "seems to be a problem with your hardware. " "The exact error message is:\n\n%s.\n\n " "The installer will now terminate.") % str(value) self.intf.messageWindow(_("Hardware error occured"), hw_error_msg) sys.exit(0) else: try: from gi.repository import Gtk # XXX: Gtk stopped raising RuntimeError if it fails to # initialize. Horay! But will it stay like this? Let's be # cautious and raise the exception on our own to work in both # cases initialized = Gtk.init_check(None)[0] if not initialized: raise RuntimeError() if Gtk.main_level() > 0: # main loop is running, don't crash it by running another one # potentially from a different thread log.debug("Gtk running, queuing exception handler to the " "main loop") GLib.idle_add(self.run_handleException, dump_info) else: log.debug("Gtk not running, starting Gtk and running " "exception handler in it") super(AnacondaExceptionHandler, self).handleException( dump_info) except (RuntimeError, ImportError): log.debug("Gtk cannot be initialized") # X not running (Gtk cannot be initialized) if threadMgr.in_main_thread(): log.debug("In the main thread, running exception handler") if (issubclass (ty, CmdlineError)): cmdline_error_msg = _("\nThe installation was stopped due to " "incomplete spokes detected while running " "in non-interactive cmdline mode. Since there " "can not be any questions in cmdline mode, " "edit your kickstart file and retry " "installation.\nThe exact error message is: " "\n\n%s.\n\nThe installer will now terminate.") % str(value) # since there is no UI in cmdline mode and it is completely # non-interactive, we can't show a message window asking the user # to acknowledge the error; instead, print the error out and sleep # for a few seconds before exiting the installer print(cmdline_error_msg) time.sleep(10) sys.exit(0) else: print("\nAn unknown error has occured, look at the " "/tmp/anaconda-tb* file(s) for more details") # in the main thread, run exception handler super(AnacondaExceptionHandler, self).handleException( dump_info) else: log.debug("In a non-main thread, sending a message with " "exception data") # not in the main thread, just send message with exception # data and let message handler run the exception handler in # the main thread exc_info = dump_info.exc_info hubQ.send_exception((exc_info.type, exc_info.value, exc_info.stack))
def handleException(self, dump_info): """ Our own handleException method doing some additional stuff before calling the original python-meh's one. :type dump_info: an instance of the meh.DumpInfo class :see: python-meh's ExceptionHandler.handleException """ log.debug("running handleException") ty = dump_info.exc_info.type value = dump_info.exc_info.value if (issubclass(ty, blivet.errors.StorageError) and value.hardware_fault) \ or (issubclass(ty, OSError) and value.errno == errno.EIO): # hardware fault or '[Errno 5] Input/Output error' hw_error_msg = _("The installation was stopped due to what " "seems to be a problem with your hardware. " "The exact error message is:\n\n%s.\n\n " "The installer will now terminate.") % str(value) self.intf.messageWindow(_("Hardware error occured"), hw_error_msg) sys.exit(0) else: try: from gi.repository import Gtk # XXX: Gtk stopped raising RuntimeError if it fails to # initialize. Horay! But will it stay like this? Let's be # cautious and raise the exception on our own to work in both # cases initialized = Gtk.init_check(None)[0] if not initialized: raise RuntimeError() if Gtk.main_level() > 0: # main loop is running, don't crash it by running another one # potentially from a different thread log.debug("Gtk running, queuing exception handler to the " "main loop") GLib.idle_add(self.run_handleException, dump_info) else: log.debug("Gtk not running, starting Gtk and running " "exception handler in it") super(AnacondaExceptionHandler, self).handleException(dump_info) except RuntimeError: log.debug("Gtk cannot be initialized") # X not running (Gtk cannot be initialized) if threadMgr.in_main_thread(): log.debug("In the main thread, running exception handler") print "An unknown error has occured, look at the "\ "/tmp/anaconda-tb* file(s) for more details" # in the main thread, run exception handler super(AnacondaExceptionHandler, self).handleException(dump_info) else: log.debug("In a non-main thread, sending a message with " "exception data") # not in the main thread, just send message with exception # data and let message handler run the exception handler in # the main thread exc_info = dump_info.exc_info hubQ.send_exception( (exc_info.type, exc_info.value, exc_info.stack))
def handleException(self, dump_info): """ Our own handleException method doing some additional stuff before calling the original python-meh's one. :type dump_info: an instance of the meh.DumpInfo class :see: python-meh's ExceptionHandler.handleException """ log.debug("running handleException") ty = dump_info.exc_info.type value = dump_info.exc_info.value if issubclass(ty, blivet.errors.StorageError) and value.hardware_fault: hw_error_msg = _("The installation was stopped due to what " "seems to be a problem with your hardware. " "The exact error message is:\n\n%s.\n\n " "The installer will now terminate.") % str(value) self.intf.messageWindow(_("Hardware error occured"), hw_error_msg) sys.exit(0) else: try: # pylint: disable-msg=E0611 from gi.repository import Gtk # XXX: Gtk stopped raising RuntimeError if it fails to # initialize. Horay! But will it stay like this? Let's be # cautious and raise the exception on our own to work in both # cases (initialized, args) = Gtk.init_check(None) if not initialized: raise RuntimeError() if Gtk.main_level() > 0: # main loop is running, don't crash it by running another one # potentially from a different thread log.debug("Gtk running, queuing exception handler to the " "main loop") GLib.idle_add(self.run_handleException, dump_info) else: log.debug("Gtk not running, starting Gtk and running " "exception handler in it") super(AnacondaExceptionHandler, self).handleException(dump_info) except RuntimeError: log.debug("Gtk cannot be initialized") # X not running (Gtk cannot be initialized) if threadMgr.in_main_thread(): log.debug("In the main thread, running exception handler") if (issubclass(ty, CmdlineError)): cmdline_error_msg = _( "\nThe installation was stopped due to an " "error which occurred while running in " "non-interactive cmdline mode. Since there can " "not be any questions in cmdline mode, edit " "your kickstart file and retry installation. " "\nThe exact error message is: \n\n%s. \n\nThe " "installer will now terminate.") % str(value) # since there is no UI in cmdline mode and it is completely # non-interactive, we can't show a message window asking the user # to acknowledge the error; instead, print the error out and sleep # for a few seconds before exiting the installer print(cmdline_error_msg) time.sleep(180) sys.exit() else: print "An unknown error has occured, look at the "\ "/tmp/anaconda-tb* file(s) for more details" # in the main thread, run exception handler super(AnacondaExceptionHandler, self).handleException(dump_info) else: log.debug("In a non-main thread, sending a message with " "exception data") # not in the main thread, just send message with exception # data and let message handler run the exception handler in # the main thread exc_info = dump_info.exc_info hubQ.send_exception( (exc_info.type, exc_info.value, exc_info.stack))
def handleException(self, dump_info): """ Our own handleException method doing some additional stuff before calling the original python-meh's one. :type dump_info: an instance of the meh.DumpInfo class :see: python-meh's ExceptionHandler.handleException """ log.debug("running handleException") exception_lines = traceback.format_exception(*dump_info.exc_info) log.critical("\n".join(exception_lines)) ty = dump_info.exc_info.type value = dump_info.exc_info.value if (issubclass(ty, blivet.errors.StorageError) and value.hardware_fault) \ or (issubclass(ty, OSError) and value.errno == errno.EIO): # hardware fault or '[Errno 5] Input/Output error' hw_error_msg = _("The installation was stopped due to what " "seems to be a problem with your hardware. " "The exact error message is:\n\n%s.\n\n " "The installer will now terminate.") % str(value) self.intf.messageWindow(_("Hardware error occurred"), hw_error_msg) sys.exit(0) else: try: from gi.repository import Gtk # XXX: Gtk stopped raising RuntimeError if it fails to # initialize. Horay! But will it stay like this? Let's be # cautious and raise the exception on our own to work in both # cases initialized = Gtk.init_check(None)[0] if not initialized: raise RuntimeError() # Attempt to grab the GUI initializing lock, do not block if not self._gui_lock.acquire(False): # the graphical interface is running, don't crash it by # running another one potentially from a different thread log.debug("Gtk running, queuing exception handler to the " "main loop") GLib.idle_add(self.run_handleException, dump_info) else: log.debug("Gtk not running, starting Gtk and running " "exception handler in it") super(AnacondaExceptionHandler, self).handleException(dump_info) except (RuntimeError, ImportError): log.debug("Gtk cannot be initialized") # X not running (Gtk cannot be initialized) if threadMgr.in_main_thread(): log.debug("In the main thread, running exception handler") if issubclass(ty, CmdlineError) or not self._interactive: if issubclass(ty, CmdlineError): cmdline_error_msg = _( "\nThe installation was stopped due to " "incomplete spokes detected while running " "in non-interactive cmdline mode. Since there " "cannot be any questions in cmdline mode, " "edit your kickstart file and retry " "installation.\nThe exact error message is: " "\n\n%s.\n\nThe installer will now terminate." ) % str(value) else: cmdline_error_msg = _( "\nRunning in cmdline mode, no interactive debugging " "allowed.\nThe exact error message is: " "\n\n%s.\n\nThe installer will now terminate." ) % str(value) # since there is no UI in cmdline mode and it is completely # non-interactive, we can't show a message window asking the user # to acknowledge the error; instead, print the error out and sleep # for a few seconds before exiting the installer print(cmdline_error_msg) time.sleep(10) sys.exit(1) else: print("\nAn unknown error has occured, look at the " "/tmp/anaconda-tb* file(s) for more details") # in the main thread, run exception handler super(AnacondaExceptionHandler, self).handleException(dump_info) else: log.debug("In a non-main thread, sending a message with " "exception data") # not in the main thread, just send message with exception # data and let message handler run the exception handler in # the main thread exc_info = dump_info.exc_info hubQ.send_exception( (exc_info.type, exc_info.value, exc_info.stack))