From 3e2797d72758d3deb22c0336efdaec26bd009b6c Mon Sep 17 00:00:00 2001 From: Arjen Hiemstra Date: Mon, 16 Nov 2015 12:20:03 +0100 Subject: [PATCH] Properly raise DeviceBusyError in RemovableDriveOutputDevice Contributes to CURA-448 --- .../RemovableDriveOutputDevice.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py b/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py index 89e4f6ff81..4ce9b6fd94 100644 --- a/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py +++ b/plugins/RemovableDriveOutputDevice/RemovableDriveOutputDevice.py @@ -22,7 +22,12 @@ class RemovableDriveOutputDevice(OutputDevice): self.setIconName("save_sd") self.setPriority(1) + self._writing = False + def requestWrite(self, node, file_name = None): + if self._writing: + raise OutputDeviceError.DeviceBusyError() + gcode_writer = Application.getInstance().getMeshFileHandler().getWriterByMimeType("text/x-gcode") if not gcode_writer: Logger.log("e", "Could not find GCode writer, not writing to removable drive %s", self.getName()) @@ -55,6 +60,7 @@ class RemovableDriveOutputDevice(OutputDevice): self.writeStarted.emit(self) job._message = message + self._writing = True job.start() except PermissionError as e: raise OutputDeviceError.PermissionDeniedError() from e @@ -70,6 +76,8 @@ class RemovableDriveOutputDevice(OutputDevice): if hasattr(job, "_message"): job._message.hide() job._message = None + + self._writing = False self.writeFinished.emit(self) if job.getResult(): message = Message(catalog.i18nc("@info:status", "Saved to Removable Drive {0} as {1}").format(self.getName(), os.path.basename(job.getFileName())))