def deleteGcodeFile(filename, target): if not target in [FileDestinations.LOCAL, FileDestinations.SDCARD]: return make_response("Unknown target: %s" % target, 404) if not _verifyFileExists(target, filename): return make_response("File not found on '%s': %s" % (target, filename), 404) sd = target == FileDestinations.SDCARD currentJob = printer.getCurrentJob() currentFilename = None currentSd = None if currentJob is not None and "filename" in currentJob.keys() and "sd" in currentJob.keys(): currentFilename = currentJob["filename"] currentSd = currentJob["sd"] # prohibit deleting the file that is currently being printed if currentFilename == filename and currentSd == sd and (printer.isPrinting() or printer.isPaused()): make_response("Trying to delete file that is currently being printed: %s" % filename, 409) # deselect the file if it's currently selected if currentFilename is not None and filename == currentFilename: printer.unselectFile() # delete it if sd: printer.deleteSdFile(filename) else: gcodeManager.removeFile(filename) return NO_CONTENT
def deleteGcodeFile(): if "filename" in request.values.keys(): filename = request.values["filename"] sd = "target" in request.values.keys( ) and request.values["target"] == "sd" currentJob = printer.getCurrentJob() currentFilename = None currentSd = None if currentJob is not None and "filename" in currentJob.keys( ) and "sd" in currentJob.keys(): currentFilename = currentJob["filename"] currentSd = currentJob["sd"] if currentFilename is not None and filename == currentFilename and not ( printer.isPrinting() or printer.isPaused()): printer.unselectFile() if not (currentFilename == filename and currentSd == sd and (printer.isPrinting() or printer.isPaused())): if sd: printer.deleteSdFile(filename) else: gcodeManager.removeFile(filename) return readGcodeFiles()
def deleteGcodeFile(filename, target): if not target in [FileDestinations.LOCAL, FileDestinations.SDCARD]: return make_response("Unknown target: %s" % target, 404) if not _verifyFileExists(target, filename): return make_response("File not found on '%s': %s" % (target, filename), 404) # prohibit deleting files that are currently in use currentOrigin, currentFilename = _getCurrentFile() if currentFilename == filename and currentOrigin == target and (printer.isPrinting() or printer.isPaused()): make_response("Trying to delete file that is currently being printed: %s" % filename, 409) if (target, filename) in fileManager.get_busy_files(): make_response("Trying to delete a file that is currently in use: %s" % filename, 409) # deselect the file if it's currently selected if currentFilename is not None and filename == currentFilename: printer.unselectFile() # delete it if target == FileDestinations.SDCARD: printer.deleteSdFile(filename) else: fileManager.remove_file(target, filename) return NO_CONTENT
def deleteGcodeFile(filename, target): if not target in [ FileDestinations.LOCAL, FileDestinations.SDCARD, FileDestinations.FastbotSDCARD ]: return make_response("Unknown target: %s" % target, 404) if not _verifyFileExists(target, filename): return make_response("File not found on '%s': %s" % (target, filename), 404) # prohibit deleting files that are currently in use currentOrigin, currentFilename = _getCurrentFile() if currentFilename == filename and currentOrigin == target and ( printer.isPrinting() or printer.isPaused()): make_response( "Trying to delete file that is currently being printed: %s" % filename, 409) if (target, filename) in fileManager.get_busy_files(): make_response( "Trying to delete a file that is currently in use: %s" % filename, 409) # deselect the file if it's currently selected if currentFilename is not None and filename == currentFilename: printer.unselectFile() # delete it if target == FileDestinations.SDCARD: printer.deleteSdFile(filename) else: fileManager.remove_file(target, filename) return NO_CONTENT
def deleteGcodeFile(): if "filename" in request.values.keys(): filename = request.values["filename"] sd = "target" in request.values.keys() and request.values["target"] == "sd" currentJob = printer.getCurrentJob() currentFilename = None currentSd = None if currentJob is not None and "filename" in currentJob.keys() and "sd" in currentJob.keys(): currentFilename = currentJob["filename"] currentSd = currentJob["sd"] if currentFilename is not None and filename == currentFilename and not (printer.isPrinting() or printer.isPaused()): printer.unselectFile() if not (currentFilename == filename and currentSd == sd and (printer.isPrinting() or printer.isPaused())): if sd: printer.deleteSdFile(filename) else: gcodeManager.removeFile(filename) return readGcodeFiles()
def deleteGcodeFile(filename, target): if not target in [FileDestinations.LOCAL, FileDestinations.SDCARD]: return make_response("Invalid target: %s" % target, 400) sd = target == FileDestinations.SDCARD currentJob = printer.getCurrentJob() currentFilename = None currentSd = None if currentJob is not None and "filename" in currentJob.keys() and "sd" in currentJob.keys(): currentFilename = currentJob["filename"] currentSd = currentJob["sd"] if currentFilename is not None and filename == currentFilename and not (printer.isPrinting() or printer.isPaused()): printer.unselectFile() if not (currentFilename == filename and currentSd == sd and (printer.isPrinting() or printer.isPaused())): if sd: printer.deleteSdFile(filename) else: gcodeManager.removeFile(filename) return readGcodeFiles()