Skip to content

Commit

Permalink
chore: remove use of deprecated Logger.warn()
Browse files Browse the repository at this point in the history
Always use warning(), as warn() has been removed from Python with v3.13.

Signed-off-by: Adriaan Schmidt <[email protected]>
  • Loading branch information
adriaan42 committed Jun 15, 2024
1 parent 0b2461e commit 85e1e96
Show file tree
Hide file tree
Showing 17 changed files with 45 additions and 45 deletions.
2 changes: 1 addition & 1 deletion tuned/daemon/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion tuned/daemon/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 2 additions & 2 deletions tuned/exports/dbus_exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down
2 changes: 1 addition & 1 deletion tuned/hardware/inventory.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
8 changes: 4 additions & 4 deletions tuned/plugins/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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. " \
Expand Down Expand Up @@ -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):
Expand Down
2 changes: 1 addition & 1 deletion tuned/plugins/plugin_acpi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
16 changes: 8 additions & 8 deletions tuned/plugins/plugin_bootloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]

Expand Down Expand Up @@ -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]
Expand Down Expand Up @@ -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

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

Expand All @@ -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):
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 2 additions & 2 deletions tuned/plugins/plugin_cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
4 changes: 2 additions & 2 deletions tuned/plugins/plugin_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tuned/plugins/plugin_irqbalance.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down
8 changes: 4 additions & 4 deletions tuned/plugins/plugin_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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:
Expand Down Expand Up @@ -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),
Expand Down
12 changes: 6 additions & 6 deletions tuned/plugins/plugin_net.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand All @@ -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

Expand Down Expand Up @@ -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

Expand Down
4 changes: 2 additions & 2 deletions tuned/plugins/plugin_scheduler.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
6 changes: 3 additions & 3 deletions tuned/plugins/plugin_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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")
Expand Down
6 changes: 3 additions & 3 deletions tuned/plugins/plugin_vm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion tuned/profiles/functions/function_check_net_queue_count.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions tuned/utils/profile_recommender.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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.")
Expand Down

0 comments on commit 85e1e96

Please sign in to comment.