Example #1
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)

	# prohibit deleting files that are currently in use
	currentOrigin, currentFilename = _getCurrentFile()
	if currentFilename == filename and currentOrigin == target and (printer.is_printing() or printer.is_paused()):
		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.unselect_file()

	# delete it
	if target == FileDestinations.SDCARD:
		printer.delete_sd_file(filename)
	else:
		fileManager.remove_file(target, filename)

	return NO_CONTENT
Example #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)

    # prohibit deleting files that are currently in use
    currentOrigin, currentFilename = _getCurrentFile()
    if currentFilename == filename and currentOrigin == target and (
            printer.is_printing() or printer.is_paused()):
        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.unselect_file()

    # delete it
    if target == FileDestinations.SDCARD:
        printer.delete_sd_file(filename)
    else:
        fileManager.remove_file(target, filename)

    return NO_CONTENT
Example #3
0
def _isBusy(target, path):
    currentOrigin, currentPath = _getCurrentFile()
    if currentPath is not None and currentOrigin == target and fileManager.file_in_path(
            FileDestinations.LOCAL, path,
            currentPath) and (printer.is_printing() or printer.is_paused()):
        return True

    return any(target == x[0]
               and fileManager.file_in_path(FileDestinations.LOCAL, path, x[1])
               for x in fileManager.get_busy_files())
Example #4
0
def _isBusy(target, path):
	currentOrigin, currentPath = _getCurrentFile()
	if currentPath is not None and currentOrigin == target and fileManager.file_in_path(FileDestinations.LOCAL, path, currentPath) and (printer.is_printing() or printer.is_paused()):
		return True

	return any(target == x[0] and fileManager.file_in_path(FileDestinations.LOCAL, path, x[1]) for x in fileManager.get_busy_files())