示例#1
0
    def __processUpdateHandleNested(self, parent, groups):
        """Adds or updates self._items from a list of NestedGroup objects.
        @type  parent: QTreeWidgetItem or QTreeWidget
        @param parent: The parent item for this level of items
        @type  groups: list<NestedGroup>
        @param groups: paramB_description"""
        for group in groups:
            # If id already exists, update it
            if group.data.parent.id:
                parent = self._items.get(group.data.parent.id)

            if group.id() in self._items:
                groupItem = self._items[group.id()]
                groupItem.update(group, parent)
            elif group.data.parent.id:
                self._items[group.id()] = groupItem = GroupWidgetItem(
                    group, parent)
            else:
                self._items[group.id()] = groupItem = RootGroupWidgetItem(
                    group, parent)

            nestedGroups = [
                opencue.wrappers.group.NestedGroup(nestedGroup)
                for nestedGroup in group.data.groups.nested_groups
            ]
            self.__processUpdateHandleNested(groupItem, nestedGroups)

            # empty list will return all jobs on the farm
            # only search if list has jobs
            if group.data.jobs:
                jobSeq = opencue.search.JobSearch.byOptions(
                    id=list(group.data.jobs)).jobs
                jobsObject = [Job(j) for j in jobSeq.jobs]

                for job in jobsObject:
                    try:
                        if job.id() in self._items:
                            self._items[job.id()].update(job, groupItem)
                        else:
                            self._items[job.id()] = JobWidgetItem(
                                job, groupItem)
                    except RuntimeError:
                        logger.warning(
                            "Failed to create tree item. RootView might be closed",
                            exc_info=True)
示例#2
0
    def __processUpdateHandleNested(self, parent, groups):
        """Adds or updates self._items from a list of NestedGroup objects.
        @type  parent: QTreeWidgetItem or QTreeWidget
        @param parent: The parent item for this level of items
        @type  groups: list<NestedGroup>
        @param groups: paramB_description"""
        for group in groups:
            # If id already exists, update it
            if group.data.parent.id:
                parent = self._items.get(group.data.parent.id)

            if group.id() in self._items:
                groupItem = self._items[group.id()]
                groupItem.update(group, parent)
            elif group.data.parent.id:
                self._items[group.id()] = groupItem = GroupWidgetItem(
                    group, parent)
            else:
                self._items[group.id()] = groupItem = RootGroupWidgetItem(
                    group, parent)

            nestedGroups = [
                opencue.wrappers.group.NestedGroup(nestedGroup)
                for nestedGroup in group.data.groups.nested_groups
            ]
            self.__processUpdateHandleNested(groupItem, nestedGroups)

            for jobId in group.data.jobs:
                job = opencue.api.getJob(jobId)
                try:
                    if job.id() in self._items:
                        self._items[job.id()].update(job, groupItem)
                    else:
                        self._items[job.id()] = JobWidgetItem(job, groupItem)
                except RuntimeError:
                    logger.warning(
                        "Failed to create tree item. RootView might be closed",
                        exc_info=True)