Пример #1
0
 def test_getSetEnabled(self):
     UsageService.setEnabled(False)
     self.assertEquals(UsageService.isEnabled(),False)
     UsageService.setEnabled(True)
     self.assertEquals(UsageService.isEnabled(),True)
     UsageService.setEnabled(False)
     self.assertEquals(UsageService.isEnabled(),False)
Пример #2
0
 def test_getSetEnabled(self):
     UsageService.setEnabled(False)
     self.assertEqual(UsageService.isEnabled(), False)
     UsageService.setEnabled(True)
     self.assertEqual(UsageService.isEnabled(), True)
     UsageService.setEnabled(False)
     self.assertEqual(UsageService.isEnabled(), False)
Пример #3
0
def exception_logger(main_window, exc_type, exc_value, exc_traceback):
    """
    Captures ALL EXCEPTIONS.
    Prevents the Workbench from crashing silently, instead it logs the error on ERROR level.

    :param main_window: A reference to the main window, that will be used to close it in case of the user
                        choosing to terminate the execution.
    :param exc_type: The type of the exception
    :param exc_value: Value of the exception, typically contains the error message.
    :param exc_traceback: Stack trace of the exception.
    """
    logger.error("".join(
        traceback.format_exception(exc_type, exc_value, exc_traceback)))

    if UsageService.isEnabled():
        page = CrashReportPage(show_continue_terminate=True)
        presenter = ErrorReporterPresenter(
            page, '', 'workbench',
            traceback.format_exception(exc_type, exc_value, exc_traceback))
        presenter.show_view_blocking()
        if not page.continue_working:
            main_window.close()
    else:
        # show the exception message without the traceback
        WorkbenchErrorMessageBox(
            main_window,
            "".join(traceback.format_exception_only(exc_type,
                                                    exc_value))).exec_()
Пример #4
0
def main():
    if not UsageService.isEnabled():
        return int(command_line_args.exit_code)
    app = QtGui.QApplication(sys.argv)
    form = CrashReportPage(show_continue_terminate=False)
    ErrorReporterPresenter(form, command_line_args.exit_code)
    app.exec_()
    return int(command_line_args.exit_code)
    def error_handler(self, continue_working, share, name, email):
        if share == 0:
            errorReporter = ErrorReporter("mantidplot",
                                          UsageService.getUpTime(),
                                          UsageService.isEnabled(),
                                          self._exit_code, True, str(name),
                                          str(email))
            errorReporter.sendErrorReport()
        elif share == 1:
            errorReporter = ErrorReporter("mantidplot",
                                          UsageService.getUpTime(),
                                          UsageService.isEnabled(),
                                          self._exit_code, False, str(name),
                                          str(email))
            errorReporter.sendErrorReport()

        if not continue_working:
            self.error_log.error("Terminated by user.")
            self._view.quit()
        else:
            self.error_log.error("Continue working.")