コード例 #1
0
ファイル: files.py プロジェクト: Booli/OctoPrint
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
コード例 #2
0
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
コード例 #3
0
ファイル: gcodefiles.py プロジェクト: zhenninglim/OctoPrint
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()
コード例 #4
0
ファイル: gcodefiles.py プロジェクト: Bigfellas/OctoPrint
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()
コード例 #5
0
ファイル: gcodefiles.py プロジェクト: TopherMan/OctoPrint
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()