def wait(self): """Run a recursive mainloop until the command terminates. Raises an exception on error.""" if self.child is None: self.start() self.waiting = True while not self.done: g.mainloop() if self.done is not True: raise self.done
def show_exception(type, value, tb, auto_details=False): """Display this exception in an error box. The user has the options of ignoring the error, quitting the application and examining the exception in more detail. See also rox.report_exception().""" QUIT = 1 DETAILS = 2 SAVE = 3 brief = "".join(traceback.format_exception_only(type, value)) toplevel_ref() box = g.MessageDialog(None, 0, g.MESSAGE_ERROR, g.BUTTONS_NONE, brief) if not auto_details: button = ButtonMixed(g.STOCK_ZOOM_IN, _("_Details")) button.set_flags(g.CAN_DEFAULT) button.show() box.add_action_widget(button, DETAILS) box.add_button(g.STOCK_OK, g.RESPONSE_OK) box.set_default_response(g.RESPONSE_OK) box.set_position(g.WIN_POS_CENTER) box.set_title(_("Error")) reply = [] def response(box, resp): reply.append(resp) g.mainquit() box.connect("response", response) box.show() bug_report = "Traceback (most recent call last):\n" + "".join( traceback.format_stack(tb.tb_frame.f_back) + traceback.format_tb(tb) + traceback.format_exception_only(type, value) ) while 1: if auto_details: resp = DETAILS auto_details = False else: g.mainloop() resp = reply.pop() if resp == g.RESPONSE_OK or resp == g.RESPONSE_DELETE_EVENT: break if resp == SAVE: global savebox if savebox: savebox.destroy() def destroy(box): savebox = None from saving import StringSaver savebox = StringSaver(bug_report, "BugReport") savebox.connect("destroy", destroy) savebox.show() continue if resp == QUIT: sys.exit(1) assert resp == DETAILS box.set_response_sensitive(DETAILS, False) box.set_has_separator(False) button = ButtonMixed(g.STOCK_SAVE, _("_Bug Report")) button.set_flags(g.CAN_DEFAULT) button.show() box.add_action_widget(button, SAVE) box.action_area.set_child_secondary(button, True) button = ButtonMixed(g.STOCK_QUIT, _("Forced Quit")) button.set_flags(g.CAN_DEFAULT) button.show() box.add_action_widget(button, QUIT) box.action_area.set_child_secondary(button, True) ee = ExceptionExplorer(tb) box.vbox.pack_start(ee) ee.show() box.destroy() toplevel_unref()
def show_exception(type, value, tb, auto_details = False): """Display this exception in an error box. The user has the options of ignoring the error, quitting the application and examining the exception in more detail. See also rox.report_exception().""" QUIT = 1 DETAILS = 2 SAVE = 3 brief = ''.join(traceback.format_exception_only(type, value)) toplevel_ref() box = g.MessageDialog(None, 0, g.MESSAGE_ERROR, g.BUTTONS_NONE, brief) if not auto_details: button = ButtonMixed(g.STOCK_ZOOM_IN, _('_Details')) button.set_flags(g.CAN_DEFAULT) button.show() box.add_action_widget(button, DETAILS) box.add_button(g.STOCK_OK, g.RESPONSE_OK) box.set_default_response(g.RESPONSE_OK) box.set_position(g.WIN_POS_CENTER) box.set_title(_('Error')) reply = [] def response(box, resp): reply.append(resp) g.mainquit() box.connect('response', response) box.show() bug_report = 'Traceback (most recent call last):\n' + \ ''.join(traceback.format_stack(tb.tb_frame.f_back) + traceback.format_tb(tb) + traceback.format_exception_only(type, value)) while 1: if auto_details: resp = DETAILS auto_details = False else: g.mainloop() resp = reply.pop() if resp == g.RESPONSE_OK or resp == g.RESPONSE_DELETE_EVENT: break if resp == SAVE: global savebox if savebox: savebox.destroy() def destroy(box): savebox = None from saving import StringSaver savebox = StringSaver(bug_report, 'BugReport') savebox.connect('destroy', destroy) savebox.show() continue if resp == QUIT: sys.exit(1) assert resp == DETAILS box.set_response_sensitive(DETAILS, False) box.set_has_separator(False) button = ButtonMixed(g.STOCK_SAVE, _('_Bug Report')) button.set_flags(g.CAN_DEFAULT) button.show() box.add_action_widget(button, SAVE) box.action_area.set_child_secondary(button, True) button = ButtonMixed(g.STOCK_QUIT, _('Forced Quit')) button.set_flags(g.CAN_DEFAULT) button.show() box.add_action_widget(button, QUIT) box.action_area.set_child_secondary(button, True) ee = ExceptionExplorer(tb) box.vbox.pack_start(ee) ee.show() box.destroy() toplevel_unref()