diff --git a/tuned/plugins/plugin_audio.py b/tuned/plugins/plugin_audio.py index 24bca7c..18774b9 100644 --- a/tuned/plugins/plugin_audio.py +++ b/tuned/plugins/plugin_audio.py @@ -32,8 +32,8 @@ class VideoPlugin(tuned.plugins.Plugin): @classmethod def _get_default_options(cls): return { - "enable_ac97_powersave" : "", - "hda_intel_powersave" : "", + "enable_ac97_powersave" : None, + "hda_intel_powersave" : None, "dynamic_tuning" : "0", } @@ -51,11 +51,11 @@ class VideoPlugin(tuned.plugins.Plugin): value = "N" else: log.warn("Incorrect enable_ac97_powersave value.") - return "" + return sys_file = "/sys/module/snd_ac97_codec/parameters/power_save" if not os.path.exists(sys_file): - return "" + return old_value = tuned.utils.commands.read_file(sys_file) tuned.utils.commands.write_to_file(sys_file, value) @@ -73,7 +73,7 @@ class VideoPlugin(tuned.plugins.Plugin): def _set_hda_intel_powersave(self, value): sys_file = "/sys/module/snd_hda_intel/parameters/power_save" if not os.path.exists(sys_file): - return "" + return old_value = tuned.utils.commands.read_file(sys_file) tuned.utils.commands.write_to_file(sys_file, value) diff --git a/tuned/plugins/plugin_cpu.py b/tuned/plugins/plugin_cpu.py index e47ed02..dd75053 100644 --- a/tuned/plugins/plugin_cpu.py +++ b/tuned/plugins/plugin_cpu.py @@ -47,10 +47,10 @@ class CPULatencyPlugin(tuned.plugins.Plugin): "load_threshold" : 0.2, "latency_low" : 100, "latency_high" : 1000, - "latency" : "", - "cpu_governor" : "", - "cpu_multicore_powersave" : "", - "enable_usb_autosupend" : "", + "latency" : None, + "cpu_governor" : None, + "cpu_multicore_powersave" : None, + "enable_usb_autosupend" : None, } def cleanup(self): @@ -107,7 +107,7 @@ class CPULatencyPlugin(tuned.plugins.Plugin): old_value = tuned.utils.commands.execute(["cpupower", "info", "-m"]) if old_value.find("not supported") != -1: log.info("cpu_multicore_powersave is not supported by this system") - return "" + return if old_value.startswith("System's multi core scheduler setting"): try: @@ -132,7 +132,7 @@ class CPULatencyPlugin(tuned.plugins.Plugin): value = "0" else: log.warn("Incorrect enable_bluetooth value.") - return "" + return for sys_file in glob.glob("/sys/bus/usb/devices/*/power/autosuspend"): old_value[sys_file] = tuned.utils.commands.read_file(sys_file) tuned.utils.commands.write_to_file(sys_file, value) diff --git a/tuned/plugins/plugin_disk.py b/tuned/plugins/plugin_disk.py index 6e27439..ed08cfb 100644 --- a/tuned/plugins/plugin_disk.py +++ b/tuned/plugins/plugin_disk.py @@ -73,12 +73,12 @@ class DiskPlugin(tuned.plugins.Plugin): @classmethod def _get_default_options(cls): return { - "elevator" : "", - "disk_alpm" : "", - "disk_apm" : "", - "disk_spindown" : "", - "disk_readahead_multiplier" : "", - "disk_scheduler_quantum" : "", + "elevator" : None, + "disk_alpm" : None, + "disk_apm" : None, + "disk_spindown" : None, + "disk_readahead_multiplier" : None, + "disk_scheduler_quantum" : None, } def _update_idle(self, dev): @@ -204,7 +204,7 @@ class DiskPlugin(tuned.plugins.Plugin): def _set_disk_apm(self, dev, value): #TODO: get current value using hdparm -B. My disk does not support it... tuned.utils.commands.execute(["hdparm", "-B", value, "/dev/" + dev]) - return "" + return @command_revert("disk", "disk_apm") def _revert_disk_apm(self, dev, value): @@ -221,7 +221,7 @@ class DiskPlugin(tuned.plugins.Plugin): old_value = tuned.utils.commands.read_file(sys_file).strip() if len(old_value) == 0: - return "" + return new_value = int(int(old_value) * float(value)) tuned.utils.commands.write_to_file(sys_file, new_value) @@ -239,7 +239,7 @@ class DiskPlugin(tuned.plugins.Plugin): old_value = tuned.utils.commands.read_file(sys_file).strip() if len(old_value) == 0: log.info("disk_scheduler_quantum option is not supported by this HW") - return "" + return tuned.utils.commands.write_to_file(sys_file, value) return old_value diff --git a/tuned/plugins/plugin_script.py b/tuned/plugins/plugin_script.py index ec55b9a..81eabc8 100644 --- a/tuned/plugins/plugin_script.py +++ b/tuned/plugins/plugin_script.py @@ -26,7 +26,7 @@ class ScriptPlugin(tuned.plugins.Plugin): @classmethod def _get_default_options(cls): return { - "script" : "", + "script" : None, "dynamic_tuning" : "0", } diff --git a/tuned/plugins/plugin_video.py b/tuned/plugins/plugin_video.py index 6d8aa15..edb9e99 100644 --- a/tuned/plugins/plugin_video.py +++ b/tuned/plugins/plugin_video.py @@ -30,7 +30,7 @@ class VideoPlugin(tuned.plugins.Plugin): def _get_default_options(cls): return { "dynamic_tuning" : "0", - "radeon_powersave" : "", + "radeon_powersave" : None, } def cleanup(self): @@ -42,7 +42,7 @@ class VideoPlugin(tuned.plugins.Plugin): @command(STORAGE_CATEGORY, "radeon_powersave") def _set_radeon_powersave(self, value): if not os.path.exists("/sys/class/drm/card0/device/power_method"): - return "" + return old_values = [] if value in ["default", "auto", "low", "med", "high"]: diff --git a/tuned/plugins/plugin_wireless.py b/tuned/plugins/plugin_wireless.py index 15715e8..572f1f7 100644 --- a/tuned/plugins/plugin_wireless.py +++ b/tuned/plugins/plugin_wireless.py @@ -27,8 +27,8 @@ class WirelessPlugin(tuned.plugins.Plugin): def _get_default_options(cls): return { "dynamic_tuning" : "0", - "wifi_power_level" : "", - "enable_bluetooth" : "", + "wifi_power_level" : None, + "enable_bluetooth" : None, } def cleanup(self): @@ -43,7 +43,7 @@ class WirelessPlugin(tuned.plugins.Plugin): lines = open("/proc/net/wireless").readlines() except (OSError,IOError) as e: log.error("Error reading wifi devices from /proc/net/wireless: %s" % (e)) - return "" + return ifaces = [] for line in lines: @@ -56,7 +56,7 @@ class WirelessPlugin(tuned.plugins.Plugin): if len(ifaces) == 0: log.info("No wifi interfaces found") - return "" + return # TODO: set old_value properly. Is there "get_power"? I don't have wifi here old_value = "5" @@ -80,7 +80,7 @@ class WirelessPlugin(tuned.plugins.Plugin): tuned.utils.commands.execute(["rmmod", "hci_usb"]) else: log.warn("Incorrect enable_bluetooth value.") - return "" + return return old_value diff --git a/tuned/utils/commands.py b/tuned/utils/commands.py index 730c4a2..c7ef3c0 100644 --- a/tuned/utils/commands.py +++ b/tuned/utils/commands.py @@ -88,7 +88,7 @@ def command(plugin, key): return False old_value = target(self, *args, **kwargs) - if len(old_value) != 0: + if old_value and len(old_value) != 0: storage.data[plugin][key + dev] = old_value storage.save() return True