def __init__(self, *args, **kwargs): self._cmd = commands() self._selinux_path = self._get_selinux_path() if self._selinux_path is None: raise exceptions.NotSupportedPluginException("SELinux is not enabled on your system or incompatible version is used.") self._cache_threshold_path = os.path.join(self._selinux_path, "avc", "cache_threshold") super(self.__class__, self).__init__(*args, **kwargs)
def __init__(self, unit_manager, profile_loader, profile_name=None, config=None): log.debug("initializing daemon") self._sleep_interval = int(consts.CFG_DEF_SLEEP_INTERVAL) self._update_interval = int(consts.CFG_DEF_UPDATE_INTERVAL) self._dynamic_tuning = consts.CFG_DEF_DYNAMIC_TUNING if config is not None: self._sleep_interval = int(config.get("sleep_interval", consts.CFG_DEF_SLEEP_INTERVAL)) self._update_interval = int(config.get("update_interval", consts.CFG_DEF_UPDATE_INTERVAL)) self._dynamic_tuning = config.get("dynamic_tuning", consts.CFG_DEF_DYNAMIC_TUNING) if self._sleep_interval <= 0: self._sleep_interval = int(consts.CFG_DEF_SLEEP_INTERVAL) if self._update_interval == 0: self._dynamic_tuning = False elif self._update_interval < self._sleep_interval: self._update_interval = self._sleep_interval self._sleep_cycles = self._update_interval // self._sleep_interval log.info("using sleep interval of %d second(s)" % self._sleep_interval) if self._dynamic_tuning: log.info("dynamic tuning is enabled (can be overriden by plugins)") log.info("using update interval of %d second(s) (%d times of the sleep interval)" % (self._sleep_cycles * self._sleep_interval, self._sleep_cycles)) self._unit_manager = unit_manager self._profile_loader = profile_loader self._init_threads() self._cmd = commands() try: self._init_profile(profile_name) except TunedException as e: log.error("Cannot set initial profile. No tunings will be enabled!")
def __init__(self, *args, **kwargs): self._cmd = commands() self._control_file = "/sys/devices/platform/eeepc/cpufv" if not os.path.isfile(self._control_file): self._control_file = "/sys/devices/platform/eeepc-wmi/cpufv" if not os.path.isfile(self._control_file): raise exceptions.NotSupportedPluginException("Plugin is not supported on your hardware.") super(self.__class__, self).__init__(*args, **kwargs)
def __init__(self, *args, **kwargs): super(self.__class__, self).__init__(*args, **kwargs) self._power_levels = [254, 225, 195, 165, 145, 125, 105, 85, 70, 55, 30, 20] self._spindown_levels = [0, 250, 230, 210, 190, 170, 150, 130, 110, 90, 70, 60] self._levels = len(self._power_levels) self._level_steps = 6 self._load_smallest = 0.01 self._cmd = commands()
def _init_devices(self): self._devices = set() self._assigned_devices = set() for device in self._hardware_inventory.get_devices("usb").match_property("DEVTYPE", "usb_device"): self._devices.add(device.sys_name) self._free_devices = self._devices.copy() self._cmd = commands()
def __init__(self, monitors_repository, storage_factory, hardware_inventory, device_matcher, instance_factory, global_cfg, variables): super(self.__class__, self).__init__(monitors_repository, storage_factory, hardware_inventory, device_matcher, instance_factory, global_cfg, variables) self._has_dynamic_options = True self._daemon = consts.CFG_DEF_DAEMON self._sleep_interval = int(consts.CFG_DEF_SLEEP_INTERVAL) if global_cfg is not None: self._daemon = global_cfg.get_bool(consts.CFG_DAEMON, consts.CFG_DEF_DAEMON) self._sleep_interval = int(global_cfg.get(consts.CFG_SLEEP_INTERVAL, consts.CFG_DEF_SLEEP_INTERVAL)) self._cmd = commands()
def _init_devices(self): self._devices = set() self._assigned_devices = set() # FIXME: this is a blind shot, needs testing for device in self._hardware_inventory.get_devices("drm").match_sys_name("card*").match_property("DEVTYPE", "drm_minor"): self._devices.add(device.sys_name) self._free_devices = self._devices.copy() self._cmd = commands()
def __init__(self, *args, **kwargs): super(self.__class__, self).__init__(*args, **kwargs) self._has_cpupower = True self._has_energy_perf_bias = True self._has_intel_pstate = False self._min_perf_pct_save = None self._max_perf_pct_save = None self._no_turbo_save = None self._cmd = commands()
def __init__(self): self._cfg = {} self.load_config() self._cmd = commands()
def __init__(self, *args, **kwargs): if not os.path.isfile(consts.SYSTEMD_SYSTEM_CONF_FILE): raise exceptions.NotSupportedPluginException("Required systemd '%s' configuration file not found, disabling plugin." % consts.SYSTEMD_SYSTEM_CONF_FILE) super(SystemdPlugin, self).__init__(*args, **kwargs) self._cmd = commands()
import os import re import glob import repository import tuned.logs import tuned.consts as consts from tuned.utils.commands import commands log = tuned.logs.get() cmd = commands() class Functions(): """ Built-in functions """ def __init__(self): self._repository = repository.Repository() def sub_func(self, mo): sorig = mo.string[mo.start():mo.end()] if mo.lastindex != 1: return sorig s = mo.string[mo.start(1):mo.end(1)] if len(s) == 0: return sorig sl = re.split(r'(?<!\\):', s) sl = map(lambda v: str(v).replace("\:", ":"), sl) if not re.match(r'\w+$', sl[0]): log.error("invalid function name '%s'" % sl[0])
def __init__(self): self.active_profile = None self._cmd = commands(debug) self.config = tuned.utils.global_config.GlobalConfig() self.builder = Gtk.Builder() try: self.builder.add_from_file(GLADEUI) except GObject.GError as e: print >> sys.stderr, "Error loading '%s'" % GLADEUI sys.exit(1) # # DIALOGS # self.messagedialog_operation_error = \ self.builder.get_object('messagedialogOperationError') self.tuned_daemon_exception_dialog = \ self.builder.get_object('tunedDaemonExceptionDialog') self.dialog_add_plugin = \ self.builder.get_object('dialogAddPlugin') self.tuned_daemon_exception_dialog.connect('destroy', lambda d: \ self.tuned_daemon_exception_dialog.hide()) self.cancel_button = self.builder.get_object('cancel_button') self.cancel_button.connect('clicked', lambda d: \ self.tuned_daemon_exception_dialog.hide()) if not self._starting(): return self.manager = \ tuned.gtk.gui_profile_loader.GuiProfileLoader(tuned.consts.LOAD_DIRECTORIES) self.manager = \ tuned.gtk.gui_profile_loader.GuiProfileLoader(tuned.consts.LOAD_DIRECTORIES) self.plugin_loader = \ tuned.gtk.gui_plugin_loader.GuiPluginLoader() action_group = Gtk.ActionGroup('my_actions') self.builder.connect_signals(self) self.builder.connect_signals(self) # # WINDOW MAIN # self.main_window = self.builder.get_object('mainWindow') # # WINDOW PROFILE EDITOR # self.window_profile_editor = \ self.builder.get_object('windowProfileEditor') self.window_profile_editor.connect('delete-event', self.on_delete_event) self.entry_profile_name = \ self.builder.get_object('entryProfileName') self.combobox_include_profile = \ self.builder.get_object('comboboxIncludeProfile') self.togglebutton_include_profile = \ self.builder.get_object('togglebuttonIncludeProfile') self.notebook_plugins = \ self.builder.get_object('notebookPlugins') self.button_add_plugin = \ self.builder.get_object('buttonAddPlugin') self.button_remove_plugin = \ self.builder.get_object('buttonRemovePlugin') self.button_open_raw = self.builder.get_object('buttonOpenRaw') self.button_cancel = self.builder.get_object('buttonCancel') self.button_open_raw.connect('clicked', self.execute_open_raw_button) self.button_add_plugin.connect('clicked', self.execute_add_plugin_to_notebook) self.button_remove_plugin.connect('clicked', self.execute_remove_plugin_from_notebook) self.button_cancel.connect('clicked', self.execute_cancel_window_profile_editor) # # WINDOW PROFILE EDITOR RAW # self.window_profile_editor_raw = \ self.builder.get_object('windowProfileEditorRaw') self.window_profile_editor_raw.connect('delete-event', self.on_delete_event) self.button_apply = self.builder.get_object('buttonApply') self.button_apply.connect('clicked', self.execute_apply_window_profile_editor_raw) self.button_cancel_raw = \ self.builder.get_object('buttonCancelRaw') self.button_cancel_raw.connect('clicked', self.execute_cancel_window_profile_editor_raw) self.textview_profile_config_raw = \ self.builder.get_object('textviewProfileConfigRaw') self.textview_profile_config_raw.set_editable(True) self.textview_plugin_avaible_text = \ self.builder.get_object('textviewPluginAvaibleText') self.textview_plugin_documentation_text = \ self.builder.get_object('textviewPluginDocumentationText') self.textview_plugin_avaible_text.set_editable(False) self.textview_plugin_documentation_text.set_editable(False) # # DIALOG ABOUT # self.about_dialog = Gtk.AboutDialog.new() self.about_dialog.set_name(NAME) self.about_dialog.set_version(VERSION) self.about_dialog.set_license(LICENSE) self.about_dialog.set_wrap_license(True) self.about_dialog.set_copyright(COPYRIGHT) self.about_dialog.set_authors(AUTHORS) # # GET WIDGETS # self.imagemenuitem_quit = \ self.builder.get_object('imagemenuitemQuit') self.imagemenuitem_about = \ self.builder.get_object('imagemenuitemAbout') self.label_actual_profile = \ self.builder.get_object('labelActualProfile') self.label_recommended_profile = \ self.builder.get_object('label_recommemnded_profile') self.label_dbus_status = \ self.builder.get_object('labelDbusStatus') self.label_summary_profile = \ self.builder.get_object('summaryProfileName') self.label_summary_included_profile = \ self.builder.get_object('summaryIncludedProfileName') self.comboboxtext_fast_change_profile = \ self.builder.get_object('comboboxtextFastChangeProfile') self.button_fast_change_profile = \ self.builder.get_object('buttonFastChangeProfile') self.spinner_fast_change_profile = \ self.builder.get_object('spinnerFastChangeProfile') self.spinner_fast_change_profile.hide() self.switch_tuned_start_stop = \ self.builder.get_object('switchTunedStartStop') self.switch_tuned_startup_start_stop = \ self.builder.get_object('switchTunedStartupStartStop') self.switch_tuned_admin_functions = \ self.builder.get_object('switchTunedAdminFunctions') self.treeview_profile_manager = \ self.builder.get_object('treeviewProfileManager') self.treeview_actual_plugins = \ self.builder.get_object('treeviewActualPlugins') # # SET WIDGETS # self.treestore_profiles = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING) self.treestore_plugins = Gtk.ListStore(GObject.TYPE_STRING) for plugin in sorted(self.plugin_loader.plugins): self.treestore_plugins.append([plugin.name]) self.combobox_plugins = \ self.builder.get_object('comboboxPlugins') self.combobox_plugins.set_model(self.treestore_plugins) self.combobox_main_plugins = \ self.builder.get_object('comboboxMainPlugins') self.combobox_main_plugins.set_model(self.treestore_plugins) self.combobox_main_plugins.connect('changed', self.on_changed_combobox_plugins) self.combobox_include_profile.set_model(self.treestore_profiles) cell = Gtk.CellRendererText() self.combobox_include_profile.pack_start(cell, True) self.combobox_include_profile.add_attribute(cell, 'text', 0) self.treeview_profile_manager.append_column(Gtk.TreeViewColumn('Type' , Gtk.CellRendererText(), text=1)) self.treeview_profile_manager.append_column(Gtk.TreeViewColumn('Name' , Gtk.CellRendererText(), text=0)) self.treeview_profile_manager.set_model(self.treestore_profiles) for profile_name in self.manager.get_names(): if self.manager.is_profile_factory(profile_name): self.treestore_profiles.append([profile_name, consts.PREFIX_PROFILE_FACTORY]) else: self.treestore_profiles.append([profile_name, consts.PREFIX_PROFILE_USER]) self.treeview_profile_manager.get_selection().select_path(0) self.button_create_profile = \ self.builder.get_object('buttonCreateProfile') self.button_upadte_selected_profile = \ self.builder.get_object('buttonUpadteSelectedProfile') self.button_delete_selected_profile = \ self.builder.get_object('buttonDeleteSelectedProfile') self.label_actual_profile.set_text(self.controller.active_profile()) if self.config.get(consts.CFG_RECOMMEND_COMMAND): self.label_recommended_profile.set_text(self.controller.recommend_profile()) self.listbox_summary_of_active_profile = \ self.builder.get_object('listboxSummaryOfActiveProfile') self.data_for_listbox_summary_of_active_profile() self.comboboxtext_fast_change_profile.set_model(self.treestore_profiles) self.label_dbus_status.set_text(str(bool(self.controller.is_running()))) self.switch_tuned_start_stop.set_active(True) self.switch_tuned_startup_start_stop.set_active(self.service_run_on_start_up('tuned' )) self.switch_tuned_admin_functions.set_active(self.is_admin) self.menu_add_plugin_value = \ self.builder.get_object('menuAddPluginValue') self.add_plugin_value_action = \ self.builder.get_object('addPluginValue') self.add_custom_plugin_value = \ self.builder.get_object('addCustomPluginValue') self.delete_plugin_value_action = \ self.builder.get_object('deletePluginValue') self.add_plugin_value_action.connect('activate', self.add_plugin_value_to_treeview) self.add_custom_plugin_value.connect('activate', self.add_custom_plugin_value_to_treeview) self.delete_plugin_value_action.connect('activate', self.delete_plugin_value_to_treeview) # # CONNECTIONS # self.imagemenuitem_quit.connect('activate', Gtk.main_quit) self.imagemenuitem_about.connect('activate', self.execute_about) self.comboboxtext_fast_change_profile.set_active(self.get_iter_from_model_by_name(self.comboboxtext_fast_change_profile.get_model(), self.controller.active_profile())) self.button_fast_change_profile.connect('clicked', self.execute_change_profile) self.switch_tuned_start_stop.connect('notify::active', self.execute_switch_tuned) self.switch_tuned_startup_start_stop.connect('notify::active', self.execute_switch_tuned) self.switch_tuned_admin_functions.connect('notify::active', self.execute_switch_tuned_admin_functions) self.button_create_profile.connect('clicked', self.execute_create_profile) self.button_upadte_selected_profile.connect('clicked', self.execute_update_profile) self.button_delete_selected_profile.connect('clicked', self.execute_remove_profile) self.button_confirm_profile_create = \ self.builder.get_object('buttonConfirmProfileCreate') self.button_confirm_profile_update = \ self.builder.get_object('buttonConfirmProfileUpdate') self.button_confirm_profile_create.connect('clicked', self.on_click_button_confirm_profile_create) self.button_confirm_profile_update.connect('clicked', self.on_click_button_confirm_profile_update) self.editing_profile_name = None self.treeview_actual_plugins.connect('row-activated', self.on_treeview_click) # self.treeview_profile_manager.connect('row-activated',lambda x,y,z: self.execute_update_profile(x,y)) # TO DO: need to be fixed! - double click on treeview self.main_window.connect('destroy', Gtk.main_quit) self.main_window.show() Gtk.main()
def __init__(self, *args, **kwargs): super(SysctlPlugin, self).__init__(*args, **kwargs) self._has_dynamic_options = True self._cmd = commands()
def __init__(self, *args, **kwargs): super(SCSIHostPlugin, self).__init__(*args, **kwargs) self._cmd = commands()
def __init__(self, *args, **kwargs): super(self.__class__, self).__init__(*args, **kwargs) self._cmd = commands()
def __init__(self, name, nargs_max, nargs_min=None): self._name = name self._nargs_max = nargs_max self._nargs_min = nargs_min self._cmd = commands()
def __init__(self): self._commands = commands()
from tuned.utils.commands import commands from tuned.profiles import Locator as profiles_locator from exceptions import TunedAdminDBusException import tuned.consts as consts import os import sys import errno import threading class Admin(object): def __init__(self, controller, debug = False, async = False): self._controller = controller self._debug = debug self._async = async self._cmd = commands(debug) self._profiles_locator = profiles_locator(consts.LOAD_DIRECTORIES) self._daemon_action_finished = threading.Event() self._daemon_action_profile = "" self._daemon_action_result = True self._daemon_action_errstr = "" if self._controller is None: self._dbus = False else: self._dbus = True try: self._controller.set_signal_handler(consts.DBUS_SIGNAL_PROFILE_CHANGED, self._signal_profile_changed_cb) except TunedAdminDBusException as e: self._error(e) self._dbus = False def _error(self, message):
def __init__(self,config_file = consts.GLOBAL_CONFIG_FILE): self._cfg = {} self.load_config(file_name=config_file) self._cmd = commands()
def setUp(self): self._commands = commands() self._test_dir = tempfile.mkdtemp() self._test_file = tempfile.NamedTemporaryFile(mode='r', dir=self._test_dir)
def __init__(self, *args, **kwargs): super(self.__class__, self).__init__(*args, **kwargs) self._has_dynamic_options = True self._cmd = commands()
def __init__(self, *args, **kwargs): super(NetTuningPlugin, self).__init__(*args, **kwargs) self._load_smallest = 0.05 self._level_steps = 6 self._cmd = commands()
def __init__(self, *args, **kwargs): super(self.__class__, self).__init__(*args, **kwargs) self._load_smallest = 0.05 self._level_steps = 6 self._cmd = commands()
def __init__(self): self._cmd = commands() self._lookup_re = {} self._lookup_env = {} self._functions = functions.Functions()
def __init__(self, *args, **kwargs): if not os.path.isfile(consts.GRUB2_TUNED_TEMPLATE_PATH): raise exceptions.NotSupportedPluginException( "Required GRUB2 template not found, disabling plugin.") super(self.__class__, self).__init__(*args, **kwargs) self._cmd = commands()
def __init__(self, daemon, global_config): super(Controller, self).__init__() self._daemon = daemon self._global_config = global_config self._terminate = threading.Event() self._cmd = commands()
def __init__(self): self.active_profile = None self._cmd = commands(debug) self.config = tuned.utils.global_config.GlobalConfig() self.builder = Gtk.Builder() try: self.builder.add_from_file(GLADEUI) except GObject.GError as e: print("Error loading '%s'" % GLADEUI, file=sys.stderr) sys.exit(1) # # DIALOGS # self.messagedialog_operation_error = \ self.builder.get_object('messagedialogOperationError') self.tuned_daemon_exception_dialog = \ self.builder.get_object('tunedDaemonExceptionDialog') self.dialog_add_plugin = \ self.builder.get_object('dialogAddPlugin') self.tuned_daemon_exception_dialog.connect('destroy', lambda d: \ self.tuned_daemon_exception_dialog.hide()) self.cancel_button = self.builder.get_object('cancel_button') self.cancel_button.connect('clicked', lambda d: \ self.tuned_daemon_exception_dialog.hide()) if not self._starting(): return self.manager = \ tuned.gtk.gui_profile_loader.GuiProfileLoader(tuned.consts.LOAD_DIRECTORIES) self.manager = \ tuned.gtk.gui_profile_loader.GuiProfileLoader(tuned.consts.LOAD_DIRECTORIES) self.plugin_loader = \ tuned.gtk.gui_plugin_loader.GuiPluginLoader() action_group = Gtk.ActionGroup('my_actions') self.builder.connect_signals(self) self.builder.connect_signals(self) # # WINDOW MAIN # self.main_window = self.builder.get_object('mainWindow') # # WINDOW PROFILE EDITOR # self.window_profile_editor = \ self.builder.get_object('windowProfileEditor') self.window_profile_editor.connect('delete-event', self.on_delete_event) self.entry_profile_name = \ self.builder.get_object('entryProfileName') self.combobox_include_profile = \ self.builder.get_object('comboboxIncludeProfile') self.togglebutton_include_profile = \ self.builder.get_object('togglebuttonIncludeProfile') self.notebook_plugins = \ self.builder.get_object('notebookPlugins') self.button_add_plugin = \ self.builder.get_object('buttonAddPlugin') self.button_remove_plugin = \ self.builder.get_object('buttonRemovePlugin') self.button_open_raw = self.builder.get_object('buttonOpenRaw') self.button_cancel = self.builder.get_object('buttonCancel') self.button_open_raw.connect('clicked', self.execute_open_raw_button) self.button_add_plugin.connect('clicked', self.execute_add_plugin_to_notebook) self.button_remove_plugin.connect( 'clicked', self.execute_remove_plugin_from_notebook) self.button_cancel.connect('clicked', self.execute_cancel_window_profile_editor) # # WINDOW PROFILE EDITOR RAW # self.window_profile_editor_raw = \ self.builder.get_object('windowProfileEditorRaw') self.window_profile_editor_raw.connect('delete-event', self.on_delete_event) self.button_apply = self.builder.get_object('buttonApply') self.button_apply.connect('clicked', self.execute_apply_window_profile_editor_raw) self.button_cancel_raw = \ self.builder.get_object('buttonCancelRaw') self.button_cancel_raw.connect( 'clicked', self.execute_cancel_window_profile_editor_raw) self.textview_profile_config_raw = \ self.builder.get_object('textviewProfileConfigRaw') self.textview_profile_config_raw.set_editable(True) self.textview_plugin_avaible_text = \ self.builder.get_object('textviewPluginAvaibleText') self.textview_plugin_documentation_text = \ self.builder.get_object('textviewPluginDocumentationText') self.textview_plugin_avaible_text.set_editable(False) self.textview_plugin_documentation_text.set_editable(False) # # DIALOG ABOUT # self.about_dialog = Gtk.AboutDialog.new() self.about_dialog.set_name(NAME) self.about_dialog.set_version(VERSION) self.about_dialog.set_license(LICENSE) self.about_dialog.set_wrap_license(True) self.about_dialog.set_copyright(COPYRIGHT) self.about_dialog.set_authors(AUTHORS) # # GET WIDGETS # self.imagemenuitem_quit = \ self.builder.get_object('imagemenuitemQuit') self.imagemenuitem_about = \ self.builder.get_object('imagemenuitemAbout') self.label_actual_profile = \ self.builder.get_object('labelActualProfile') self.label_recommended_profile = \ self.builder.get_object('label_recommemnded_profile') self.label_dbus_status = \ self.builder.get_object('labelDbusStatus') self.label_summary_profile = \ self.builder.get_object('summaryProfileName') self.label_summary_included_profile = \ self.builder.get_object('summaryIncludedProfileName') self.comboboxtext_fast_change_profile = \ self.builder.get_object('comboboxtextFastChangeProfile') self.button_fast_change_profile = \ self.builder.get_object('buttonFastChangeProfile') self.spinner_fast_change_profile = \ self.builder.get_object('spinnerFastChangeProfile') self.spinner_fast_change_profile.hide() self.switch_tuned_start_stop = \ self.builder.get_object('switchTunedStartStop') self.switch_tuned_startup_start_stop = \ self.builder.get_object('switchTunedStartupStartStop') self.switch_tuned_admin_functions = \ self.builder.get_object('switchTunedAdminFunctions') self.treeview_profile_manager = \ self.builder.get_object('treeviewProfileManager') self.treeview_actual_plugins = \ self.builder.get_object('treeviewActualPlugins') # # SET WIDGETS # self.treestore_profiles = Gtk.ListStore(GObject.TYPE_STRING, GObject.TYPE_STRING) self.treestore_plugins = Gtk.ListStore(GObject.TYPE_STRING) for plugin in sorted(self.plugin_loader.plugins): self.treestore_plugins.append([plugin.name]) self.combobox_plugins = \ self.builder.get_object('comboboxPlugins') self.combobox_plugins.set_model(self.treestore_plugins) self.combobox_main_plugins = \ self.builder.get_object('comboboxMainPlugins') self.combobox_main_plugins.set_model(self.treestore_plugins) self.combobox_main_plugins.connect('changed', self.on_changed_combobox_plugins) self.combobox_include_profile.set_model(self.treestore_profiles) cell = Gtk.CellRendererText() self.combobox_include_profile.pack_start(cell, True) self.combobox_include_profile.add_attribute(cell, 'text', 0) self.treeview_profile_manager.append_column( Gtk.TreeViewColumn('Type', Gtk.CellRendererText(), text=1)) self.treeview_profile_manager.append_column( Gtk.TreeViewColumn('Name', Gtk.CellRendererText(), text=0)) self.treeview_profile_manager.set_model(self.treestore_profiles) for profile_name in self.manager.get_names(): if self.manager.is_profile_factory(profile_name): self.treestore_profiles.append( [profile_name, consts.PREFIX_PROFILE_FACTORY]) else: self.treestore_profiles.append( [profile_name, consts.PREFIX_PROFILE_USER]) self.treeview_profile_manager.get_selection().select_path(0) self.button_create_profile = \ self.builder.get_object('buttonCreateProfile') self.button_upadte_selected_profile = \ self.builder.get_object('buttonUpadteSelectedProfile') self.button_delete_selected_profile = \ self.builder.get_object('buttonDeleteSelectedProfile') self.label_actual_profile.set_text(self.controller.active_profile()) if self.config.get(consts.CFG_RECOMMEND_COMMAND): self.label_recommended_profile.set_text( self.controller.recommend_profile()) self.listbox_summary_of_active_profile = \ self.builder.get_object('listboxSummaryOfActiveProfile') self.data_for_listbox_summary_of_active_profile() self.comboboxtext_fast_change_profile.set_model( self.treestore_profiles) self.label_dbus_status.set_text(str(bool( self.controller.is_running()))) self.switch_tuned_start_stop.set_active(True) self.switch_tuned_startup_start_stop.set_active( self.service_run_on_start_up('tuned')) self.switch_tuned_admin_functions.set_active(self.is_admin) self.menu_add_plugin_value = \ self.builder.get_object('menuAddPluginValue') self.add_plugin_value_action = \ self.builder.get_object('addPluginValue') self.add_custom_plugin_value = \ self.builder.get_object('addCustomPluginValue') self.delete_plugin_value_action = \ self.builder.get_object('deletePluginValue') self.add_plugin_value_action.connect('activate', self.add_plugin_value_to_treeview) self.add_custom_plugin_value.connect( 'activate', self.add_custom_plugin_value_to_treeview) self.delete_plugin_value_action.connect( 'activate', self.delete_plugin_value_to_treeview) # # CONNECTIONS # self.imagemenuitem_quit.connect('activate', Gtk.main_quit) self.imagemenuitem_about.connect('activate', self.execute_about) self.comboboxtext_fast_change_profile.set_active( self.get_iter_from_model_by_name( self.comboboxtext_fast_change_profile.get_model(), self.controller.active_profile())) self.button_fast_change_profile.connect('clicked', self.execute_change_profile) self.switch_tuned_start_stop.connect('notify::active', self.execute_switch_tuned) self.switch_tuned_startup_start_stop.connect('notify::active', self.execute_switch_tuned) self.switch_tuned_admin_functions.connect( 'notify::active', self.execute_switch_tuned_admin_functions) self.button_create_profile.connect('clicked', self.execute_create_profile) self.button_upadte_selected_profile.connect( 'clicked', self.execute_update_profile) self.button_delete_selected_profile.connect( 'clicked', self.execute_remove_profile) self.button_confirm_profile_create = \ self.builder.get_object('buttonConfirmProfileCreate') self.button_confirm_profile_update = \ self.builder.get_object('buttonConfirmProfileUpdate') self.button_confirm_profile_create.connect( 'clicked', self.on_click_button_confirm_profile_create) self.button_confirm_profile_update.connect( 'clicked', self.on_click_button_confirm_profile_update) self.editing_profile_name = None self.treeview_actual_plugins.connect('row-activated', self.on_treeview_click) # self.treeview_profile_manager.connect('row-activated',lambda x,y,z: self.execute_update_profile(x,y)) # TO DO: need to be fixed! - double click on treeview self.main_window.connect('destroy', Gtk.main_quit) self.main_window.show() Gtk.main()
def __init__(self, name, nargs_max, nargs_min = None): self._name = name self._nargs_max = nargs_max self._nargs_min = nargs_min self._cmd = commands()
def __init__(self, daemon, global_config): super(self.__class__, self).__init__() self._daemon = daemon self._global_config = global_config self._terminate = threading.Event() self._cmd = commands()
def __init__(self, controller, debug = False): self._controller = controller self._debug = debug self._cmd = commands(debug)
def __init__(self, is_hardcoded=False): self._is_hardcoded = is_hardcoded self._commands = commands() self._chassis_type = None
def __init__(self, daemon): super(self.__class__, self).__init__() self._daemon = daemon self._terminate = threading.Event() self._cmd = commands()
from exceptions import TunedAdminDBusException from tuned.exceptions import TunedException import tuned.consts as consts import os import sys import errno import time import threading class Admin(object): def __init__(self, dbus = True, debug = False, async = False, timeout = consts.ADMIN_TIMEOUT): self._dbus = dbus self._debug = debug self._async = async self._timeout = timeout self._cmd = commands(debug) self._profiles_locator = profiles_locator(consts.LOAD_DIRECTORIES) self._daemon_action_finished = threading.Event() self._daemon_action_profile = "" self._daemon_action_result = True self._daemon_action_errstr = "" self._controller = None if self._dbus: self._controller = tuned.admin.DBusController(consts.DBUS_BUS, consts.DBUS_INTERFACE, consts.DBUS_OBJECT, debug) try: self._controller.set_signal_handler(consts.DBUS_SIGNAL_PROFILE_CHANGED, self._signal_profile_changed_cb) except TunedAdminDBusException as e: self._error(e) self._dbus = False def _error(self, message):
import base from decorators import * from subprocess import Popen,PIPE import tuned.logs from tuned.utils.commands import commands import glob log = tuned.logs.get() cmd = commands() class MountsPlugin(base.Plugin): """ Plugin for tuning options of mount-points. """ @classmethod def _generate_mountpoint_topology(cls): """ Gets the information about disks, partitions and mountpoints. Stores information about used filesystem and creates a list of all underlying devices (in case of LVM) for each mountpoint. """ mountpoint_topology = {} current_disk = None stdout, stderr = Popen(["/usr/bin/lsblk", "-rno", "TYPE,RM,KNAME,FSTYPE,MOUNTPOINT"], stdout=PIPE, stderr=PIPE, close_fds=True).communicate() for columns in map(lambda line: line.split(), stdout.splitlines()): if len(columns) < 3: continue device_type, device_removable, device_name = columns[:3] filesystem = columns[3] if len(columns) > 3 else None mountpoint = columns[4] if len(columns) > 4 else None
def __init__(self, *args, **kwargs): if not os.path.isfile(consts.GRUB2_TUNED_TEMPLATE_PATH): raise exceptions.NotSupportedPluginException("Required GRUB2 template not found, disabling plugin.") super(self.__class__, self).__init__(*args, **kwargs) self._cmd = commands()
def __init__(self, controller, debug=False): self._controller = controller self._debug = debug self._cmd = commands(debug)