示例#1
0
 def test_main(self):
     try:
         1 / 0
     except:
         result = format_exception(*sys.exc_info())
         self.assertTrue(isinstance(result, list))
         self.assertTrue(all([isinstance(l, str) for l in result]))
示例#2
0
def get_github_issue_url(exc_info):
    """Gives an URL for a pre-filled github issue based on an exception

    Returns:
        str
    """

    error_title = (text_type(exc_info[1]).strip() or u"\n").splitlines()[0]
    title = u"[Error] %s: %s" % (exc_info[0].__name__, error_title)
    error_text = u"\n".join(format_exception(*exc_info))
    body = u"""\
* What did you try to do when the error occurred?

Error Details:
```
%s

Version: %s
Python: %s
Platform: %s
```
""" % (error_text, quodlibet.get_build_description(), sys.version,
       platform.platform())

    return build_issue_url(title, body)
示例#3
0
 def test_main(self):
     try:
         1 / 0
     except:
         result = format_exception(*sys.exc_info())
         self.assertTrue(isinstance(result, list))
         self.assertTrue(all([isinstance(l, text_type) for l in result]))
示例#4
0
def run_error_dialogs(exc_info, sentry_error):
    error_text = u"%s: %s" % (exc_info[0].__name__,
                              (text_type(exc_info[1]).strip()
                               or u"\n").splitlines()[0])
    error_text += u"\n------\n"
    error_text += u"\n".join(format_exception(*exc_info))

    # Don't reshow the error dialog in case the user wanted to quit the app
    # but due to the error state more errors pile up..
    if app.is_quitting:
        return

    window = find_active_window()
    if window is None:
        return

    # XXX: This does blocking IO and uses nested event loops... but it's simple
    dialog = ErrorDialog(window,
                         error_text,
                         show_bug_report=(sentry_error is None))
    while 1:
        response = dialog.run()
        if response == ErrorDialog.RESPONSE_QUIT:
            dialog.destroy()
            app.quit()
        elif response == ErrorDialog.RESPONSE_SUBMIT:
            dialog.hide()
            submit_dialog = SubmitErrorDialog(window,
                                              sentry_error.get_report())
            submit_response = submit_dialog.run()

            if submit_response == SubmitErrorDialog.RESPONSE_SUBMIT:
                sentry_error.set_comment(submit_dialog.get_comment())
                timeout_seconds = 5
                try:
                    sentry_error.send(timeout_seconds)
                except SentryError:
                    print_exc()
                submit_dialog.destroy()
                dialog.destroy()
            else:
                submit_dialog.destroy()
                dialog.show()
                continue
        elif response == ErrorDialog.RESPONSE_BUGREPORT:
            url = get_github_issue_url(exc_info)
            website(url)
            dialog.destroy()
        else:
            dialog.destroy()
        break
示例#5
0
文件: main.py 项目: Muges/quodlibet
def run_error_dialogs(exc_info, sentry_error):
    assert sentry_error is not None

    error_text = u"%s: %s" % (
        exc_info[0].__name__,
        (text_type(exc_info[1]).strip() or u"\n").splitlines()[0])
    error_text += u"\n------\n"
    error_text += u"\n".join(format_exception(*exc_info))

    # Don't reshow the error dialog in case the user wanted to quit the app
    # but due to the error state more errors pile up..
    if app.is_quitting:
        return

    window = find_active_window()
    if window is None:
        return

    # XXX: This does blocking IO and uses nested event loops... but it's simple
    dialog = ErrorDialog(window, error_text)
    while 1:
        response = dialog.run()
        if response == ErrorDialog.RESPONSE_QUIT:
            dialog.destroy()
            app.quit()
        elif response == ErrorDialog.RESPONSE_SUBMIT:
            dialog.hide()
            submit_dialog = SubmitErrorDialog(
                window, sentry_error.get_report())
            submit_response = submit_dialog.run()

            if submit_response == SubmitErrorDialog.RESPONSE_SUBMIT:
                sentry_error.set_comment(submit_dialog.get_comment())
                timeout_seconds = 5
                try:
                    sentry_error.send(timeout_seconds)
                except SentryError:
                    print_exc()
                submit_dialog.destroy()
                dialog.destroy()
            else:
                submit_dialog.destroy()
                dialog.show()
                continue
        else:
            dialog.destroy()
        break
