commit
035eabd286
7 changed files with 20 additions and 23 deletions
|
|
@ -33,7 +33,7 @@ import tuned.consts as consts
|
||||||
import tuned.logs
|
import tuned.logs
|
||||||
import tuned.plugins.repository as repository
|
import tuned.plugins.repository as repository
|
||||||
import configobj as ConfigObj
|
import configobj as ConfigObj
|
||||||
import tuned.exceptions as TunedException
|
from tuned.exceptions import TunedException
|
||||||
|
|
||||||
from tuned import plugins
|
from tuned import plugins
|
||||||
from tuned.utils.plugin_loader import PluginLoader
|
from tuned.utils.plugin_loader import PluginLoader
|
||||||
|
|
@ -42,7 +42,7 @@ from tuned import storage, units, monitors, plugins, profiles, exports, \
|
||||||
|
|
||||||
import tuned.plugins as Plugins
|
import tuned.plugins as Plugins
|
||||||
|
|
||||||
__all__ = ['GTKPluginLoader']
|
__all__ = ['GuiPluginLoader']
|
||||||
|
|
||||||
global_config_spec = ['dynamic_tuning = boolean(default=%s)'
|
global_config_spec = ['dynamic_tuning = boolean(default=%s)'
|
||||||
% consts.CFG_DEF_DYNAMIC_TUNING,
|
% consts.CFG_DEF_DYNAMIC_TUNING,
|
||||||
|
|
|
||||||
|
|
@ -123,10 +123,6 @@ class GuiProfileLoader(object):
|
||||||
config.write()
|
config.write()
|
||||||
self._refresh_profiles()
|
self._refresh_profiles()
|
||||||
|
|
||||||
def _refresh_profiles(self):
|
|
||||||
self.profiles = {}
|
|
||||||
self._load_all_profiles()
|
|
||||||
|
|
||||||
def update_profile(
|
def update_profile(
|
||||||
self,
|
self,
|
||||||
old_profile_name,
|
old_profile_name,
|
||||||
|
|
|
||||||
|
|
@ -38,10 +38,8 @@ class ManagerException(Exception):
|
||||||
|
|
||||||
return repr(self.code)
|
return repr(self.code)
|
||||||
|
|
||||||
def profile_already_exists(self, text):
|
def profile_already_exists(self, text=None):
|
||||||
return repr(text)
|
if text is None:
|
||||||
|
return repr(self.code)
|
||||||
def profile_already_exists(self):
|
else:
|
||||||
return repr(self.code)
|
return repr(text)
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ class BootloaderPlugin(base.Plugin):
|
||||||
def _instance_init(self, instance):
|
def _instance_init(self, instance):
|
||||||
instance._has_dynamic_tuning = False
|
instance._has_dynamic_tuning = False
|
||||||
instance._has_static_tuning = True
|
instance._has_static_tuning = True
|
||||||
self._grub2_cfg_file = self._get_grub2_cfg_file()
|
self._grub2_cfg_file_name = self._get_grub2_cfg_file()
|
||||||
|
|
||||||
def _instance_cleanup(self, instance):
|
def _instance_cleanup(self, instance):
|
||||||
pass
|
pass
|
||||||
|
|
@ -82,7 +82,7 @@ class BootloaderPlugin(base.Plugin):
|
||||||
|
|
||||||
def _remove_grub2_tuning(self):
|
def _remove_grub2_tuning(self):
|
||||||
self._patch_bootcmdline("")
|
self._patch_bootcmdline("")
|
||||||
self._cmd.replace_in_file(self._grub2_cfg_file, r"\b(set\s+" + consts.GRUB2_TUNED_VAR + r"\s*=).*$", r"\1" + "\"\"")
|
self._cmd.replace_in_file(self._grub2_cfg_file_name, r"\b(set\s+" + consts.GRUB2_TUNED_VAR + r"\s*=).*$", r"\1" + "\"\"")
|
||||||
|
|
||||||
def _instance_unapply_static(self, instance, profile_switch = False):
|
def _instance_unapply_static(self, instance, profile_switch = False):
|
||||||
if profile_switch:
|
if profile_switch:
|
||||||
|
|
@ -121,18 +121,18 @@ class BootloaderPlugin(base.Plugin):
|
||||||
|
|
||||||
def _grub2_cfg_patch(self, value):
|
def _grub2_cfg_patch(self, value):
|
||||||
log.debug("patching grub.cfg")
|
log.debug("patching grub.cfg")
|
||||||
if self._grub2_cfg_file is None:
|
if self._grub2_cfg_file_name is None:
|
||||||
log.error("cannot find grub.cfg to patch, you need to regenerate it by hand by grub2-mkconfig")
|
log.error("cannot find grub.cfg to patch, you need to regenerate it by hand by grub2-mkconfig")
|
||||||
return False
|
return False
|
||||||
grub2_cfg = self._cmd.read_file(self._grub2_cfg_file)
|
grub2_cfg = self._cmd.read_file(self._grub2_cfg_file_name)
|
||||||
if len(grub2_cfg) <= 0:
|
if len(grub2_cfg) <= 0:
|
||||||
log.error("error patching %s, you need to regenerate it by hand by grub2-mkconfig" % self._grub2_cfg_file)
|
log.error("error patching %s, you need to regenerate it by hand by grub2-mkconfig" % self._grub2_cfg_file_name)
|
||||||
return False
|
return False
|
||||||
log.debug("adding boot command line parameters to '%s'" % self._grub2_cfg_file)
|
log.debug("adding boot command line parameters to '%s'" % self._grub2_cfg_file_name)
|
||||||
(grub2_cfg_new, nsubs) = re.subn(r"\b(set\s+" + consts.GRUB2_TUNED_VAR + "\s*=).*$", r"\1" + "\"" + str(value) + "\"", grub2_cfg, flags = re.MULTILINE)
|
(grub2_cfg_new, nsubs) = re.subn(r"\b(set\s+" + consts.GRUB2_TUNED_VAR + "\s*=).*$", r"\1" + "\"" + str(value) + "\"", grub2_cfg, flags = re.MULTILINE)
|
||||||
if nsubs < 1 or re.search(r"\$" + consts.GRUB2_TUNED_VAR, grub2_cfg, flags = re.MULTILINE) is None:
|
if nsubs < 1 or re.search(r"\$" + consts.GRUB2_TUNED_VAR, grub2_cfg, flags = re.MULTILINE) is None:
|
||||||
grub2_cfg_new = self._grub2_cfg_patch_initial(self._grub2_cfg_unpatch(grub2_cfg), value)
|
grub2_cfg_new = self._grub2_cfg_patch_initial(self._grub2_cfg_unpatch(grub2_cfg), value)
|
||||||
self._cmd.write_to_file(self._grub2_cfg_file, grub2_cfg_new)
|
self._cmd.write_to_file(self._grub2_cfg_file_name, grub2_cfg_new)
|
||||||
self._grub2_default_env_patch()
|
self._grub2_default_env_patch()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
@ -142,7 +142,7 @@ class BootloaderPlugin(base.Plugin):
|
||||||
if verify:
|
if verify:
|
||||||
return None
|
return None
|
||||||
if enabling and value is not None:
|
if enabling and value is not None:
|
||||||
self._grub2_cfg_file = value
|
self._grub2_cfg_file_name = value
|
||||||
|
|
||||||
@command_custom("cmdline", per_device = False, priority = 10)
|
@command_custom("cmdline", per_device = False, priority = 10)
|
||||||
def _cmdline(self, enabling, value, verify, ignore_missing):
|
def _cmdline(self, enabling, value, verify, ignore_missing):
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@ import tuned.logs
|
||||||
import functions.functions as functions
|
import functions.functions as functions
|
||||||
import tuned.consts as consts
|
import tuned.consts as consts
|
||||||
from tuned.utils.commands import commands
|
from tuned.utils.commands import commands
|
||||||
from configobj import ConfigObj
|
from configobj import ConfigObj, ConfigObjError
|
||||||
|
|
||||||
log = tuned.logs.get()
|
log = tuned.logs.get()
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -129,7 +129,7 @@ class commands:
|
||||||
os.rename(src, dst)
|
os.rename(src, dst)
|
||||||
except OSError as error:
|
except OSError as error:
|
||||||
if not no_error:
|
if not no_error:
|
||||||
log.error("cannot rename file '%s' to '%s': '%s'" % (f, str(error)))
|
log.error("cannot rename file '%s' to '%s': '%s'" % (src, dst, str(error)))
|
||||||
return False
|
return False
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -17,6 +17,9 @@ class PluginLoader(object):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
super(PluginLoader, self).__init__()
|
super(PluginLoader, self).__init__()
|
||||||
|
|
||||||
|
self._namespace = None
|
||||||
|
self._prefix = None
|
||||||
|
self._interface = None
|
||||||
self._set_loader_parameters()
|
self._set_loader_parameters()
|
||||||
assert type(self._namespace) is str
|
assert type(self._namespace) is str
|
||||||
assert type(self._prefix) is str
|
assert type(self._prefix) is str
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue