Adjust catching of InvocationCancelledError so stiching reports as cancelled

Also stop stitching scans that error. This is a legacy from regular errors
This commit is contained in:
Julian Stirling 2026-06-30 20:33:41 +01:00
parent c5867b02e9
commit c146b89e74

View file

@ -313,17 +313,18 @@ class SmartScanThing(OFMThing):
# If _scan_data is set then scan started # If _scan_data is set then scan started
if self._scan_data is not None: if self._scan_data is not None:
self._return_to_starting_position() self._return_to_starting_position()
if not isinstance(e, scan_directories.NotEnoughFreeSpaceError):
# Don't stitch if drive is full (already logged)
self.logger.info(
"Attempting to stitch and archive the images acquired so far."
)
self._perform_final_stitch()
if self._ongoing_scan is not None: if self._ongoing_scan is not None:
# Save any final messages even if there is an exception. # Save any final messages even if there is an exception.
self._ongoing_scan.save_scan_log(self) self._ongoing_scan.save_scan_log(self)
# Error must be raised so UI gives correct output # Error must be raised so UI gives correct output
raise e raise e
except lt.exceptions.InvocationCancelledError as e:
# InvocationCancelledError is caught for scanning but not for stitching
# If raised we still need to save the scan log.
if self._ongoing_scan is not None:
self._ongoing_scan.save_scan_log(self)
# Reraise so the action reports as cancelled if stitching is cancelled.
raise e
finally: finally:
# However the scan finishes, unset all variables and release lock # However the scan finishes, unset all variables and release lock
self._ongoing_scan = None self._ongoing_scan = None
@ -728,9 +729,10 @@ class SmartScanThing(OFMThing):
) )
try: try:
final_stitcher.run() final_stitcher.run()
except lt.exceptions.InvocationCancelledError: except lt.exceptions.InvocationCancelledError as e:
# Sleep for 1 second just to allow invocation logs to pass to user. # Sleep for 1 second just to allow invocation logs to pass to user.
time.sleep(1) time.sleep(1)
raise e
except ChildProcessError as e: except ChildProcessError as e:
self.logger.error(f"Stitching failed: {e}", exc_info=e) self.logger.error(f"Stitching failed: {e}", exc_info=e)