From 2e6ba733452a5977a75e72c1434fcfb415176e7a Mon Sep 17 00:00:00 2001 From: Julian Stirling Date: Wed, 6 Aug 2025 15:52:52 +0000 Subject: [PATCH] Apply suggestions from code review of branch yet-another-smart-scan-refactor Co-authored-by: Joe Knapper --- src/openflexure_microscope_server/things/smart_scan.py | 3 ++- src/openflexure_microscope_server/utilities.py | 3 +++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/openflexure_microscope_server/things/smart_scan.py b/src/openflexure_microscope_server/things/smart_scan.py index d2bd4921..559aea47 100644 --- a/src/openflexure_microscope_server/things/smart_scan.py +++ b/src/openflexure_microscope_server/things/smart_scan.py @@ -702,7 +702,7 @@ class SmartScanThing(lt.Thing): """ scan_data_dict = self._scan_dir_manager.get_scan_data_dict(scan_name) if scan_data_dict is None: - logger.warning("Couldn't read scan data it may be missing or corrupt.") + logger.warning("Couldn't read scan data - it may be missing or corrupt.") final_stitcher = stitching.FinalStitcher( self._scan_dir_manager.img_dir_for(scan_name), logger=logger, @@ -712,6 +712,7 @@ class SmartScanThing(lt.Thing): scan_data_dict=scan_data_dict, ) try: + # start the final stitch, providing the cancel hook to allow aborting final_stitcher.start(cancel) except lt.exceptions.InvocationCancelledError: # Sleep for 1 second just to allow invocation logs to pass to user. diff --git a/src/openflexure_microscope_server/utilities.py b/src/openflexure_microscope_server/utilities.py index 07bc4fea..bbad56f9 100644 --- a/src/openflexure_microscope_server/utilities.py +++ b/src/openflexure_microscope_server/utilities.py @@ -128,8 +128,11 @@ def _wrap_and_catch_errors(target, error_buffer, *args, **kwargs): # Compiled regular expressions for unsafe characters +# Matches anything that isn't a-z, A-Z, 0-9, _, ., -, :, /, \ _WINDOWS_UNSAFE_PATTERN = re.compile(r"[^a-zA-Z0-9_.\-:/\\]") +# Matches anything that isn't a-z, A-Z, 0-9, _, ., -, \ _POSIX_UNSAFE_PATTERN = re.compile(r"[^a-zA-Z0-9_.\-/]") +# Matches anything that isn't a-z, A-Z, 0-9, _, ., - _NAME_UNSAFE_PATTERN = re.compile(r"[^a-zA-Z0-9_.\-]")