1
0
Fork 0

Merge pull request #11 from olysonek/pylint_fixes

Pylint fixes
This commit is contained in:
Jaroslav Škarvada 2017-02-14 17:43:12 +01:00 committed by GitHub
commit 035eabd286
7 changed files with 20 additions and 23 deletions

View file

@ -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,

View file

@ -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,

View file

@ -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)

View file

@ -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):

View file

@ -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()

View file

@ -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

View file

@ -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