From d4716c4f400ee9a3b927f016a5be0e8da7521ca4 Mon Sep 17 00:00:00 2001 From: Alan O'Callaghan Date: Wed, 30 Oct 2024 17:44:03 +0000 Subject: [PATCH] Windows bodge --- qubalab/images/qupath_server.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/qubalab/images/qupath_server.py b/qubalab/images/qupath_server.py index af91112..83a440a 100644 --- a/qubalab/images/qupath_server.py +++ b/qubalab/images/qupath_server.py @@ -95,8 +95,10 @@ def _read_block(self, level: int, region: Region2D) -> np.ndarray: self._gateway.entry_point.writeImageRegion(self._qupath_server, request, temp_path) image = bytes_to_image(temp_path, self.metadata.is_rgb, ImageShape(region.width, region.height, c=self.metadata.n_channels)) - - os.remove(temp_path) + ## on Windows, this fails because the file handle is open elsewhere + ## slightly bad manners to pollute tempfiles but should be insignificant + if not os.name == "nt": + os.remove(temp_path) else: format = 'png' if self.metadata.is_rgb else "imagej tiff"