Beispiel #1
0
def handle_error(err=None):
    traceback_str = traceback.format_exc()
    log(traceback_str)
    report_issue = False
    d = xbmcgui.Dialog()
    if d:
        message = dialog_error(err)

        if can_send_error(traceback_str):
            latest_version = issue_reporter.get_latest_version()
            version_string = '.'.join([str(i) for i in latest_version])
            if not issue_reporter.is_latest_version(config.VERSION, latest_version):
                message.append("Your version of this add-on is outdated. Please try upgrading to the latest version: v%s" % version_string)
                d.ok(*message)
                return

            # Only report if we haven't done one already
            try:
                message.append("Would you like to automatically report this error?")
                report_issue = d.yesno(*message)
            except:
                message.append("If this error continues to occur, please report it to our issue tracker.")
                d.ok(*message)
        else:
            # Just show the message
            d.ok(*message)
    if report_issue:
        log("Reporting issue to GitHub...")
        issue_url = issue_reporter.report_issue(traceback_str)
        if issue_url:
            # Split the url here to make sure it fits in our dialog
            split_url = issue_url.replace('/xbmc', ' /xbmc')
            d.ok("%s v%s Error" % (config.NAME, config.VERSION), "Thanks! Your issue has been reported to: %s" % split_url)
            # Touch our file to prevent more than one error report
            save_last_error_report(traceback_str)
Beispiel #2
0
def handle_error(msg, exc=None):
    traceback_str = traceback.format_exc()
    log(traceback_str)
    report_issue = False

    # Don't show any dialogs when user cancels
    if traceback_str.find('SystemExit') > 0:
        return

    d = xbmcgui.Dialog()
    if d:
        message = dialog_error(msg)

        # Work out if we should allow an error report
        send_error = can_send_error(traceback_str)

        # Some transient network errors we don't want any reports about
        if ((traceback_str.find('The read operation timed out') > 0)
                or (traceback_str.find('IncompleteRead') > 0)
                or (traceback_str.find('HTTP Error 404: Not Found') > 0)):
            send_error = False

        # Any non-fatal errors, don't allow issue reporting
        if isinstance(exc, NRLException):
            send_error = False

        if send_error:
            latest_version = issue_reporter.get_latest_version()
            version_string = '.'.join([str(i) for i in latest_version])
            if not issue_reporter.is_latest_version(config.VERSION,
                                                    latest_version):
                message.append("Your version of this add-on is outdated. "
                               "Please try upgrading to the latest version: "
                               "v%s" % version_string)
                d.ok(*message)
                return

            # Only report if we haven't done one already
            try:
                message.append("Would you like to automatically "
                               "report this error?")
                report_issue = d.yesno(*message)
            except:
                message.append("If this error continues to occur, "
                               "please report it to our issue tracker.")
                d.ok(*message)
        else:
            # Just show the message
            d.ok(*message)

    if report_issue:
        log("Reporting issue to GitHub...")
        issue_url = issue_reporter.report_issue(traceback_str)
        if issue_url:
            # Split the url here to make sure it fits in our dialog
            split_url = issue_url.replace('/xbmc', ' /xbmc')
            d.ok("%s v%s Error" % (config.NAME, config.VERSION),
                 "Thanks! Your issue has been reported to: %s" % split_url)
            # Touch our file to prevent more than one error report
            save_last_error_report(traceback_str)
