def updateCompletionAndStatus(self):
        """
        Evaluate new value for completion and status of a particular FolderNode
        """

        self.updateAllocation()

        if not self.invalidated:
            return
        if not self.children:
            completion = 1.0
            status = NODE_DONE
        else:

            # Getting completion info
            self.readyCommandCount = 0
            self.doneCommandCount = 0
            self.commandCount = 0
            completion = 0.0
            status = defaultdict(int)
            for child in self.children:
                child.updateCompletionAndStatus()
                completion += child.completion
                status[child.status] += 1
                self.readyCommandCount += child.readyCommandCount
                self.doneCommandCount += child.doneCommandCount
                self.commandCount += child.commandCount

            if hasattr(self, "commandCount") and int(self.commandCount) != 0:
                self.completion = self.doneCommandCount / float(self.commandCount)
            else:
                # LOGGER.warning("Warning: a folder node without \"commandCount\" value was found -> %s" % self.name  )
                self.completion = completion / len(self.children)

            # Updating node's overall status
            if NODE_PAUSED in status:
                self.status = NODE_PAUSED
            elif NODE_ERROR in status:
                self.status = NODE_ERROR
            elif NODE_RUNNING in status:
                self.status = NODE_RUNNING
            elif NODE_READY in status:
                self.status = NODE_READY
            elif NODE_BLOCKED in status:
                self.status = NODE_BLOCKED
            elif NODE_CANCELED in status:
                self.status = NODE_CANCELED
            else:
                # all commands are DONE, ensure the completion is at 1.0 (in case of failed completion update from some workers)
                self.completion = 1.0
                self.status = NODE_DONE

            # Updating timers
            times = [childNode.creationTime for childNode in self.children if childNode.creationTime is not None]
            if times:
                self.creationTime = min(times)
                if self.taskGroup and (self.taskGroup.creationTime is None or self.taskGroup.creationTime > self.creationTime):
                    self.taskGroup.creationTime = self.creationTime

            times = [childNode.startTime for childNode in self.children if childNode.startTime is not None]
            if times:
                self.startTime = min(times)
                if self.taskGroup and (self.taskGroup.startTime is None or self.taskGroup.startTime > self.startTime):
                    self.taskGroup.startTime = self.startTime

            times = [childNode.updateTime for childNode in self.children if childNode.updateTime is not None]
            if times:
                self.updateTime = max(times)
                if self.taskGroup and (self.taskGroup.updateTime is None or self.taskGroup.updateTime > self.updateTime):
                    self.taskGroup.updateTime = self.updateTime

            if isFinalNodeStatus(self.status):
                times = [childNode.endTime for childNode in self.children if childNode.endTime is not None]
                if times:
                    self.endTime = max(times)
                    if self.taskGroup and (self.taskGroup.endTime is None or
                                           self.taskGroup.endTime > self.taskGroup.endTime):
                        self.taskGroup.endTime = self.endTime
            else:
                self.endTime = None
                if self.taskGroup:
                    self.taskGroup.endTime = None
        self.invalidated = False
        if self.taskGroup:
            self.timer = self.taskGroup.timer
            # FIXME: suboptimal... lazy update someday ?
            self.taskGroup.updateStatusAndCompletion()
dataset/ETHPy150Open mikrosimage/OpenRenderManagement/src/octopus/dispatcher/model/node.py/FolderNode.updateCompletionAndStatus/original