1
0
Fork 0

moved parser for kernel radio options to tuned.utils.commands

It is for getting the active option from strings like:
[always] never
In this case active is 'always'.
This commit is contained in:
Jaroslav Škarvada 2012-11-30 10:18:18 +01:00
parent 1ef447fad3
commit bc5538c16c
2 changed files with 10 additions and 5 deletions

View file

@ -143,11 +143,7 @@ class DiskPlugin(base.Plugin):
sys_file = self._elevator_file(device)
# example of scheduler file content:
# noop deadline [cfq]
schedulers = tuned.utils.commands.read_file(sys_file).split()
for scheduler in schedulers:
if scheduler[0] == "[" and scheduler[-1] == "]":
return scheduler[1:-1]
return schedulers[0]
return tuned.utils.commands.get_active_option(tuned.utils.commands.read_file(sys_file))
def _alpm_policy_files(self):
policy_files = []

View file

@ -43,6 +43,15 @@ def execute(args):
log.error("Executing %s error: %s" % (args[0], e))
return out
# Helper for parsing kernel options like:
# [always] never
# It will return 'always'
def get_active_option(options):
m = re.match(r'.*\[([^\]]+)\].*', options)
if m:
return m.group(1)
return options.split()[0]
def recommend_profile():
profile = consts.DEFAULT_PROFILE
for f in consts.LOAD_DIRECTORIES: