diff --git a/tuned/gtk/gui_plugin_loader.py b/tuned/gtk/gui_plugin_loader.py index 2b3e93b..67fa195 100644 --- a/tuned/gtk/gui_plugin_loader.py +++ b/tuned/gtk/gui_plugin_loader.py @@ -33,7 +33,7 @@ import tuned.consts as consts import tuned.logs import tuned.plugins.repository as repository import configobj as ConfigObj -import tuned.exceptions as TunedException +from tuned.exceptions import TunedException from tuned import plugins 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 -__all__ = ['GTKPluginLoader'] +__all__ = ['GuiPluginLoader'] global_config_spec = ['dynamic_tuning = boolean(default=%s)' % consts.CFG_DEF_DYNAMIC_TUNING, diff --git a/tuned/gtk/gui_profile_loader.py b/tuned/gtk/gui_profile_loader.py index 47b2da6..10bd7cd 100644 --- a/tuned/gtk/gui_profile_loader.py +++ b/tuned/gtk/gui_profile_loader.py @@ -123,10 +123,6 @@ class GuiProfileLoader(object): config.write() self._refresh_profiles() - def _refresh_profiles(self): - self.profiles = {} - self._load_all_profiles() - def update_profile( self, old_profile_name, diff --git a/tuned/gtk/managerException.py b/tuned/gtk/managerException.py index 9589b52..958a346 100644 --- a/tuned/gtk/managerException.py +++ b/tuned/gtk/managerException.py @@ -38,10 +38,8 @@ class ManagerException(Exception): return repr(self.code) - def profile_already_exists(self, text): - return repr(text) - - def profile_already_exists(self): - return repr(self.code) - - + def profile_already_exists(self, text=None): + if text is None: + return repr(self.code) + else: + return repr(text) diff --git a/tuned/plugins/plugin_bootloader.py b/tuned/plugins/plugin_bootloader.py index 8e2ae91..fc76063 100644 --- a/tuned/plugins/plugin_bootloader.py +++ b/tuned/plugins/plugin_bootloader.py @@ -27,7 +27,7 @@ class BootloaderPlugin(base.Plugin): def _instance_init(self, instance): instance._has_dynamic_tuning = False 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): pass @@ -82,7 +82,7 @@ class BootloaderPlugin(base.Plugin): def _remove_grub2_tuning(self): 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): if profile_switch: @@ -121,18 +121,18 @@ class BootloaderPlugin(base.Plugin): def _grub2_cfg_patch(self, value): 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") 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: - 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 - 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) 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) - 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() return True @@ -142,7 +142,7 @@ class BootloaderPlugin(base.Plugin): if verify: return 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) def _cmdline(self, enabling, value, verify, ignore_missing): diff --git a/tuned/profiles/variables.py b/tuned/profiles/variables.py index 396e590..a871ad9 100644 --- a/tuned/profiles/variables.py +++ b/tuned/profiles/variables.py @@ -4,7 +4,7 @@ import tuned.logs import functions.functions as functions import tuned.consts as consts from tuned.utils.commands import commands -from configobj import ConfigObj +from configobj import ConfigObj, ConfigObjError log = tuned.logs.get() diff --git a/tuned/utils/commands.py b/tuned/utils/commands.py index d5b2a1f..672ea0e 100644 --- a/tuned/utils/commands.py +++ b/tuned/utils/commands.py @@ -129,7 +129,7 @@ class commands: os.rename(src, dst) except OSError as 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 True diff --git a/tuned/utils/plugin_loader.py b/tuned/utils/plugin_loader.py index aa80e20..cdaa040 100644 --- a/tuned/utils/plugin_loader.py +++ b/tuned/utils/plugin_loader.py @@ -17,6 +17,9 @@ class PluginLoader(object): def __init__(self): super(PluginLoader, self).__init__() + self._namespace = None + self._prefix = None + self._interface = None self._set_loader_parameters() assert type(self._namespace) is str assert type(self._prefix) is str