From 2c237b66235255acfd9b44a95a04ba5488224330 Mon Sep 17 00:00:00 2001 From: David Perl Date: Mon, 27 Jul 2026 14:57:29 +0200 Subject: [PATCH] style: fix a few style issues by hand --- src/aare/devices/jfjoch.py | 6 +++--- src/aare/gui/gui.py | 25 ++++++++++------------ src/aare/gui/models/sample_queue_model.py | 4 ++-- src/aare/gui/models/user_sample_model.py | 6 +++--- src/aare/gui/tutorials/tutorial_manager.py | 4 ++-- src/aare/gui/tutorials/tutorial_runtime.py | 3 ++- 6 files changed, 23 insertions(+), 25 deletions(-) diff --git a/src/aare/devices/jfjoch.py b/src/aare/devices/jfjoch.py index 5b5cd05d..5b801f67 100644 --- a/src/aare/devices/jfjoch.py +++ b/src/aare/devices/jfjoch.py @@ -256,7 +256,7 @@ class JFJochWrapper: def detector(self) -> jfjoch_client.models.DetectorListElement: try: - l = self.__api.config_select_detector_get() + detector_list = self.__api.config_select_detector_get() except Exception as e: self._raise_jfjoch_error( f"JFJoch detector configuration retrieval failed: {e}", @@ -265,7 +265,7 @@ class JFJochWrapper: endpoint="config_select_detector_get", ) - if len(l.detectors) == 0: + if len(detector_list.detectors) == 0: raise JFJochCommunicationError( "JFJoch returned no configured detectors", operation="GET", @@ -275,7 +275,7 @@ class JFJochWrapper: ) try: - return l.detectors[l.current_id] + return detector_list.detectors[detector_list.current_id] except Exception as e: self._raise_jfjoch_error( "JFJoch returned an invalid selected detector entry", diff --git a/src/aare/gui/gui.py b/src/aare/gui/gui.py index bd103da2..777bb475 100644 --- a/src/aare/gui/gui.py +++ b/src/aare/gui/gui.py @@ -19,24 +19,24 @@ logger = setup_logger(LOGGER_NAME) def main(): """Wrapped gui as main function to make tests easier""" - splash = None + try: + basedir = os.path.dirname(__file__) + icon_path = os.path.join(basedir, "graphics/aaregui_logo.svg") + banner_path = os.path.join(basedir, "graphics/aare_banner.png") + splash_pix = QtGui.QPixmap(banner_path) + splash = LoadingSplashScreen(splash_pix) + except Exception as e: + logger.error(f"Failed to load resources for splash screen: {e}") + sys.exit(1) try: # define application app = QApplication(sys.argv) + app.setWindowIcon(QtGui.QIcon(icon_path)) app.setApplicationName("AareGUI") app.setApplicationVersion("0.3.1") app.setOrganizationName("PSI") app.setOrganizationDomain("psi.ch") - # set icon - basedir = os.path.dirname(__file__) - icon_path = os.path.join(basedir, "graphics/aaregui_logo.svg") - app.setWindowIcon(QtGui.QIcon(icon_path)) - - # show splash screen - banner_path = os.path.join(basedir, "graphics/aare_banner.png") - splash_pix = QtGui.QPixmap(banner_path) - splash = LoadingSplashScreen(splash_pix) splash.show() splash.set_progress(10, "Initializing Application...") @@ -199,16 +199,13 @@ def main(): logger.error(f"Error starting GUI: {e}") logger.error(f"Traceback: {traceback.format_exc()}") - try: - QMessageBox.critical( + QMessageBox.critical( None, "Fatal Error", f"An error occurred during startup. See console for details." f"\nPlease check the server is running and your network connection." f"\n\n{str(e)}\n\n", ) - except: - pass sys.exit(1) diff --git a/src/aare/gui/models/sample_queue_model.py b/src/aare/gui/models/sample_queue_model.py index 5452a610..47dd35d5 100644 --- a/src/aare/gui/models/sample_queue_model.py +++ b/src/aare/gui/models/sample_queue_model.py @@ -90,9 +90,9 @@ class SampleQueueSpreadsheet(QAbstractTableModel): row = parent.row() try: - l = SampleShortInfoList.model_validate_json(data.text()) + sample_data = SampleShortInfoList.model_validate_json(data.text()) self.beginResetModel() - for sample in l.s: + for sample in sample_data.s: updated_row = row updated_samples = [] for i in range(len(self.samples)): diff --git a/src/aare/gui/models/user_sample_model.py b/src/aare/gui/models/user_sample_model.py index 10e85340..95e8d863 100644 --- a/src/aare/gui/models/user_sample_model.py +++ b/src/aare/gui/models/user_sample_model.py @@ -180,12 +180,12 @@ class UserSampleSpreadsheet(QAbstractTableModel): def mimeData(self, indexes): mime_data = QMimeData() - l = SampleShortInfoList(s=[]) + sample_data = SampleShortInfoList(s=[]) for i in sorted(set(index.row() for index in indexes)): - l.s.append(self.__sorted_samples[i]) + sample_data.s.append(self.__sorted_samples[i]) - mime_data.setText(l.model_dump_json()) + mime_data.setText(sample_data.model_dump_json()) return mime_data def get_id(self, row: int) -> SampleShortInfo: diff --git a/src/aare/gui/tutorials/tutorial_manager.py b/src/aare/gui/tutorials/tutorial_manager.py index 099019d2..005a4dc5 100644 --- a/src/aare/gui/tutorials/tutorial_manager.py +++ b/src/aare/gui/tutorials/tutorial_manager.py @@ -554,13 +554,13 @@ class TutorialManager(QObject): return None - def _run_setup_actions(self, step: TutorialStep) -> None: + def _run_setup_actions(self, step: TutorialStepDefinition) -> None: if self.context is None: return for action in step.setup_actions: self.action_executor.execute_action(action, self.context) - def _run_cleanup_actions(self, step: TutorialStep) -> None: + def _run_cleanup_actions(self, step: TutorialStepDefinition) -> None: if self.context is None: return for action in step.cleanup_actions: diff --git a/src/aare/gui/tutorials/tutorial_runtime.py b/src/aare/gui/tutorials/tutorial_runtime.py index 5ddfd145..acee7266 100644 --- a/src/aare/gui/tutorials/tutorial_runtime.py +++ b/src/aare/gui/tutorials/tutorial_runtime.py @@ -14,6 +14,7 @@ from aare.gui.tutorials.tutorial_models import ( TutorialContext, TutorialEvent, TutorialScenario, + TutorialStepDefinition, TutorialTarget, TutorialTextRef, ) @@ -188,7 +189,7 @@ class CompletionEvaluator: self._event_bus = event_bus def is_step_complete( - self, step: TutorialStep, context: TutorialContext, *, target_clicked: bool = False + self, step: TutorialStepDefinition, context: TutorialContext, *, target_clicked: bool = False ) -> bool: if step.completion is None: return True