def getFileData(self, filename): filename = self._getBasicFilename(filename) absolutePath = self.getAbsolutePath(filename) if absolutePath is None: return None statResult = os.stat(absolutePath) fileData = { "name": filename, "size": util.getFormattedSize(statResult.st_size), "bytes": statResult.st_size, "date": util.getFormattedDateTime(datetime.datetime.fromtimestamp(statResult.st_ctime)), } # enrich with additional metadata from analysis if available if filename in self._metadata.keys(): for key in self._metadata[filename].keys(): if key == "prints": val = self._metadata[filename][key] formattedLast = None if val["last"] is not None: formattedLast = { "date": util.getFormattedDateTime(datetime.datetime.fromtimestamp(val["last"]["date"])), "success": val["last"]["success"], } formattedPrints = {"success": val["success"], "failure": val["failure"], "last": formattedLast} fileData["prints"] = formattedPrints else: fileData[key] = self._metadata[filename][key] return fileData
def getFileData(self, filename): filename = self._getBasicFilename(filename) absolutePath = self.getAbsolutePath(filename) if absolutePath is None: return None statResult = os.stat(absolutePath) fileData = { "name": filename, "size": util.getFormattedSize(statResult.st_size), "bytes": statResult.st_size, "date": util.getFormattedDateTime(datetime.datetime.fromtimestamp(statResult.st_ctime)) } # enrich with additional metadata from analysis if available if filename in self._metadata.keys(): for key in self._metadata[filename].keys(): if key == "prints": val = self._metadata[filename][key] formattedLast = None if val["last"] is not None: formattedLast = { "date": util.getFormattedDateTime(datetime.datetime.fromtimestamp(val["last"]["date"])), "success": val["last"]["success"] } formattedPrints = { "success": val["success"], "failure": val["failure"], "last": formattedLast } fileData["prints"] = formattedPrints else: fileData[key] = self._metadata[filename][key] return fileData
def getFileData(self, filename): if not filename: return filename = self._getBasicFilename(filename) # TODO: Make this more robust when STLs will be viewable from the # client if isSTLFileName(filename): return absolutePath = self.getAbsolutePath(filename) if absolutePath is None: return None statResult = os.stat(absolutePath) fileData = { "name": filename, "size": util.getFormattedSize(statResult.st_size), "bytes": statResult.st_size, "date": util.getFormattedDateTime(datetime.datetime.fromtimestamp(statResult.st_ctime)) } # enrich with additional metadata from analysis if available if filename in self._metadata.keys(): for key in self._metadata[filename].keys(): if key == "prints": val = self._metadata[filename][key] formattedLast = None if "last" in val and val["last"] is not None: formattedLast = { "date": util.getFormattedDateTime(datetime.datetime.fromtimestamp(val["last"]["date"])), "success": val["last"]["success"] } formattedPrints = { "success": val["success"], "failure": val["failure"], "last": formattedLast } fileData["prints"] = formattedPrints else: fileData[key] = self._metadata[filename][key] return fileData
def getFinishedTimelapses(): files = [] basedir = settings().getBaseFolder("timelapse") for osFile in os.listdir(basedir): if not fnmatch.fnmatch(osFile, "*.mpg"): continue statResult = os.stat(os.path.join(basedir, osFile)) files.append({ "name": osFile, "size": util.getFormattedSize(statResult.st_size), "bytes": statResult.st_size, "date": util.getFormattedDateTime(datetime.datetime.fromtimestamp(statResult.st_ctime)) }) return files