Merge branch 'devel' into commRefactoring

This commit is contained in:
Gina Häußge committed 2014-05-30 18:38:23 +02:00
commit 72f7b4627f
4 files changed
+43 -12

No files matched your search

+6 -3
View File
@@ -51,14 +51,17 @@ def _getFileList(origin):
files = []
if sdFileList is not None:
for sdFile in sdFileList:
files.append({
for sdFile, sdSize in sdFileList:
file = {
"name": sdFile,
"origin": FileDestinations.SDCARD,
"refs": {
"resource": url_for(".readGcodeFile", target=FileDestinations.SDCARD, filename=sdFile, _external=True)
}
})
}
if sdSize is not None:
file.update({"size": sdSize})
files.append(file)
else:
files = gcodeManager.getAllFileData()
for file in files:
+2 -1
View File
@@ -153,7 +153,8 @@ default_settings = {
"e": 300
},
"hasBed": True,
"repetierStyleTargetTemperature": False
"repetierStyleTargetTemperature": False,
"extendedSdFileList": False
}
}
}
+21 -6
View File
@@ -645,13 +645,28 @@ class MachineCom(object):
##~~ SD file list
# if we are currently receiving an sd file list, each line is just a filename, so just read it and abort processing
if self._sdFileList and isGcodeFileName(line.strip().lower()) and not 'End file list' in line:
filename = line.strip().lower()
if filterNonAscii(filename):
self._logger.warn("Got a file from printer's SD that has a non-ascii filename (%s), that shouldn't happen according to the protocol" % filename)
if self._sdFileList and not "End file list" in line:
fileinfo = line.strip().split(None, 2)
if len(fileinfo) > 1:
# we got extended file information here, so let's split filename and size and try to make them a bit nicer
filename, size = fileinfo
filename = filename.lower()
try:
size = int(size)
except ValueError:
# whatever that was, it was not an integer, so we'll just ignore it and set size to None
size = None
else:
self._sdFiles.append(filename)
continue
# no extended file information, so only the filename is there and we set size to None
filename = fileinfo[0].lower()
size = None
if isGcodeFileName(filename):
if filterNonAscii(filename):
self._logger.warn("Got a file from printer's SD that has a non-ascii filename (%s), that shouldn't happen according to the protocol" % filename)
else:
self._sdFiles.append((filename, size))
continue
##~~ Temperature processing
if ' T:' in line or line.startswith('T:') or ' T0:' in line or line.startswith('T0:'):
+14 -2
View File
@@ -197,8 +197,20 @@ class VirtualPrinter():
def _listSd(self):
self.readList.append("Begin file list")
for osFile in os.listdir(self._virtualSd):
self.readList.append(osFile.upper())
if settings().getBoolean(["devel", "virtualPrinter", "extendedSdFileList"]):
self.readList.extend(
map(
lambda x: "%s %d" % (x.upper(), os.stat(os.path.join(self._virtualSd, x)).st_size),
os.listdir(self._virtualSd)
)
)
else:
self.readList.extend(
map(
lambda x: x.upper(),
os.listdir(self._virtualSd)
)
)
self.readList.append("End file list")
self._sendOk()