def main(argv: Sequence[str] = None) -> int: argv = argv if argv is not None else sys.argv command_line_args = parse_commandline(argv) exit_code_str = command_line_args.exit_code exit_code = int(exit_code_str) if mantid.config['usagereports.enabled'] != '1': return exit_code # On Windows/macOS the plugin locations need to be known before starting # QApplication if command_line_args.qtdir is not None: QCoreApplication.addLibraryPath(command_line_args.qtdir) # Qt resources must be imported before QApplication starts importlib.import_module(f'mantidqt.dialogs.errorreports.resources_qt{QT_VERSION[0]}') if sys.platform == 'darwin': qtutils.force_layer_backing_BigSur() from qtpy.QtWidgets import QApplication app = QApplication(argv) # The strings APPNAME, ORG_DOMAIN, ORGANIZATION are duplicated from workbench.config app.setOrganizationName(command_line_args.org_name) app.setOrganizationDomain(command_line_args.org_domain) app.setApplicationName(command_line_args.application) QSettings.setDefaultFormat(QSettings.IniFormat) form = CrashReportPage(show_continue_terminate=False) presenter = ErrorReporterPresenter(form, exit_code_str, command_line_args.application) presenter.show_view() app.exec_() return exit_code
def initialize(): """Perform an initialization of the application instance. - Patches sys.exit so that it does nothing. - Uses WindowsSelectorEventLoop required by Tornado :return: A reference to the existing application instance """ if sys.platform == 'win32': # Tornado requires WindowsSelectorEventLoop # https://www.tornadoweb.org/en/stable/#installation import asyncio asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) if sys.platform == 'darwin': qtutils.force_layer_backing_BigSur() app = qapplication() # Monkey patching sys.exit so users can't kill # the application this way def fake_sys_exit(arg=[]): pass sys.exit = fake_sys_exit return app
def main() -> int: command_line_args = parse_commandline() exit_code_str = command_line_args.exit_code exit_code = int(exit_code_str) if mantid.config['usagereports.enabled'] != '1': return exit_code # On Windows/macOS the plugin locations need to be known before starting # QApplication if command_line_args.qtdir is not None: QCoreApplication.addLibraryPath(command_line_args.qtdir) # Qt resources must be imported before QApplication starts importlib.import_module( f'mantidqt.dialogs.errorreports.resources_qt{QT_VERSION[0]}') if sys.platform == 'darwin': qtutils.force_layer_backing_BigSur() from qtpy.QtWidgets import QApplication app = QApplication(sys.argv) form = CrashReportPage(show_continue_terminate=False) presenter = ErrorReporterPresenter(form, exit_code_str, command_line_args.application) presenter.show_view() app.exec_() return exit_code