Skip to content

Commit

Permalink
Fix root group check to handle standard groups. (#634)
Browse files Browse the repository at this point in the history
* Fix root group check to handle standard groups.

* Revise code, only NestedGroup can be a root group.

* Fix type check.

* Clean up code.
  • Loading branch information
bcipriano committed Feb 27, 2020
1 parent f347994 commit 42139e9
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 10 deletions.
7 changes: 5 additions & 2 deletions cuegui/cuegui/Utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
from yaml.scanner import ScannerError

import opencue
import opencue.wrappers.group

import cuegui.ConfirmationDialog
import cuegui.Constants
Expand Down Expand Up @@ -141,14 +142,16 @@ def isRootGroup(object):
"""Returns true if the object is a root, false if not
@return: If the object is a root group
@rtype: bool"""
return object.__class__.__name__ in ["NestedGroup", "Group"] and not object.hasParent()
return isinstance(object, opencue.wrappers.group.NestedGroup) and not object.hasParent()


def isGroup(object):
"""Returns true if the object is a group, false if not
@return: If the object is a group
@rtype: bool"""
return object.__class__.__name__ in ["NestedGroup", "Group"] and object.hasParent()
return (
type(object) == opencue.wrappers.group.Group or
(isinstance(object, opencue.wrappers.group.NestedGroup) and object.hasParent()))


def isHost(object):
Expand Down
16 changes: 8 additions & 8 deletions pycue/opencue/wrappers/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,6 @@ def pendingJobs(self):
:return: total number of running jobs"""
return self.data.group_stats.pending_jobs

def hasParent(self):
"""Whether this Group/NestedGroup has a parent group.
:rtype: bool
:return: whether the group has a parent
"""
return self.data.HasField('parent')


class NestedGroup(Group):
"""This class contains information and actions related to a nested group."""
Expand Down Expand Up @@ -240,3 +232,11 @@ def asGroup(self):
level=self.data.level,
group_stats=self.data.stats,
))

def hasParent(self):
"""Whether this NestedGroup has a parent group.
:rtype: bool
:return: whether the group has a parent group.
"""
return self.data.HasField('parent')

0 comments on commit 42139e9

Please sign in to comment.