diff --git a/octoprint/gcodefiles.py b/octoprint/gcodefiles.py index 72a94738..a1847737 100644 --- a/octoprint/gcodefiles.py +++ b/octoprint/gcodefiles.py @@ -174,10 +174,8 @@ class GcodeManager: config = self._settings.get(["curaEngine", "config"]) curaEngine.process_file( - config, gcodePath, absolutePath, callBack, callBackArgs) - + config, gcodePath, absolutePath, callBack, callBackArgs) def processGcode(self, absolutePath): - logging.info("Processing Gcode:%s" % str(absolutePath)) if absolutePath is None: return None @@ -206,10 +204,16 @@ class GcodeManager: def removeFile(self, filename): filename = self._getBasicFilename(filename) absolutePath = self.getAbsolutePath(filename) + stlPath = util.genStlFileName(absolutePath) + if absolutePath is None: return + if stlPath: + os.remove(stlPath) + os.remove(absolutePath) + if filename in self._metadata.keys(): del self._metadata[filename] self._metadataDirty = True diff --git a/octoprint/printer.py b/octoprint/printer.py index 754552e8..9a394bbe 100644 --- a/octoprint/printer.py +++ b/octoprint/printer.py @@ -484,12 +484,9 @@ class Printer(): absolutePath, callBack, callBackArgs) def streamSdFile(self, filename, path): - logging.info("Stream SD file called:%s" % filename) if not self._comm or self._comm.isBusy(): return - logging.info("Starting to stream file") self._comm.startFileTransfer(path, filename[:8].lower() + ".gco") - logging.info("File is streaming to SD Card") def deleteSdFile(self, filename): if not self._comm: diff --git a/octoprint/util/__init__.py b/octoprint/util/__init__.py index ce6a9172..5bd7578b 100644 --- a/octoprint/util/__init__.py +++ b/octoprint/util/__init__.py @@ -82,7 +82,16 @@ def genGcodeFileName(filename): return filename.replace('.stl', '.gcode') +def genStlFileName(filename): + if not filename: + return None + + if "." not in filename: + return filename + ".stl" + + return filename.replace('.gcode', '.stl') + def isDevVersion(): gitPath = os.path.abspath(os.path.join(os.path.split(os.path.abspath(__file__))[0], "../../.git")) return os.path.exists(gitPath) diff --git a/octoprint/util/comm.py b/octoprint/util/comm.py index 1a8a141f..1460cab5 100644 --- a/octoprint/util/comm.py +++ b/octoprint/util/comm.py @@ -353,7 +353,6 @@ class MachineCom(object): if not self.isOperational(): # printer is not connected, can't use SD return - logging.info("Select SD file: %s" % filename) self.sendCommand("M23 %s" % filename) else: self._currentFile = PrintingGcodeFileInformation(filename) @@ -427,9 +426,7 @@ class MachineCom(object): self.refreshSdFiles() def refreshSdFiles(self): - logging.info("refresh sd files") if not self.isOperational() or self.isBusy(): - logging.info("refresh busy") return self.sendCommand("M20") @@ -602,6 +599,8 @@ class MachineCom(object): self._callback.mcPrintjobDone() self._changeState(self.STATE_OPERATIONAL) eventManager().fire("PrintDone") + elif 'Done saving file' in line: + self.refreshSdFiles() ##~~ Message handling elif line.strip() != '' and line.strip() != 'ok' and not line.startswith("wait") and not line.startswith('Resend:') and line != 'echo:Unknown command:""\n' and self.isOperational(): @@ -681,8 +680,8 @@ class MachineCom(object): startSeen = True elif "ok" in line and startSeen: self._changeState(self.STATE_OPERATIONAL) - if self._sdAvailable: - self.refreshSdFiles() + if not self._sdAvailable: + self.initSdCard() eventManager().fire("Connected", "%s at %s baud" % (self._port, self._baudrate)) elif time.time() > timeout: self.close()