def FileExpand(self,ID,Payload): self.ID = ID self.Payload = Payload self.FileList = {} for FileObj in self.Payload: if FileObj["type"] == "folder": self.aFilePaths = self.get_filepaths(FileObj["data"]) for f in self.aFilePaths: self.path = os.path.normpath(f) self.FileList[self.path] = dataclasses.c_file(os.path.getsize(f)) elif FileObj["type"] == "file": self.path = os.path.normpath(FileObj["data"]) self.FileList[self.path] = dataclasses.c_file(os.path.getsize(f)) return self.FileList
def m_ReadJobList(self): logging.debug("Init TCP server: Reading existing jobs from %s", Tasks.WorkData["sTargetDir"]) self.aFiles = self.get_xmljobs(Tasks) self.filecounter = 0 for i in range(len(self.aFiles)): Tasks.Order.append(i) for f in self.aFiles: self.tree = ET.ElementTree(file=f) self.root = self.tree.getroot() Tasks.Jobs[self.root.attrib["ID"]] = dataclasses.c_Task(self.root.attrib["ID"]) Tasks.Jobs[self.root.attrib["ID"]].state = self.root.attrib["state"] Tasks.Jobs[self.root.attrib["ID"]].active = self.StringToBool(self.root.attrib["active"]) Tasks.Jobs[self.root.attrib["ID"]].order = int(self.root.attrib["order"]) Tasks.Order[int(self.root.attrib["order"])-1] = self.root.attrib["ID"] self.bIsActive = True self.CopiedFiles = 0 for file in self.root.find("FileList").findall("File"): Tasks.Jobs[self.root.attrib["ID"]].filelist[file.attrib["file"]] = dataclasses.c_file(os.path.getsize(file.attrib["file"])) Tasks.Jobs[self.root.attrib["ID"]].filelist[file.attrib["file"]].copied = self.StringToBool(file.attrib["copied"]) if file.attrib["copied"] == True: Tasks.Jobs[self.root.attrib["ID"]].filelist[file.attrib["file"]].progress = 100.0 self.CopiedFiles += 1 Tasks.Jobs[self.root.attrib["ID"]].filelist[file.attrib["file"]].delete = self.StringToBool(file.attrib["delete"]) Tasks.Jobs[self.root.attrib["ID"]].filelist[file.attrib["file"]].uploaded = self.StringToBool(file.attrib["uploaded"]) Tasks.Jobs[self.root.attrib["ID"]].filelist[file.attrib["file"]].size = int(file.attrib["size"]) Tasks.Jobs[self.root.attrib["ID"]].progress = (self.CopiedFiles/len(Tasks.Jobs[self.root.attrib["ID"]].filelist))*100 for ID in Tasks.Order: self.aIncompleteFiles = 0 for file in Tasks.Jobs[ID].filelist: if Tasks.Jobs[ID].filelist[file].copied == True: self.aIncompleteFiles += 1 logging.debug("Loading task:[%s] %s : %s files. %s percent complete", Tasks.Jobs[ID].order, ID, len(Tasks.Jobs[ID].filelist), (self.aIncompleteFiles/len(Tasks.Jobs[ID].filelist)*100))
def m_ReadJobList(self): logging.debug("Init TCP server: Reading existing jobs from %s", self.dict_WorkData["sTargetDir"]) self.aFiles = self.get_filepaths(self.dict_WorkData["sTargetDir"]) for f in self.aFiles: self.head,self.tail = os.path.split(f) self.head, self.tail = (os.path.splitext(self.tail)) if self.tail.lower() == ".xml": self.tree = ET.ElementTree(file=f) self.task = self.tree.getroot() self.dict_Jobs[self.task.attrib["ID"]] = dataclasses.c_Task(self.task.attrib["ID"]) self.dict_Jobs[self.task.attrib["ID"]].state = self.task.attrib["state"] self.dict_Jobs[self.task.attrib["ID"]].active = self.task.attrib["active"] self.bIsActive = True self.CopiedFiles = 0 for file in self.task.find("FileList").findall("File"): self.dict_Jobs[self.task.attrib["ID"]].filelist[file.attrib["file"]] = dataclasses.c_file(int(file.attrib["size"])) self.dict_Jobs[self.task.attrib["ID"]].filelist[file.attrib["file"]].copied = self.StringToBool(file.attrib["copied"]) if file.attrib["copied"] == False: self.bIsActive = False else: self.dict_Jobs[self.task.attrib["ID"]].filelist[file.attrib["file"]].progress = 100.0 self.CopiedFiles += 1 self.dict_Jobs[self.task.attrib["ID"]].filelist[file.attrib["file"]].delete = self.StringToBool(file.attrib["delete"]) self.dict_Jobs[self.task.attrib["ID"]].filelist[file.attrib["file"]].uploaded = self.StringToBool(file.attrib["uploaded"]) self.dict_Jobs[self.task.attrib["ID"]].active = self.bIsActive self.dict_Jobs[self.task.attrib["ID"]].progress = (self.CopiedFiles/len(self.dict_Jobs[self.task.attrib["ID"]].filelist))*100 for f in self.dict_Jobs: self.aIncompleteFiles = 0 for file in self.dict_Jobs[f].filelist: if self.dict_Jobs[f].filelist[file].copied == False: self.aIncompleteFiles += 1 logging.debug("Loading task:[%s] %s : %s files. %s Incomplete", self.dict_Jobs[f].active, f, len(self.dict_Jobs[f].filelist), self.aIncompleteFiles)