示例#1
0
文件: cgroups.py 项目: bigzz/devlib
 def set(self, cpus, mems):
     if isiterable(cpus):
         cpus = list_to_ranges(cpus)
     if isiterable(mems):
         mems = list_to_ranges(mems)
     self.target.write_value(self.cpus_file, cpus)
     self.target.write_value(self.mems_file, mems)
示例#2
0
    def set(self, **attrs):
        for idx in attrs:
            if isiterable(attrs[idx]):
                attrs[idx] = list_to_ranges(attrs[idx])
            # Build attribute path
            path = '{}.{}'.format(self.controller.kind, idx)
            path = self.target.path.join(self.directory, path)

            self.logger.debug('Set attribute [%s] to: %s"', path, attrs[idx])

            # Set the attribute value
            self.target.write_value(path, attrs[idx])
示例#3
0
    def set(self, **attrs):
        for idx in attrs:
            if isiterable(attrs[idx]):
                attrs[idx] = list_to_ranges(attrs[idx])
            # Build attribute path
            path = '{}.{}'.format(self.controller.kind, idx)
            path = self.target.path.join(self.directory, path)

            self.logger.debug('Set attribute [%s] to: %s"',
                    path, attrs[idx])

            # Set the attribute value
            self.target.write_value(path, attrs[idx])
示例#4
0
    def set(self, **attrs):
        for idx in attrs:
            if isiterable(attrs[idx]):
                attrs[idx] = list_to_ranges(attrs[idx])
            # Build attribute path
            if self.controller._noprefix:  # pylint: disable=protected-access
                attr_name = '{}'.format(idx)
            else:
                attr_name = '{}.{}'.format(self.controller.kind, idx)
            path = self.target.path.join(self.directory, attr_name)

            self.logger.debug('Set attribute [%s] to: %s"', path, attrs[idx])

            # Set the attribute value
            try:
                self.target.write_value(path, attrs[idx])
            except TargetStableError:
                # Check if the error is due to a non-existing attribute
                attrs = self.get()
                if idx not in attrs:
                    raise ValueError('Controller [{}] does not provide attribute [{}]'\
                                     .format(self.controller.kind, attr_name))
                raise
示例#5
0
    def set(self, **attrs):
        for idx in attrs:
            if isiterable(attrs[idx]):
                attrs[idx] = list_to_ranges(attrs[idx])
            # Build attribute path
            if self.controller._noprefix:
                attr_name = "{}".format(idx)
            else:
                attr_name = "{}.{}".format(self.controller.kind, idx)
            path = self.target.path.join(self.directory, attr_name)

            self.logger.debug('Set attribute [%s] to: %s"', path, attrs[idx])

            # Set the attribute value
            try:
                self.target.write_value(path, attrs[idx])
            except TargetError:
                # Check if the error is due to a non-existing attribute
                attrs = self.get()
                if idx not in attrs:
                    raise ValueError(
                        "Controller [{}] does not provide attribute [{}]".format(self.controller.kind, attr_name)
                    )
                raise