def projectAsDict(self, nsmName:str)->dict: entry = {} entry["nsmName"] = nsmName entry["name"] = os.path.basename(nsmName) basePath = pathlib.Path(PATHS["sessionRoot"], nsmName) sessionFile = pathlib.Path(basePath, "session.nsm") if not sessionFile.exists(): logging.info("Got wrong session directory from nsmd. Race condition after delete? Project: " + repr(sessionFile)) return None timestamp = datetime.fromtimestamp(sessionFile.stat().st_mtime).isoformat(sep=" ", timespec='minutes') entry["lastSavedDate"] = timestamp entry["sessionFile"] = sessionFile entry["lockFile"] = pathlib.Path(basePath, ".lock") entry["fullPath"] = str(basePath) entry["sizeInBytes"] = sum(f.stat().st_size for f in basePath.glob('**/*') if f.is_file() ) entry["numberOfClients"] = len(open(sessionFile).readlines()) entry["hasSymlinks"] = self._checkDirectoryForSymlinks(basePath) entry["parents"] = basePath.relative_to(PATHS["sessionRoot"]).parts[:-1] #tuple of each dir between NSM root and nsmName/session.nsm, exluding the actual project name. This is the tree entry["locked"] = self._checkIfLocked(nsmName) #not for direct display return entry def exportProjects(self)->list: """Return a list of dicts of projects with additional information: """ results = [] data = self._requestProjects() #False for auto-sent data by nsmd for nsmName in data: result = self.projectAsDict(nsmName) results.append(result) return results