How to use the cgroupspy.interfaces.MultiLineIntegerFile 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 / controllers.py View on Github external
"""
import os
from cgroupspy.contenttypes import DeviceAccess, DeviceThrottle

from .interfaces import FlagFile, BitFieldFile, CommaDashSetFile, IntegerFile, SplitValueFile
from .interfaces import MultiLineIntegerFile, DictFile, IntegerListFile, TypedFile


class Controller(object):

    """
    Base controller. Provides access to general files, existing in all cgroups and means to get/set properties
    """

    tasks = MultiLineIntegerFile("tasks")
    procs = MultiLineIntegerFile("cgroup.procs")
    notify_on_release = FlagFile("notify_on_release")
    clone_children = FlagFile("cgroup.clone_children")

    def __init__(self, node):
        self.node = node

    def filepath(self, filename):
        """The full path to a file"""

        return os.path.join(self.node.full_path, filename)

    def get_property(self, filename):
        """Opens the file and reads the value"""

        with open(self.filepath(filename)) as f:
            return f.read().strip()
github cloudsigma / cgroupspy / cgroupspy / controllers.py View on Github external
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
"""
import os
from cgroupspy.contenttypes import DeviceAccess, DeviceThrottle

from .interfaces import FlagFile, BitFieldFile, CommaDashSetFile, IntegerFile, SplitValueFile
from .interfaces import MultiLineIntegerFile, DictFile, IntegerListFile, TypedFile


class Controller(object):

    """
    Base controller. Provides access to general files, existing in all cgroups and means to get/set properties
    """

    tasks = MultiLineIntegerFile("tasks")
    procs = MultiLineIntegerFile("cgroup.procs")
    notify_on_release = FlagFile("notify_on_release")
    clone_children = FlagFile("cgroup.clone_children")

    def __init__(self, node):
        self.node = node

    def filepath(self, filename):
        """The full path to a file"""

        return os.path.join(self.node.full_path, filename)

    def get_property(self, filename):
        """Opens the file and reads the value"""

        with open(self.filepath(filename)) as f: