def _write_exception_hook(self, exctype, value, tb): # NOTE: This exception hook depends on gtk, kiwi, twisted being present # In the future we might want it to run without some of these # dependencies, so we can crash reports that happens really # really early on for users with weird environments. if not self.entered_main: self._setup_twisted(raise_=False) try: from psycopg2 import OperationalError if exctype == OperationalError: from stoqlib.lib.message import error from stoqlib.lib.translation import stoqlib_gettext as _ return error(_('There was an error quering the database'), str(value)) except ImportError: pass appname = 'unknown' try: from stoq.gui.shell.shell import get_shell shell = get_shell() if shell: appname = shell.get_current_app_name() except ImportError: pass window_name = 'unknown' try: from stoqlib.gui.base.dialogs import get_current_toplevel window = get_current_toplevel() if window: window_name = window.get_name() except ImportError: pass log.info('An error occurred in application "%s", toplevel window=%s' % ( appname, window_name)) exc_lines = traceback.format_exception(exctype, value, tb) for line in ''.join(exc_lines).split('\n')[:-1]: log.error(line) from stoqlib.lib.crashreport import collect_traceback collect_traceback((exctype, value, tb)) if self.entered_main: return from stoqlib.gui.dialogs.crashreportdialog import show_dialog d = show_dialog() from twisted.internet import reactor d.addCallback(lambda *x: reactor.stop()) reactor.run() raise SystemExit
def _write_exception_hook(self, exctype, value, tb): # NOTE: This exception hook depends on gtk, kiwi, twisted being present # In the future we might want it to run without some of these # dependencies, so we can crash reports that happens really # really early on for users with weird environments. if not self.entered_main: self._setup_twisted(raise_=False) try: from psycopg2 import OperationalError if exctype == OperationalError: from stoqlib.lib.message import error from stoqlib.lib.translation import stoqlib_gettext as _ return error(_('There was an error quering the database'), str(value)) except ImportError: pass appname = 'unknown' try: from stoq.gui.shell.shell import get_shell shell = get_shell() if shell: appname = shell.get_current_app_name() except ImportError: pass window_name = 'unknown' try: from stoqlib.gui.base.dialogs import get_current_toplevel window = get_current_toplevel() if window: window_name = window.get_name() except ImportError: pass log.info('An error occurred in application "%s", toplevel window=%s' % (appname, window_name)) exc_lines = traceback.format_exception(exctype, value, tb) for line in ''.join(exc_lines).split('\n')[:-1]: log.error(line) from stoqlib.lib.crashreport import collect_traceback collect_traceback((exctype, value, tb)) if self.entered_main: return from stoqlib.gui.dialogs.crashreportdialog import show_dialog d = show_dialog() from twisted.internet import reactor d.addCallback(lambda *x: reactor.stop()) reactor.run() raise SystemExit
def _write_exception_hook(self, exctype, value, tb): try: from psycopg2 import OperationalError if exctype == OperationalError: from stoqlib.lib.message import error from stoqlib.lib.translation import stoqlib_gettext as _ return error(_('There was an error quering the database'), str(value)) except ImportError: pass appname = 'unknown' try: from stoq.gui.shell.shell import get_shell shell = get_shell() if shell: appname = shell.get_current_app_name() except ImportError: pass window_name = 'unknown' try: from stoqlib.gui.base.dialogs import get_current_toplevel window = get_current_toplevel() if window: window_name = window.get_name() except ImportError: pass log.info('An error occurred in application "%s", toplevel window=%s' % (appname, window_name)) exc_lines = traceback.format_exception(exctype, value, tb) for line in ''.join(exc_lines).split('\n')[:-1]: log.error(line) from stoqlib.lib.crashreport import collect_traceback collect_traceback((exctype, value, tb)) if self.entered_main: return from gi.repository import Gtk from stoqlib.gui.dialogs.crashreportdialog import show_dialog show_dialog(callback=Gtk.main_quit) Gtk.main() raise SystemExit
def _write_exception_hook(self, exctype, value, tb): try: from psycopg2 import OperationalError if exctype == OperationalError: from stoqlib.lib.message import error from stoqlib.lib.translation import stoqlib_gettext as _ return error(_('There was an error quering the database'), str(value)) except ImportError: pass appname = 'unknown' try: from stoq.gui.shell.shell import get_shell shell = get_shell() if shell: appname = shell.get_current_app_name() except ImportError: pass window_name = 'unknown' try: from stoqlib.gui.base.dialogs import get_current_toplevel window = get_current_toplevel() if window: window_name = window.get_name() except ImportError: pass log.info('An error occurred in application "%s", toplevel window=%s' % ( appname, window_name)) exc_lines = traceback.format_exception(exctype, value, tb) for line in ''.join(exc_lines).split('\n')[:-1]: log.error(line) from stoqlib.lib.crashreport import collect_traceback collect_traceback((exctype, value, tb)) if self.entered_main: return import gtk from stoqlib.gui.dialogs.crashreportdialog import show_dialog show_dialog(callback=gtk.main_quit) gtk.main() raise SystemExit
def _reload_filename(self, filename): shell = get_shell() app_name = shell.get_current_app_name() if app_name == "launcher": app_name = None shell.quit(restart=True, app=app_name)