def send_report(title, trace=None, connection_info=None, user_initiated=False): try: import issue_reporter log("Reporting issue to GitHub") if not connection_info: connection_info = issue_reporter.get_connection_info() if user_initiated: if not is_valid_country(connection_info): return # Show dialog spinner, and close afterwards xbmc.executebuiltin("ActivateWindow(busydialog)") report_url = issue_reporter.report_issue(title, trace, connection_info) split_url = report_url.replace('/issue-reports', ' /issue-reports') dialog_message( ['Thanks! Your issue has been reported to: ', split_url]) return report_url except Exception: traceback.print_exc() log('Failed to send report') finally: xbmc.executebuiltin("Dialog.Close(busydialog)")
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)
def send_report(title, trace=None, connection_info=None, user_initiated=False): try: dialog_progress = xbmcgui.DialogProgress() dialog_created = False import issue_reporter log("Reporting issue to GitHub") if not connection_info: connection_info = issue_reporter.get_connection_info() if user_initiated: if not is_valid_country(connection_info): return if not xbmcgui.Dialog().yesno( '{0} v{1}'.format(get_addon_name(), get_addon_version()), 'Please confirm you would like to submit an issue report ' 'and upload your logfile to Github. '): log('Cancelled user report') return # Show dialog spinner, and close afterwards dialog_progress.create('Uploading issue to GitHub...') dialog_created = True if not issue_reporter.is_supported_addon(): xbmcgui.Dialog().ok( '{0} v{1}'.format(get_addon_name(), get_addon_version()), 'This add-on is no longer supported by Aussie Add-ons.') log('Add-on not supported, aborting issue report.') return report_url = issue_reporter.report_issue(title, trace, connection_info) split_url = report_url.replace('/issue-reports', ' /issue-reports') dialog_message([ 'Thanks! Your issue has been reported to: ', split_url, 'Please visit and describe the issue in order for ' 'us to assist.' ]) return report_url except Exception: traceback.print_exc() log('Failed to send report') finally: if dialog_created: dialog_progress.close()