Beispiel #3
0
def handle_error(msg, exc=None):
    traceback_str = traceback.format_exc()
    log(traceback_str)
    report_issue = False

    # Don't show any dialogs when user cancels
    if traceback_str.find('SystemExit') > 0:
        return

    d = xbmcgui.Dialog()
    if d:
        message = dialog_error(msg)

        # Work out if we should allow an error report
        send_error = can_send_error(traceback_str)

        # Some transient network errors we don't want any reports about
        if ((traceback_str.find('The read operation timed out') > 0) or
            (traceback_str.find('IncompleteRead') > 0) or
            (traceback_str.find('HTTP Error 404: Not Found') > 0)):
                send_error = False

        # Any non-fatal errors, don't allow issue reporting
        if isinstance(exc, AFLVideoException):
            send_error = False

        if send_error:
            latest_version = issue_reporter.get_latest_version()
            version_string = '.'.join([str(i) for i in latest_version])
            if not issue_reporter.is_latest_version(config.VERSION,
                                                    latest_version):
                message.append("Your version of this add-on is outdated. "
                               "Please try upgrading to the latest version: "
                               "v%s" % version_string)
                d.ok(*message)
                return

            # Only report if we haven't done one already
            try:
                message.append("Would you like to automatically "
                               "report this error?")
                report_issue = d.yesno(*message)
            except:
                message.append("If this error continues to occur, "
                               "please report it to our issue tracker.")
                d.ok(*message)
        else:
            # Just show the message
            d.ok(*message)

    if report_issue:
        log("Reporting issue to GitHub...")
        issue_url = issue_reporter.report_issue(traceback_str)
        if issue_url:
            # Split the url here to make sure it fits in our dialog
            split_url = issue_url.replace('/xbmc', ' /xbmc')
            d.ok("%s v%s Error" % (config.NAME, config.VERSION),
                 "Thanks! Your issue has been reported to: %s" % split_url)
            # Touch our file to prevent more than one error report
            save_last_error_report(traceback_str)
Beispiel #4
0
def handle_error(message):
    """Issue reporting handler

    This function should be called in the exception part of a try/catch block
    and provides the user (in some cases) the ability to send an error report.

    Tests are performed to ensure we don't accept some user network type
    errors (like timeouts, etc), any errors from old versions of an add-on or
    any duplicate reports from a user.
    """
    exc_type, exc_value, exc_traceback = sys.exc_info()

    # Don't show any dialogs when user cancels
    if exc_type.__name__ == 'SystemExit':
        return

    trace = traceback.format_exc()
    log(trace)

    # AttributeError: global name 'foo' is not defined
    error = '%s: %s' % (exc_type.__name__, ', '.join(
        ensure_ascii(e) for e in exc_value.args))

    message = format_dialog_error(message)

    import issue_reporter

    connection_info = issue_reporter.get_connection_info()

    if not is_valid_country(connection_info, message):
        return

    is_reportable = issue_reporter.is_reportable(exc_type, exc_value,
                                                 exc_traceback)

    # If already reported, or a non-reportable error, just show the error
    if not issue_reporter.not_already_reported(error) or not is_reportable:
        xbmcgui.Dialog().ok(*message)
        return

    github_repo = '%s/%s' % (GITHUB_ORG, get_addon_id())
    latest = issue_reporter.get_latest_version(github_repo)
    version = get_addon_version()

    if issue_reporter.is_not_latest_version(version, latest):
        message.append('Your version of this add-on (v%s) is outdated. Please '
                       'upgrade to the latest version: '
                       'v%s' % (version, latest))
        xbmcgui.Dialog().ok(*message)
        return

    if is_reportable:
        message.append('Would you like to automatically ' 'report this error?')
        if xbmcgui.Dialog().yesno(*message):
            issue_url = send_report(error,
                                    trace=trace,
                                    connection_info=connection_info)
            if issue_url:
                issue_reporter.save_last_error_report(error)
Beispiel #5
0
def handle_error(err=None):
    traceback_str = traceback.format_exc()
    log(traceback_str)
    report_issue = False
    d = xbmcgui.Dialog()
    if d:
        message = dialog_error(err)

        if can_send_error(traceback_str):
            latest_version = issue_reporter.get_latest_version()
            version_string = '.'.join([str(i) for i in latest_version])
            if not issue_reporter.is_latest_version(config.VERSION,
                                                    latest_version):
                message.append(
                    "Your version of this add-on is outdated. Please try upgrading to the latest version: v%s"
                    % version_string)
                d.ok(*message)
                return

            # Only report if we haven't done one already
            try:
                message.append(
                    "Would you like to automatically report this error?")
                report_issue = d.yesno(*message)
            except:
                message.append(
                    "If this error continues to occur, please report it to our issue tracker."
                )
                d.ok(*message)
        else:
            # Just show the message
            d.ok(*message)
    if report_issue:
        log("Reporting issue to GitHub...")
        issue_url = issue_reporter.report_issue(traceback_str)
        if issue_url:
            # Split the url here to make sure it fits in our dialog
            split_url = issue_url.replace('/xbmc', ' /xbmc')
            d.ok("%s v%s Error" % (config.NAME, config.VERSION),
                 "Thanks! Your issue has been reported to: %s" % split_url)
            # Touch our file to prevent more than one error report
            save_last_error_report(traceback_str)