Exemplo n.º 1
0
    def on_exception(self, *exc_info):
        if self.exception_handler_called:
            # We only show one feedback dialog, even when there are two consecutive exceptions.
            return

        self.exception_handler_called = True

        exception_text = "".join(traceback.format_exception(*exc_info))
        logging.error(exception_text)
        self.tribler_crashed.emit(exception_text)

        self.delete_tray_icon()

        # Stop the download loop
        self.downloads_page.stop_loading_downloads()

        # Add info about whether we are stopping Tribler or not
        os.environ['TRIBLER_SHUTTING_DOWN'] = str(
            self.core_manager.shutting_down)

        if not self.core_manager.shutting_down:
            self.core_manager.stop(stop_app_on_shutdown=False)

        self.setHidden(True)

        if self.debug_window:
            self.debug_window.setHidden(True)

        dialog = FeedbackDialog(self, exception_text, self.tribler_version,
                                self.start_time)
        dialog.show()
Exemplo n.º 2
0
def test_feedback_dialog(tribler_api, window):
    def screenshot_dialog():
        screenshot(dialog, name="feedback_dialog")
        dialog.close()

    dialog = FeedbackDialog(window, "test", "1.2.3", 23)
    dialog.closeEvent = lambda _: None  # Otherwise, the application will stop
    QTimer.singleShot(1000, screenshot_dialog)
    dialog.exec_()
Exemplo n.º 3
0
def test_feedback_dialog(window):
    def screenshot_dialog():
        screenshot(dialog, name="feedback_dialog")
        dialog.close()

    reported_error = ReportedError('type', 'text', {})
    sentry_reporter = SentryReporter()
    dialog = FeedbackDialog(window, sentry_reporter, reported_error, "1.2.3",
                            23)
    dialog.closeEvent = lambda _: None  # Otherwise, the application will stop
    QTimer.singleShot(1000, screenshot_dialog)
    dialog.exec_()
Exemplo n.º 4
0
    def gui_error(self, *exc_info):
        if self._tribler_stopped:
            return

        info_type, info_error, tb = exc_info
        if info_type in self._handled_exceptions:
            return
        self._handled_exceptions.add(info_type)

        text = "".join(traceback.format_exception(info_type, info_error, tb))

        if info_type is CoreConnectTimeoutError:
            text = text + self.tribler_window.core_manager.core_traceback
            self._stop_tribler(text)

        self._logger.error(text)

        FeedbackDialog(
            parent=self.tribler_window,
            exception_text=text,
            tribler_version=self.tribler_window.tribler_version,
            start_time=self.tribler_window.start_time,
            sentry_event=SentryReporter.event_from_exception(info_error),
            error_reporting_requires_user_consent=True,
            stop_application_on_close=self._tribler_stopped,
            additional_tags={
                'source': 'gui'
            }).show()
Exemplo n.º 5
0
    def core_error(self, reported_error: ReportedError):
        if self._tribler_stopped or reported_error.type in self._handled_exceptions:
            return

        error_text = f'{reported_error.text}\n{reported_error.long_text}'
        self._logger.error(error_text)

        if reported_error.should_stop:
            self._stop_tribler(error_text)

        FeedbackDialog(parent=self.tribler_window,
                       sentry_reporter=gui_sentry_reporter,
                       reported_error=reported_error,
                       tribler_version=self.tribler_window.tribler_version,
                       start_time=self.tribler_window.start_time,
                       stop_application_on_close=self._tribler_stopped,
                       additional_tags={
                           'source': 'core'
                       }).show()
Exemplo n.º 6
0
    def core_error(self, text, core_event):
        if self._tribler_stopped:
            return

        self._logger.error(text)

        self._stop_tribler(text)

        FeedbackDialog(parent=self.tribler_window,
                       exception_text=text,
                       tribler_version=self.tribler_window.tribler_version,
                       start_time=self.tribler_window.start_time,
                       sentry_event=core_event['sentry_event'],
                       error_reporting_requires_user_consent=core_event[
                           'error_reporting_requires_user_consent'],
                       stop_application_on_close=self._tribler_stopped,
                       additional_tags={
                           'source': 'core'
                       }).show()
Exemplo n.º 7
0
    def test_feedback_dialog_report_sent(self):
        def screenshot_dialog():
            self.screenshot(dialog, name="feedback_dialog")
            dialog.close()

        def on_report_sent(response):
            self.assertTrue(response[u'sent'])

        dialog = FeedbackDialog(window, "Tribler GUI Test to test sending crash report works", "1.2.3", 23)
        dialog.closeEvent = lambda _: None  # Otherwise, the application will stop
        dialog.on_report_sent = on_report_sent
        QTest.mouseClick(dialog.send_report_button, Qt.LeftButton)
        QTimer.singleShot(1000, screenshot_dialog)
        dialog.exec_()
Exemplo n.º 8
0
    def gui_error(self, *exc_info):
        if exc_info and len(exc_info) == 3:
            info_type, info_error, tb = exc_info
            text = "".join(
                traceback.format_exception(info_type, info_error, tb))
            self._logger.error(text)

        if self._tribler_stopped:
            return

        if gui_sentry_reporter.global_strategy == SentryStrategy.SEND_SUPPRESSED:
            self._logger.info(
                f'GUI error was suppressed and not sent to Sentry: {info_type.__name__}: {info_error}'
            )
            return

        if info_type in self._handled_exceptions:
            return
        self._handled_exceptions.add(info_type)

        is_core_exception = issubclass(info_type, CoreError)
        if is_core_exception:
            text = text + self.tribler_window.core_manager.last_core_stderr_output
            self._stop_tribler(text)

        reported_error = ReportedError(
            type=type(info_type).__name__,
            text=text,
            event=gui_sentry_reporter.event_from_exception(info_error),
        )

        FeedbackDialog(
            parent=self.tribler_window,
            sentry_reporter=gui_sentry_reporter,
            reported_error=reported_error,
            tribler_version=self.tribler_window.tribler_version,
            start_time=self.tribler_window.start_time,
            stop_application_on_close=self._tribler_stopped,
            additional_tags={
                'source': 'gui'
            },
            retrieve_error_message_from_stacktrace=is_core_exception).show()
Exemplo n.º 9
0
def test_feedback_dialog_report_sent(window):
    def screenshot_dialog():
        screenshot(dialog, name="feedback_dialog")
        dialog.close()

    def on_report_sent():
        on_report_sent.did_send_report = True

    on_report_sent.did_send_report = False
    reported_error = ReportedError(
        '', 'Tribler GUI Test to test sending crash report works', {})
    sentry_reporter = SentryReporter()
    dialog = FeedbackDialog(window, sentry_reporter, reported_error, "1.2.3",
                            23)
    dialog.closeEvent = lambda _: None  # Otherwise, the application will stop
    dialog.on_report_sent = on_report_sent
    QTest.mouseClick(dialog.send_report_button, Qt.LeftButton)
    QTimer.singleShot(1000, screenshot_dialog)
    dialog.exec_()
    assert on_report_sent.did_send_report