示例#1
0
def readGcodeFilesForOrigin(origin):
	if origin not in [FileDestinations.LOCAL, FileDestinations.SDCARD, FileDestinations.FastbotSDCARD]:
		return make_response("Unknown origin: %s" % origin, 404)

	files = _getFileList(origin)
	print("lkj readGcodeFilesForOrigin origin:%s" % origin )
	print("lkj readGcodeFilesForOrigin files:%s" % str(files) )
	if origin == FileDestinations.LOCAL:
		return jsonify(files=files, free=util.getFreeBytes(settings().getBaseFolder("uploads")))
	elif origin == FileDestinations.FastbotSDCARD:
		return jsonify(files=files, sdFree=util.getFreeBytes(fileManager._storage(origin).get_basefolder()))
	else:
		return jsonify(files=files)
示例#2
0
文件: files.py 项目: Bevaz/OctoPrint
def readGcodeFiles():
	filter = None
	if "filter" in request.values:
		filter = request.values["filter"]
	files = _getFileList(FileDestinations.LOCAL, filter=filter)
	files.extend(_getFileList(FileDestinations.SDCARD))
	return jsonify(files=files, free=util.getFreeBytes(settings().getBaseFolder("uploads")))
示例#3
0
def readGcodeFiles():
	filter = None
	if "filter" in request.values:
		filter = request.values["filter"]
	if filter is not None:
		print("lkj readGcodeFiles filter:%s" % repr(filter) )
	print("lkj readGcodeFiles request.values:%s" % str(request.values) )
	
	files = _getFileList(FileDestinations.LOCAL, filter=filter)
	print("lkj 1 readGcodeFiles files:%s" % str(files) )
	#lkj files.extend(_getFileList(FileDestinations.SDCARD))
	sdFree = 0
	if printer.isSdReady():
		files.extend(_getFileList(FileDestinations.FastbotSDCARD))
		sdFree = util.getFreeBytes(fileManager._storage(FileDestinations.FastbotSDCARD).get_basefolder())
		print("lkj 2 readGcodeFiles files:%s, sdFree:%s" % (str(files), str(sdFree)) )
		
	return jsonify(files=files, free=util.getFreeBytes(settings().getBaseFolder("uploads")), sdFree=sdFree)
示例#4
0
def readGcodeFilesForOrigin(origin):
	if origin not in [FileDestinations.LOCAL, FileDestinations.SDCARD]:
		return make_response("Unknown origin: %s" % origin, 404)

	files = _getFileList(origin)

	if origin == FileDestinations.LOCAL:
		return jsonify(files=files, free=util.getFreeBytes(settings().getBaseFolder("uploads")))
	else:
		return jsonify(files=files)
示例#5
0
文件: files.py 项目: Booli/OctoPrint
def readGcodeFilesForOrigin(origin):
	if origin not in [FileDestinations.LOCAL, FileDestinations.SDCARD]:
		return make_response("Unknown origin: %s" % origin, 404)

	files = _getFileList(origin)

	if origin == FileDestinations.LOCAL:
		return jsonify(files=files, free=util.getFreeBytes(settings().getBaseFolder("uploads")))
	else:
		return jsonify(files=files)
示例#6
0
def readGcodeFilesForOrigin(origin):
    if origin not in [
            FileDestinations.LOCAL, FileDestinations.SDCARD,
            FileDestinations.FastbotSDCARD
    ]:
        return make_response("Unknown origin: %s" % origin, 404)

    files = _getFileList(origin)
    print("lkj readGcodeFilesForOrigin origin:%s" % origin)
    print("lkj readGcodeFilesForOrigin files:%s" % str(files))
    if origin == FileDestinations.LOCAL:
        return jsonify(files=files,
                       free=util.getFreeBytes(
                           settings().getBaseFolder("uploads")))
    elif origin == FileDestinations.FastbotSDCARD:
        return jsonify(files=files,
                       sdFree=util.getFreeBytes(
                           fileManager._storage(origin).get_basefolder()))
    else:
        return jsonify(files=files)
示例#7
0
def readGcodeFilesForOrigin(origin):
    if origin not in [FileDestinations.LOCAL, FileDestinations.SDCARD]:
        return make_response("Unknown origin: %s" % origin, 404)

    files = _getFileList(origin)

    if origin == FileDestinations.LOCAL:
        #modify by kevin, for different path
        return jsonify(files=files,
                       free=util.getFreeBytes(gcodeManager._uploadFolder))
        #modify end
    else:
        return jsonify(files=files)
示例#8
0
def readGcodeFiles():
    files = gcodeManager.getAllFileData()

    sdFileList = printer.getSdFiles()
    if sdFileList is not None:
        for sdFile in sdFileList:
            files.append({
                "name": sdFile,
                "size": "n/a",
                "bytes": 0,
                "date": "n/a",
                "origin": "sd"
            })
    return jsonify(files=files, free=util.getFormattedSize(util.getFreeBytes(settings.getpath("uploads"))))