示例#6
0
def format_dump_header(type_, value, traceback):
    """Returns system information and the traceback as`text_type`"""

    lines = [
        u"=== SYSTEM INFORMATION:"
        u"",
        u"Quod Libet %s" % quodlibet.get_build_description(),
        u"Mutagen %s" % mutagen.version_string,
        u"Python %s %s" % (sys.version, sys.platform),
        u"Platform %s" % platform.platform(),
        u"=== STACK TRACE",
        u"",
    ]

    lines.extend(format_exception(type_, value, traceback))
    lines.append(u"")
    return os.linesep.join(lines)
示例#7
0
def format_dump_header(type_, value, traceback):
    """Returns system information and the traceback as`text_type`"""

    lines = [
        u"=== SYSTEM INFORMATION:"
        u"",
        u"Quod Libet %s" % quodlibet.get_build_description(),
        u"Mutagen %s" % mutagen.version_string,
        u"Python %s %s" % (sys.version, sys.platform),
        u"Platform %s" % platform.platform(),
        u"=== STACK TRACE",
        u"",
    ]

    lines.extend(format_exception(type_, value, traceback))
    lines.append(u"")
    return os.linesep.join(lines)
示例#8
0
文件: main.py 项目: elfalem/quodlibet
def run_error_dialogs(exc_info, sentry_error):
    error_text = u"%s: %s" % (
        exc_info[0].__name__,
        (text_type(exc_info[1]).strip() or u"\n").splitlines()[0])
    error_text += u"\n------\n"
    error_text += u"\n".join(format_exception(*exc_info))

    window = find_active_window()
    if window is None:
        return

    # XXX: This does blocking IO and uses nested event loops... but it's simple
    dialog = ErrorDialog(
        window, error_text, show_bug_report=(sentry_error is None))
    while 1:
        response = dialog.run()
        if response == ErrorDialog.RESPONSE_QUIT:
            dialog.destroy()
            app.quit()
        elif response == ErrorDialog.RESPONSE_SUBMIT:
            dialog.hide()
            submit_dialog = SubmitErrorDialog(
                window, sentry_error.get_report())
            submit_response = submit_dialog.run()

            if submit_response == SubmitErrorDialog.RESPONSE_SUBMIT:
                sentry_error.set_comment(submit_dialog.get_comment())
                timeout_seconds = 5
                try:
                    sentry_error.send(timeout_seconds)
                except SentryError:
                    print_exc()
                submit_dialog.destroy()
                dialog.destroy()
            else:
                submit_dialog.destroy()
                dialog.show()
                continue
        elif response == ErrorDialog.RESPONSE_BUGREPORT:
            url = get_github_issue_url(exc_info)
            website(url)
            dialog.destroy()
        else:
            dialog.destroy()
        break
示例#9
0
def format_dump_header(exc_info):
    """Returns system information and the traceback

    Args:
        exc_info (tuple): sys.exc_info() result tuple
    Returns:
        text_type
    """

    lines = [
        u"=== SYSTEM INFORMATION:"
        u"",
        u"Quod Libet %s" % quodlibet.get_build_description(),
        u"Mutagen %s" % mutagen.version_string,
        u"Python %s %s" % (sys.version, sys.platform),
        u"Platform %s" % platform.platform(),
        u"=== STACK TRACE",
        u"",
    ]

    lines.extend(format_exception(*exc_info))
    lines.append(u"")
    return os.linesep.join(lines)