From 85e1e96ae62b3bb6b1acbd3e86f5f64e365f7a7f Mon Sep 17 00:00:00 2001 From: Adriaan Schmidt Date: Sat, 15 Jun 2024 09:00:39 +0200 Subject: [PATCH] chore: remove use of deprecated Logger.warn() Always use warning(), as warn() has been removed from Python with v3.13. Signed-off-by: Adriaan Schmidt --- tuned/daemon/application.py | 2 +- tuned/daemon/controller.py | 2 +- tuned/exports/dbus_exporter.py | 4 ++-- tuned/hardware/inventory.py | 2 +- tuned/plugins/base.py | 8 ++++---- tuned/plugins/plugin_acpi.py | 2 +- tuned/plugins/plugin_bootloader.py | 16 ++++++++-------- tuned/plugins/plugin_cpu.py | 4 ++-- tuned/plugins/plugin_disk.py | 4 ++-- tuned/plugins/plugin_irqbalance.py | 4 ++-- tuned/plugins/plugin_modules.py | 8 ++++---- tuned/plugins/plugin_net.py | 12 ++++++------ tuned/plugins/plugin_scheduler.py | 4 ++-- tuned/plugins/plugin_video.py | 6 +++--- tuned/plugins/plugin_vm.py | 6 +++--- .../functions/function_check_net_queue_count.py | 2 +- tuned/utils/profile_recommender.py | 4 ++-- 17 files changed, 45 insertions(+), 45 deletions(-) diff --git a/tuned/daemon/application.py b/tuned/daemon/application.py index a7400cfee..3e2684b7a 100644 --- a/tuned/daemon/application.py +++ b/tuned/daemon/application.py @@ -211,7 +211,7 @@ def run(self, daemon): if daemon: self.config.set(consts.CFG_DAEMON, True) if not self.config.get_bool(consts.CFG_DAEMON, consts.CFG_DEF_DAEMON): - log.warn("Using one shot no daemon mode, most of the functionality will be not available, it can be changed in global config") + log.warning("Using one shot no daemon mode, most of the functionality will be not available, it can be changed in global config") result = self._controller.run() if self.config.get_bool(consts.CFG_DAEMON, consts.CFG_DEF_DAEMON): exports.stop() diff --git a/tuned/daemon/controller.py b/tuned/daemon/controller.py index 7ddcd2d6b..4f43d5467 100644 --- a/tuned/daemon/controller.py +++ b/tuned/daemon/controller.py @@ -178,7 +178,7 @@ def _switch_profile(self, profile_name, manual): finally: if was_running: if reapply: - log.warn("Applying previously applied (possibly out-dated) profile '%s'." % profile_name) + log.warning("Applying previously applied (possibly out-dated) profile '%s'." % profile_name) elif not success: log.info("Applying previously applied profile.") self._daemon.start() diff --git a/tuned/exports/dbus_exporter.py b/tuned/exports/dbus_exporter.py index b0a9f9bd1..0c9e8be31 100644 --- a/tuned/exports/dbus_exporter.py +++ b/tuned/exports/dbus_exporter.py @@ -139,12 +139,12 @@ def wrapper(owner, *args, **kwargs): if ret == 1: log.debug("action '%s' requested by caller '%s' was successfully authorized by polkit" % (action_id, caller)) elif ret == 2: - log.warn("polkit error, but action '%s' requested by caller '%s' was successfully authorized by fallback method" % (action_id, caller)) + log.warning("polkit error, but action '%s' requested by caller '%s' was successfully authorized by fallback method" % (action_id, caller)) elif ret == 0: log.info("action '%s' requested by caller '%s' wasn't authorized, ignoring the request" % (action_id, caller)) args_copy = list(args[:-1]) + [""] elif ret == -1: - log.warn("polkit error and action '%s' requested by caller '%s' wasn't authorized by fallback method, ignoring the request" % (action_id, caller)) + log.warning("polkit error and action '%s' requested by caller '%s' wasn't authorized by fallback method, ignoring the request" % (action_id, caller)) args_copy = list(args[:-1]) + [""] else: log.error("polkit error and unable to use fallback method to authorize action '%s' requested by caller '%s', ignoring the request" % (action_id, caller)) diff --git a/tuned/hardware/inventory.py b/tuned/hardware/inventory.py index a08e45609..d661b5265 100644 --- a/tuned/hardware/inventory.py +++ b/tuned/hardware/inventory.py @@ -28,7 +28,7 @@ def __init__(self, udev_context=None, udev_monitor_cls=None, monitor_observer_fa try: self._udev_monitor.set_receive_buffer_size(buffer_size) except EnvironmentError: - log.warn("cannot set udev monitor receive buffer size, we are probably running inside " + + log.warning("cannot set udev monitor receive buffer size, we are probably running inside " + "container or with limited capabilites, TuneD functionality may be limited") if monitor_observer_factory is None: diff --git a/tuned/plugins/base.py b/tuned/plugins/base.py index afeb37f85..cd54aea5f 100644 --- a/tuned/plugins/base.py +++ b/tuned/plugins/base.py @@ -80,7 +80,7 @@ def _get_effective_options(self, options): if key in effective or self._has_dynamic_options: effective[key] = options[key] else: - log.warn("Unknown option '%s' for plugin '%s'." % (key, self.__class__.__name__)) + log.warning("Unknown option '%s' for plugin '%s'." % (key, self.__class__.__name__)) return effective def _option_bool(self, value): @@ -172,7 +172,7 @@ def assign_free_devices(self, instance): to_assign = self._get_matching_devices(instance, self._free_devices) instance.active = len(to_assign) > 0 if not instance.active: - log.warn("instance %s: no matching devices available" % instance.name) + log.warning("instance %s: no matching devices available" % instance.name) else: name = instance.name if instance.name != self.name: @@ -217,7 +217,7 @@ def _call_device_script(self, instance, script, op, devices, rollback = consts.R if script is None: return None if len(devices) == 0: - log.warn("Instance '%s': no device to call script '%s' for." % (instance.name, script)) + log.warning("Instance '%s': no device to call script '%s' for." % (instance.name, script)) return None if not script.startswith("/"): log.error("Relative paths cannot be used in script_pre or script_post. " \ @@ -489,7 +489,7 @@ def _process_assignment_modifiers(self, new_value, current_value): else: return None except ValueError: - log.warn("cannot compare new value '%s' with current value '%s' by operator '%s', using '%s' directly as new value" % (val, current_value, op, new_value)) + log.warning("cannot compare new value '%s' with current value '%s' by operator '%s', using '%s' directly as new value" % (val, current_value, op, new_value)) return new_value def _get_current_value(self, command, device = None, ignore_missing=False): diff --git a/tuned/plugins/plugin_acpi.py b/tuned/plugins/plugin_acpi.py index 38eca6829..bfb105dcd 100644 --- a/tuned/plugins/plugin_acpi.py +++ b/tuned/plugins/plugin_acpi.py @@ -69,7 +69,7 @@ def _set_platform_profile(self, profiles, sim, remove): self._cmd.write_to_file(self._platform_profile_path(), profile, \ no_error=[errno.ENOENT] if remove else False) return profile - log.warn("Requested platform_profile '%s' unavailable" % profile) + log.warning("Requested platform_profile '%s' unavailable" % profile) log.error("Failed to set platform_profile. Is the value in the profile correct?") return None diff --git a/tuned/plugins/plugin_bootloader.py b/tuned/plugins/plugin_bootloader.py index 1b79c3813..8a7621fba 100644 --- a/tuned/plugins/plugin_bootloader.py +++ b/tuned/plugins/plugin_bootloader.py @@ -251,7 +251,7 @@ def _rpm_ostree_status(self): return None splited = out.split() if len(splited) < 2 or splited[0] != "State:": - log.warn("Exceptional format of rpm-ostree status result:\n%s" % out) + log.warning("Exceptional format of rpm-ostree status result:\n%s" % out) return None return splited[1] @@ -328,7 +328,7 @@ def _get_effective_options(self, options): elif key in effective: effective[key] = options[key] else: - log.warn("Unknown option '%s' for plugin '%s'." % (key, self.__class__.__name__)) + log.warning("Unknown option '%s' for plugin '%s'." % (key, self.__class__.__name__)) cmdline = "" for key in cmdline_keys: val = options[key] @@ -524,7 +524,7 @@ def _update_grubenv(self, d): l = ["%s=%s" % (str(option), str(value)) for option, value in d.items()] (rc, out) = self._cmd.execute(["grub2-editenv", "-", "set"] + l) if rc != 0: - log.warn("cannot update grubenv: '%s'" % out) + log.warning("cannot update grubenv: '%s'" % out) return False return True @@ -535,7 +535,7 @@ def _bls_entries_patch_initial(self): log.debug("running kernel update hook '%s' to patch BLS entries" % consts.KERNEL_UPDATE_HOOK_FILE) (rc, out) = self._cmd.execute([consts.KERNEL_UPDATE_HOOK_FILE, "add"], env = {"KERNEL_INSTALL_MACHINE_ID" : machine_id}) if rc != 0: - log.warn("cannot patch BLS entries: '%s'" % out) + log.warning("cannot patch BLS entries: '%s'" % out) return False return True @@ -556,10 +556,10 @@ def _check_petitboot(self): def _install_initrd(self, img): if self._rpm_ostree: - log.warn("Detected rpm-ostree which doesn't support initrd overlays.") + log.warning("Detected rpm-ostree which doesn't support initrd overlays.") return False if self._check_petitboot(): - log.warn("Detected Petitboot which doesn't support initrd overlays. The initrd overlay will be ignored by bootloader.") + log.warning("Detected Petitboot which doesn't support initrd overlays. The initrd overlay will be ignored by bootloader.") log.info("installing initrd image as '%s'" % self._initrd_dst_img_val) img_name = os.path.basename(self._initrd_dst_img_val) if not self._cmd.copy(img, self._initrd_dst_img_val): @@ -691,9 +691,9 @@ def _skip_grub_config(self, enabling, value, verify, ignore_missing): def _instance_post_static(self, instance, enabling): if enabling and self._skip_grub_config_val: if len(self._initrd_val) > 0: - log.warn("requested changes to initrd will not be applied!") + log.warning("requested changes to initrd will not be applied!") if len(self._cmdline_val) > 0: - log.warn("requested changes to cmdline will not be applied!") + log.warning("requested changes to cmdline will not be applied!") # ensure that the desired cmdline is always written to BOOT_CMDLINE_FILE (/etc/tuned/bootcmdline) self._patch_bootcmdline({consts.BOOT_CMDLINE_TUNED_VAR : self._cmdline_val, consts.BOOT_CMDLINE_INITRD_ADD_VAR : self._initrd_val}) elif enabling and self.update_grub2_cfg: diff --git a/tuned/plugins/plugin_cpu.py b/tuned/plugins/plugin_cpu.py index 4a5ef1bf5..767e68c39 100644 --- a/tuned/plugins/plugin_cpu.py +++ b/tuned/plugins/plugin_cpu.py @@ -535,7 +535,7 @@ def _set_governor(self, governors, device, sim, remove): log.debug("Ignoring governor '%s' on cpu '%s', it is not supported" % (governor, device)) else: - log.warn("None of the scaling governors is supported: %s" + log.warning("None of the scaling governors is supported: %s" % ", ".join(governors)) governor = None return governor @@ -765,7 +765,7 @@ def _set_energy_performance_preference(self, energy_performance_preference, devi log.info("Setting energy_performance_preference value '%s' for cpu '%s'" % (val, device)) break else: - log.warn("energy_performance_preference value '%s' unavailable for cpu '%s'" % (val, device)) + log.warning("energy_performance_preference value '%s' unavailable for cpu '%s'" % (val, device)) else: log.error("Failed to set energy_performance_preference on cpu '%s'. Is the value in the profile correct?" % device) diff --git a/tuned/plugins/plugin_disk.py b/tuned/plugins/plugin_disk.py index d6feb06c5..6fe52a728 100644 --- a/tuned/plugins/plugin_disk.py +++ b/tuned/plugins/plugin_disk.py @@ -117,7 +117,7 @@ def _is_hdparm_apm_supported(self, device): (rc, out, err_msg) = self._cmd.execute(["hdparm", "-C", "/dev/%s" % device], \ no_errors = [errno.ENOENT], return_err=True) if rc == -errno.ENOENT: - log.warn("hdparm command not found, ignoring for other devices") + log.warning("hdparm command not found, ignoring for other devices") self._use_hdparm = False return False elif rc: @@ -214,7 +214,7 @@ def _update_errcnt(self, rc, spindown): cnt = 0 elif rc == -errno.ENOENT: self._spindown_errcnt = self._apm_errcnt = consts.ERROR_THRESHOLD + 1 - log.warn("hdparm command not found, ignoring future set_apm / set_spindown commands") + log.warning("hdparm command not found, ignoring future set_apm / set_spindown commands") return else: cnt += 1 diff --git a/tuned/plugins/plugin_irqbalance.py b/tuned/plugins/plugin_irqbalance.py index d8e9e59fb..0db8fdc1f 100644 --- a/tuned/plugins/plugin_irqbalance.py +++ b/tuned/plugins/plugin_irqbalance.py @@ -52,7 +52,7 @@ def _read_irqbalance_sysconfig(self): return f.read() except IOError as e: if e.errno == errno.ENOENT: - log.warn("irqbalance sysconfig file is missing. Is irqbalance installed?") + log.warning("irqbalance sysconfig file is missing. Is irqbalance installed?") else: log.error("Failed to read irqbalance sysconfig file: %s" % e) return None @@ -83,7 +83,7 @@ def _restart_irqbalance(self): ["systemctl", "try-restart", "irqbalance"], no_errors=[5]) if retcode != 0: - log.warn("Failed to restart irqbalance. Is it installed?") + log.warning("Failed to restart irqbalance. Is it installed?") def _set_banned_cpus(self, banned_cpumask): content = self._read_irqbalance_sysconfig() diff --git a/tuned/plugins/plugin_modules.py b/tuned/plugins/plugin_modules.py index fa2d04b1a..06ea4c62b 100644 --- a/tuned/plugins/plugin_modules.py +++ b/tuned/plugins/plugin_modules.py @@ -65,13 +65,13 @@ def _reload_modules(self, modules): for module in modules: retcode, out = self._cmd.execute(["modprobe", "-r", module]) if retcode < 0: - log.warn("'modprobe' command not found, cannot reload kernel modules, reboot is required") + log.warning("'modprobe' command not found, cannot reload kernel modules, reboot is required") return elif retcode > 0: log.debug("cannot remove kernel module '%s': %s" % (module, out.strip())) retcode, out = self._cmd.execute(["modprobe", module]) if retcode != 0: - log.warn("cannot insert/reinsert module '%s', reboot is required: %s" % (module, out.strip())) + log.warning("cannot insert/reinsert module '%s', reboot is required: %s" % (module, out.strip())) def _instance_apply_static(self, instance): self._clear_modprobe_file() @@ -86,7 +86,7 @@ def _instance_apply_static(self, instance): retcode, out = self._cmd.execute(["modinfo", module]) if retcode < 0: skip_check = True - log.warn("'modinfo' command not found, not checking kernel modules") + log.warning("'modinfo' command not found, not checking kernel modules") elif retcode > 0: log.error("kernel module '%s' not found, skipping it" % module) if skip_check or retcode == 0: @@ -126,7 +126,7 @@ def _instance_verify_static(self, instance, ignore_missing, devices): for item in l: arg = item.split("=", 1) if len(arg) != 2: - log.warn("unrecognized module option for module '%s': %s" % (module, item)) + log.warning("unrecognized module option for module '%s': %s" % (module, item)) else: if self._verify_value(arg[0], arg[1], self._cmd.read_file(mpath + "/parameters/" + self._unquote_path(arg[0]), err_ret = None, no_error = True), diff --git a/tuned/plugins/plugin_net.py b/tuned/plugins/plugin_net.py index 521198a16..873dc792c 100644 --- a/tuned/plugins/plugin_net.py +++ b/tuned/plugins/plugin_net.py @@ -387,7 +387,7 @@ def _set_wake_on_lan(self, value, device, sim, remove): # see man ethtool for possible wol values, 0 added as an alias for 'd' value = re.sub(r"0", "d", str(value)); if not re.match(r"^[" + WOL_VALUES + r"]+$", value): - log.warn("Incorrect 'wake_on_lan' value.") + log.warning("Incorrect 'wake_on_lan' value.") return None if not sim: @@ -432,7 +432,7 @@ def _call_ip_link(self, args=[]): args = ["ip", "link"] + args (rc, out, err_msg) = self._cmd.execute(args, no_errors=[errno.ENOENT], return_err=True) if rc == -errno.ENOENT: - log.warn("ip command not found, ignoring for other devices") + log.warning("ip command not found, ignoring for other devices") self._use_ip = False return None elif rc: @@ -454,13 +454,13 @@ def _set_txqueuelen(self, value, device, sim, remove): try: int(value) except ValueError: - log.warn("txqueuelen value '%s' is not integer" % value) + log.warning("txqueuelen value '%s' is not integer" % value) return None if not sim: # there is inconsistency in "ip", where "txqueuelen" is set as it, but is shown as "qlen" res = self._call_ip_link(["set", "dev", device, "txqueuelen", value]) if res is None: - log.warn("Cannot set txqueuelen for device '%s'" % device) + log.warning("Cannot set txqueuelen for device '%s'" % device) return None return value @@ -494,12 +494,12 @@ def _set_mtu(self, value, device, sim, remove): try: int(value) except ValueError: - log.warn("mtu value '%s' is not integer" % value) + log.warning("mtu value '%s' is not integer" % value) return None if not sim: res = self._call_ip_link(["set", "dev", device, "mtu", value]) if res is None: - log.warn("Cannot set mtu for device '%s'" % device) + log.warning("Cannot set mtu for device '%s'" % device) return None return value diff --git a/tuned/plugins/plugin_scheduler.py b/tuned/plugins/plugin_scheduler.py index 85d615159..c9ac01b86 100644 --- a/tuned/plugins/plugin_scheduler.py +++ b/tuned/plugins/plugin_scheduler.py @@ -660,7 +660,7 @@ def _affinity_changeable(self, pid): log.debug("Affinity of kernel thread with PID %d cannot be changed, the task's affinity mask is fixed." % pid) else: - log.warn("Affinity of task with PID %d cannot be changed, the task's affinity mask is fixed." + log.warning("Affinity of task with PID %d cannot be changed, the task's affinity mask is fixed." % pid) return 0 else: @@ -1003,7 +1003,7 @@ def _cgroup_cleanup_tasks_one(self, cgroup): self._cmd.write_to_file("%s/%s" % (self._cgroup_mount_point, "tasks"), l, no_error = True) cnt -= 1 if cnt == 0: - log.warn("Unable to cleanup tasks from cgroup '%s'" % cgroup) + log.warning("Unable to cleanup tasks from cgroup '%s'" % cgroup) def _cgroup_cleanup_tasks(self): if self._cgroup is not None and not self._cgroup in self._cgroups: diff --git a/tuned/plugins/plugin_video.py b/tuned/plugins/plugin_video.py index 4bd76ddd5..b2b934b08 100644 --- a/tuned/plugins/plugin_video.py +++ b/tuned/plugins/plugin_video.py @@ -142,7 +142,7 @@ def _set_radeon_powersave(self, value, device, sim, remove): return v else: if not sim: - log.warn("Invalid option for radeon_powersave.") + log.warning("Invalid option for radeon_powersave.") return None return None @@ -168,12 +168,12 @@ def _set_panel_power_savings(self, value, device, sim, remove): try: value = int(value, 10) except ValueError: - log.warn("Invalid value %s for panel_power_savings" % value) + log.warning("Invalid value %s for panel_power_savings" % value) return None if value in range(0, 5): return self.apply_panel_power_saving_target(device, value, sim) else: - log.warn("Invalid value %s for panel_power_savings" % value) + log.warning("Invalid value %s for panel_power_savings" % value) return None @command_get("panel_power_savings") diff --git a/tuned/plugins/plugin_vm.py b/tuned/plugins/plugin_vm.py index e86230b63..d7f9d30c6 100644 --- a/tuned/plugins/plugin_vm.py +++ b/tuned/plugins/plugin_vm.py @@ -61,7 +61,7 @@ def _thp_path(self): def _set_transparent_hugepages(self, value, sim, remove): if value not in ["always", "never", "madvise"]: if not sim: - log.warn("Incorrect 'transparent_hugepages' value '%s'." % str(value)) + log.warning("Incorrect 'transparent_hugepages' value '%s'." % str(value)) return None cmdline = cmd.read_file("/proc/cmdline", no_error = True) @@ -78,7 +78,7 @@ def _set_transparent_hugepages(self, value, sim, remove): return value else: if not sim: - log.warn("Option 'transparent_hugepages' is not supported on current hardware.") + log.warning("Option 'transparent_hugepages' is not supported on current hardware.") return None # just an alias to transparent_hugepages @@ -109,7 +109,7 @@ def _set_transparent_hugepage_defrag(self, value, sim, remove): return value else: if not sim: - log.warn("Option 'transparent_hugepage.defrag' is not supported on current hardware.") + log.warning("Option 'transparent_hugepage.defrag' is not supported on current hardware.") return None @command_get("transparent_hugepage.defrag") diff --git a/tuned/profiles/functions/function_check_net_queue_count.py b/tuned/profiles/functions/function_check_net_queue_count.py index eb54f98a6..379bd131d 100644 --- a/tuned/profiles/functions/function_check_net_queue_count.py +++ b/tuned/profiles/functions/function_check_net_queue_count.py @@ -18,5 +18,5 @@ def execute(self, args): if args[0].isdigit(): return args[0] (ret, out) = self._cmd.execute(["nproc"]) - log.warn("net-dev queue count is not correctly specified, setting it to HK CPUs %s" % (out)) + log.warning("net-dev queue count is not correctly specified, setting it to HK CPUs %s" % (out)) return out diff --git a/tuned/utils/profile_recommender.py b/tuned/utils/profile_recommender.py index 97eb9a26f..c4f8d95c5 100644 --- a/tuned/utils/profile_recommender.py +++ b/tuned/utils/profile_recommender.py @@ -148,7 +148,7 @@ def _get_chassis_type(self): except IndexError: log.error("Unknown chassis type id read from dmi sysfs: %d" % chassis_type_id) except (OSError, IOError) as e: - log.warn("error accessing dmi sysfs file: %s" % e) + log.warning("error accessing dmi sysfs file: %s" % e) if self._chassis_type: log.debug("chassis type - %s" % self._chassis_type) @@ -167,7 +167,7 @@ def _get_chassis_type(self): else: self._chassis_type = dmi_output.strip().decode() except (OSError, IOError) as e: - log.warn("error executing dmidecode tool : %s" % e) + log.warning("error executing dmidecode tool : %s" % e) if not self._chassis_type: log.debug("could not determine chassis type.")