示例#9
0
def readGcodeFiles():
	files = gcodeManager.getAllFileData()

	sdFileList = printer.getSdFiles()
	if sdFileList is not None:
		for sdFile in sdFileList:
			files.append({
				"name": sdFile,
				"size": "n/a",
				"bytes": 0,
				"date": "n/a",
				"origin": "sd"
			})
	return jsonify(files=files, free=util.getFormattedSize(util.getFreeBytes(settings().getBaseFolder("uploads"))))
示例#10
0
def readGcodeFiles():
    filter = None
    if "filter" in request.values:
        filter = request.values["filter"]
    if filter is not None:
        print("lkj readGcodeFiles filter:%s" % repr(filter))
    print("lkj readGcodeFiles request.values:%s" % str(request.values))

    files = _getFileList(FileDestinations.LOCAL, filter=filter)
    print("lkj 1 readGcodeFiles files:%s" % str(files))
    #lkj files.extend(_getFileList(FileDestinations.SDCARD))
    sdFree = 0
    if printer.isSdReady():
        files.extend(_getFileList(FileDestinations.FastbotSDCARD))
        sdFree = util.getFreeBytes(
            fileManager._storage(
                FileDestinations.FastbotSDCARD).get_basefolder())
        print("lkj 2 readGcodeFiles files:%s, sdFree:%s" %
              (str(files), str(sdFree)))

    return jsonify(files=files,
                   free=util.getFreeBytes(settings().getBaseFolder("uploads")),
                   sdFree=sdFree)
示例#11
0
	def getLocalFiles(self, sendResponse):
		try:
			try:
				files = self._getLocalFileList(FileDestinations.LOCAL)
			except:
				pass

			try:
				files.extend(self._getLocalFileList(FileDestinations.SDCARD))
			except:
				pass
			sendResponse( { 'files': files, 'free': util.getFreeBytes(settings().getBaseFolder("uploads")) })

		except Exception as e:
			self._logger.error("files can not be obtained", exc_info = True)
			sendResponse('no_files_obtained',True)
示例#12
0
	def getLocalFiles(self, sendResponse):
		try:
			try:
				files = self._getLocalFileList(FileDestinations.LOCAL)
			except:
				pass

			try:
				files.extend(self._getLocalFileList(FileDestinations.SDCARD))
			except:
				pass
			sendResponse( { 'files': files, 'free': util.getFreeBytes(settings().getBaseFolder("uploads")) })

		except Exception as e:
			self._logger.error("files can not be obtained", exc_info = True)
			sendResponse('no_files_obtained',True)
示例#13
0
def changeFilesPath():
    #modify by kevin, for use json format
    if not "application/json" in request.headers["Content-Type"]:
        return make_response("Expected content type JSON", 400)

    data = request.json

    if "filespath" in data.keys():
        if "local" == data["filespath"]:
            gcodeManager._uploadFolder = gcodeManager._localpath
        elif "usb" == data["filespath"]:
            gcodeManager._uploadFolder = gcodeManager._usbpath
    #modify end

    if "returnFiles" in data.keys() and data.get("returnFiles") is True:
        files = _getFileList(FileDestinations.LOCAL)
        files.extend(_getFileList(FileDestinations.SDCARD))
        return jsonify(files=files,
                       free=util.getFreeBytes(gcodeManager._uploadFolder))

    return NO_CONTENT
示例#14
0
文件: log.py 项目: Booli/OctoPrint
def getLogFiles():
	files = _getLogFiles()
	return jsonify(files=files, free=getFreeBytes(settings().getBaseFolder("logs")))
示例#15
0
def getUpdateFiles():
	return jsonify(files=_getUpdateFiles(), free=getFreeBytes(settings().getBaseFolder("updates")))
示例#16
0
def readGcodeFiles():
    files = _getFileList(FileDestinations.LOCAL)
    files.extend(_getFileList(FileDestinations.SDCARD))
    return jsonify(files=files,
                   free=util.getFreeBytes(settings().getBaseFolder("uploads")))
示例#17
0
文件: files.py 项目: Booli/OctoPrint
def readGcodeFiles():
	files = _getFileList(FileDestinations.LOCAL)
	files.extend(_getFileList(FileDestinations.SDCARD))
	return jsonify(files=files, free=util.getFreeBytes(settings().getBaseFolder("uploads")))
示例#18
0
def getLogFiles():
    files = _getLogFiles()
    return jsonify(files=files,
                   free=getFreeBytes(settings().getBaseFolder("logs")))
示例#19
0
def readGcodeFiles():
    files = _getFileList(FileDestinations.LOCAL)
    files.extend(_getFileList(FileDestinations.SDCARD))
    #modify by kevin, for different path
    return jsonify(files=files,
                   free=util.getFreeBytes(gcodeManager._uploadFolder))
示例#20
0
def readGcodeFilesForTarget(target):
	if target not in [FileDestinations.LOCAL, FileDestinations.SDCARD]:
		return make_response("Invalid target: %s" % target, 400)

	return jsonify(files=_getFileList(target), free=util.getFormattedSize(util.getFreeBytes(settings().getBaseFolder("uploads"))))