How to use the cgroupspy.utils.split_path_components function in cgroupspy

To help you get started, we’ve selected a few cgroupspy examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github cloudsigma / cgroupspy / cgroupspy / trees.py View on Github external
def _init_sub_groups(self, parent):
        """
        Initialise sub-groups, and create any that do not already exist.
        """

        if self._sub_groups:
            for sub_group in self._sub_groups:
                for component in split_path_components(sub_group):
                    fp = os.path.join(parent.full_path, component)
                    if os.path.exists(fp):
                        node = Node(name=component, parent=parent)
                        parent.children.append(node)
                    else:
                        node = parent.create_cgroup(component)
                    parent = node
                self._init_children(node)
        else:
            self._init_children(parent)