Пример #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
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
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
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
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"))))