diff --git a/Furious/Externals/GenTranslation.py b/Furious/Externals/GenTranslation.py index e57b76a..7c035bc 100644 --- a/Furious/Externals/GenTranslation.py +++ b/Furious/Externals/GenTranslation.py @@ -994,22 +994,6 @@ TRANSLATION = { "ZH": "不修改系统代理", "isReviewed": "True" }, - "Furious is not able to run on this operating system": { - "source": [ - "Furious.__main__" - ], - "RU": "Furious не может работать в этой операционной системе", - "ZH": "Furious无法在此操作系统上运行", - "isReviewed": "True" - }, - "Operating system information": { - "source": [ - "Furious.__main__" - ], - "RU": "Информация об операционной системе", - "ZH": "操作系统信息", - "isReviewed": "True" - }, "Furious encountered an internal error and needs to be stopped": { "source": [ "Furious.__main__" diff --git a/Furious/Interface/Application.py b/Furious/Interface/Application.py index 4eb3594..80836d8 100644 --- a/Furious/Interface/Application.py +++ b/Furious/Interface/Application.py @@ -32,7 +32,6 @@ class ApplicationRunner: ExitSuccess = 0 UnknownException = 61 - PlatformNotSupported = 62 AssertionError = 63 def __init__(self, *args, **kwargs): diff --git a/Furious/__main__.py b/Furious/__main__.py index ccd7a06..525f6bd 100644 --- a/Furious/__main__.py +++ b/Furious/__main__.py @@ -29,7 +29,6 @@ from Furious.Application import DesktopApplication from PySide6 import QtCore from PySide6.QtGui import QDesktopServices -import os import sys import logging import functools @@ -72,91 +71,49 @@ def runAppMain(): # For Qt runtime. Not used _app = DesktopApplication(sys.argv) - if exitcode == ApplicationRunner.ExitCode.PlatformNotSupported.value: - mbox = AppQMessageBox(icon=AppQMessageBox.Icon.Critical) - - mbox.setWindowIcon(bootstrapIcon('rocket-takeoff-window.svg')) - mbox.setWindowTitle(_(APPLICATION_NAME)) - mbox.setText( - _(f'{APPLICATION_NAME} is not able to run on this operating system') + if exitcode == ApplicationRunner.ExitCode.AssertionError.value: + # Assertion error + text = _( + f'{APPLICATION_NAME} encountered an internal error and needs to be stopped' ) - - if hasattr(os, 'uname'): - # Unix-like OS - unameTuple = ( - 'sysname', - 'nodename', - 'release', - 'version', - 'machine', - ) - - mbox.setInformativeText( - _('Operating system information') - + '\n' - + '\n'.join( - list(f'{arg}: {val}' for arg, val in zip(unameTuple, os.uname())) - ) - ) - - # Show the MessageBox and wait for the user to close it - mbox.exec() else: - if exitcode == ApplicationRunner.ExitCode.AssertionError.value: - # Assertion error - text = _( - f'{APPLICATION_NAME} encountered an internal error and needs to be stopped' - ) - else: - # Unknown exception - text = _( - f'{APPLICATION_NAME} stopped unexpectedly due to an unknown exception' - ) + # Unknown exception + text = _(f'{APPLICATION_NAME} stopped unexpectedly due to an unknown exception') - mbox = AppQMessageBox(icon=AppQMessageBox.Icon.Critical) + mbox = AppQMessageBox(icon=AppQMessageBox.Icon.Critical) - mbox.setWindowIcon(bootstrapIcon('rocket-takeoff-window.svg')) - mbox.setWindowTitle(_(APPLICATION_NAME)) - mbox.setText(text) + mbox.setWindowIcon(bootstrapIcon('rocket-takeoff-window.svg')) + mbox.setWindowTitle(_(APPLICATION_NAME)) + mbox.setText(text) - if process.fileWritten.value: - # Crash log saved - crashLogFile = str(CRASH_LOG_DIR / process.logFileName) + if process.fileWritten.value: + # Crash log saved + crashLogFile = str(CRASH_LOG_DIR / process.logFileName) - logger.info(f'crash log has been saved to {crashLogFile}') + logger.info(f'crash log has been saved to {crashLogFile}') - mbox.setInformativeText( - _('Crash log has been saved to') + f' {crashLogFile}' - ) - button0 = mbox.addButton( - _('Open crash log'), AppQMessageBox.ButtonRole.AcceptRole - ) - button1 = mbox.addButton(_('OK'), AppQMessageBox.ButtonRole.RejectRole) + mbox.setInformativeText(_('Crash log has been saved to') + f' {crashLogFile}') + openCrashLogButton = mbox.addButton( + _('Open crash log'), AppQMessageBox.ButtonRole.AcceptRole + ) + mbox.addButton(_('OK'), AppQMessageBox.ButtonRole.RejectRole) - def handleButtonClicked(button): - """Handle button clicked.""" - if button == button0: - # Open - if QDesktopServices.openUrl( - QtCore.QUrl.fromLocalFile(crashLogFile) - ): - logger.info(f'open crash log {crashLogFile} success') - else: - logger.error(f'open crash log {crashLogFile} failed') - else: - # OK. Do nothing - pass + def handleButtonClicked(button): + """Open the saved crash log when its action is selected.""" + if button != openCrashLogButton: + return - mbox.buttonClicked.connect(handleButtonClicked) + if QDesktopServices.openUrl(QtCore.QUrl.fromLocalFile(crashLogFile)): + logger.info(f'open crash log {crashLogFile} success') + else: + logger.error(f'open crash log {crashLogFile} failed') - # Show the MessageBox and wait for the user to close it - mbox.exec() - else: - # Crash log wasn't saved - logger.info(f'crash log was not saved') + mbox.buttonClicked.connect(handleButtonClicked) + else: + logger.info('crash log was not saved') - # Show the MessageBox and wait for the user to close it - mbox.exec() + # Keep the fallback application's local message box alive until dismissal. + mbox.exec() sys.exit(exitcode) diff --git a/tests/test_interface.py b/tests/test_interface.py index 7519ac4..6deb6dd 100644 --- a/tests/test_interface.py +++ b/tests/test_interface.py @@ -104,6 +104,7 @@ class InterfaceContractTest(unittest.TestCase): """Protect process exit values consumed by callers and host runtimes.""" self.assertEqual(ApplicationRunner.ExitCode.ExitSuccess.value, 0) self.assertEqual(ApplicationRunner.ExitCode.UnknownException.value, 61) + self.assertEqual(ApplicationRunner.ExitCode.AssertionError.value, 63) self.assertEqual(CoreRuntime.ExitCode.ConfigurationError.value, 23) self.assertEqual( CoreRuntime.ExitCode.ServerStartFailure.value,