Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replacing deprecated 'warn' function with 'warning' #3984

Merged
merged 1 commit into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion avocado_vt/plugins/vt_joblock.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _lock(self, job):
try:
os.unlink(path)
except OSError:
self.log.warn("Unable to remove stale lock: %s", path)
self.log.warning("Unable to remove stale lock: %s", path)

@staticmethod
def _get_klass_or_none(test_factory):
Expand Down
6 changes: 4 additions & 2 deletions avocado_vt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,12 +142,14 @@ def _safe_env_save(self, env):
try:
pickle.dumps(env.data)
except Exception:
self.log.warn(
self.log.warning(
"Unable to save environment: %s",
stacktrace.str_unpickable_object(env.data),
)
else:
self.log.warn("Unable to save environment: %s (%s)", details, env.data)
self.log.warning(
"Unable to save environment: %s (%s)", details, env.data
)
return True
return False

Expand Down
2 changes: 1 addition & 1 deletion virttest/bootstrap.py
Original file line number Diff line number Diff line change
Expand Up @@ -924,7 +924,7 @@ def bootstrap(options, interactive=False):
asset.download_all_test_providers(get_opt(options, "vt_update_providers"))
else:
if not_downloaded:
LOG.warn(
LOG.warning(
"The following test providers have not been downloaded: %s",
", ".join(not_downloaded),
)
Expand Down
2 changes: 1 addition & 1 deletion virttest/cartesian_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -1509,7 +1509,7 @@ def _debug(self, s, *args):
LOG.debug(s, *args)

def _warn(self, s, *args):
LOG.warn(s, *args)
LOG.warning(s, *args)

def parse_file(self, filename):
"""
Expand Down
8 changes: 4 additions & 4 deletions virttest/cpu.py
Original file line number Diff line number Diff line change
Expand Up @@ -1045,7 +1045,7 @@ def _make_up_pattern(flags):
cpu_model = cpu_type
cpu_support_model.append(cpu_model)
else:
LOG.warn("Can not Get cpu flags from cpuinfo")
LOG.warning("Can not Get cpu flags from cpuinfo")

return cpu_support_model

Expand Down Expand Up @@ -1200,15 +1200,15 @@ def get_model_features(model_name):
features.append(feature.get("name"))
break
except ET.ParseError as error:
LOG.warn("Configuration file %s has wrong xml format" % conf)
LOG.warning("Configuration file %s has wrong xml format" % conf)
raise
except AttributeError as elem_attr:
LOG.warn("No attribute %s in file %s" % (str(elem_attr), conf))
LOG.warning("No attribute %s in file %s" % (str(elem_attr), conf))
raise
except Exception:
# Other exceptions like IOError when open/read configuration file,
# capture here
LOG.warn(
LOG.warning(
"Some other exceptions, like configuration file is not "
"found or not file: %s" % conf
)
Expand Down
30 changes: 15 additions & 15 deletions virttest/env_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -409,7 +409,7 @@ def preprocess_vm(test, params, env, name):
debug_msg += "There is no serial console in VM."
if debug_msg:
debug_msg += " Skip the kernel command line check."
LOG.warn(debug_msg)
LOG.warning(debug_msg)
return
cmd_line = params.get("kernel_cmd_line_str", "Command line:")
try:
Expand All @@ -435,7 +435,7 @@ def preprocess_vm(test, params, env, name):

LOG.info("Kernel command line get from serial port is as expect")
except Exception as err:
LOG.warn(
LOG.warning(
"Did not get the kernel command line from serial "
"port output. Skip the kernel command line check."
"Error is %s" % err
Expand Down Expand Up @@ -516,7 +516,7 @@ def check_image(test, params, image_name, vm_process_status=None):
if params.get(
"skip_cluster_leak_warn"
) == "yes" and "Leaked clusters" in six.text_type(e):
LOG.warn(six.text_type(e))
LOG.warning(six.text_type(e))
else:
raise e

Expand All @@ -533,7 +533,7 @@ def postprocess_image(test, params, image_name, vm_process_status=None):
or None for no vm exist.
"""
if vm_process_status == "running":
LOG.warn(
LOG.warning(
"Skipped processing image '%s' since " "the VM is running!" % image_name
)
return
Expand Down Expand Up @@ -615,7 +615,7 @@ def postprocess_fs_source(test, params, fs_name, vm_process_status=None):
running, dead or None for no vm exist.
"""
if vm_process_status == "running":
LOG.warn(
LOG.warning(
"Skipped processing filesystem '%s' since " "the VM is running!" % fs_name
)
return
Expand Down Expand Up @@ -741,7 +741,7 @@ def process_command(test, params, env, command, command_timeout, command_noncrit
a_process.system("cd %s; %s" % (test.bindir, command), shell=True)
except a_process.CmdError as e:
if command_noncritical:
LOG.warn(e)
LOG.warning(e)
else:
raise

Expand Down Expand Up @@ -1617,7 +1617,7 @@ def postprocess(test, params, env):
ppm_file_rex = "*_iter%s.ppm" % test.iteration
for f in glob.glob(os.path.join(screendump_temp_dir, ppm_file_rex)):
if not ppm_utils.image_verify_ppm_file(f):
LOG.warn("Found corrupt PPM file: %s", f)
LOG.warning("Found corrupt PPM file: %s", f)

# Should we convert PPM files to PNG format?
if params.get("convert_ppm_files_to_png", "no") == "yes":
Expand Down Expand Up @@ -1669,7 +1669,7 @@ def postprocess(test, params, env):
session = vm.wait_for_serial_login(timeout=vm.LOGIN_WAIT_TIMEOUT)
session.close()
except (remote.LoginError, virt_vm.VMError, IndexError) as e:
LOG.warn(e)
LOG.warning(e)
vm.destroy(gracefully=False)

# Kill VMs with deleted disks
Expand Down Expand Up @@ -1874,16 +1874,16 @@ def _take_screendumps(test, params, env):
try:
vm.screendump(filename=temp_filename, debug=False)
except qemu_monitor.MonitorError as e:
LOG.warn(e)
LOG.warning(e)
continue
except AttributeError as e:
LOG.warn(e)
LOG.warning(e)
continue
if not os.path.exists(temp_filename):
LOG.warn("VM '%s' failed to produce a screendump", vm.name)
LOG.warning("VM '%s' failed to produce a screendump", vm.name)
continue
if not ppm_utils.image_verify_ppm_file(temp_filename):
LOG.warn("VM '%s' produced an invalid screendump", vm.name)
LOG.warning("VM '%s' produced an invalid screendump", vm.name)
os.unlink(temp_filename)
continue
screendump_dir = "screendumps_%s_%s_iter%s" % (
Expand Down Expand Up @@ -1973,10 +1973,10 @@ def store_vm_info(vm, log_filename, info_cmd="registers", append=False, vmtype="
try:
output = vm.catch_monitor.info(info_cmd, debug=False)
except qemu_monitor.MonitorError as err:
LOG.warn(err)
LOG.warning(err)
return False
except AttributeError as err:
LOG.warn(err)
LOG.warning(err)
return False
elif vmtype == "libvirt":
try:
Expand All @@ -1985,7 +1985,7 @@ def store_vm_info(vm, log_filename, info_cmd="registers", append=False, vmtype="
)
output = result.stdout
except Exception as details:
LOG.warn(details)
LOG.warning(details)
return False

log_filename = "%s_%s" % (log_filename, timestamp)
Expand Down
4 changes: 2 additions & 2 deletions virttest/guest_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def __init__(
except VAgentError as e:
self._close_sock()
if suppress_exceptions:
LOG.warn(e)
LOG.warning(e)
else:
raise

Expand Down Expand Up @@ -333,7 +333,7 @@ def _get_supported_cmds(self):
if not self._supported_cmds:
# If initiation fails, set supported list to a None-only list.
self._supported_cmds = [None]
LOG.warn("Could not get supported guest agent cmds list")
LOG.warning("Could not get supported guest agent cmds list")

def check_has_command(self, cmd):
"""
Expand Down
4 changes: 2 additions & 2 deletions virttest/ip_sniffing.py
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,7 @@ def _output_logger_handler(self, line):
try:
log_line(self._logfile, line)
except Exception as e:
LOG.warn("Can't log ip sniffer output: '%s'", e)
LOG.warning("Can't log ip sniffer output: '%s'", e)
if self._output_handler(line):
return
# We can check whether the process is terminated unexpectedly
Expand Down Expand Up @@ -349,7 +349,7 @@ def _output_handler(self, line):
if re.match(r"[0-9a-fA-F]{1,4}:\S+", packet[0]):
# TODO: support DHCPv6
if not self.__dict__.setdefault("_ip6_warned", False):
LOG.warn(
LOG.warning(
"IPv6 address sniffing is not supported yet by "
"using TShark, please fallback to use other "
"sniffers by uninstalling TShark when testing "
Expand Down
4 changes: 2 additions & 2 deletions virttest/libvirt_xml/domcapability_xml.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def get_additional_feature_list(self, cpu_mode_name, ignore_features=("invtsc",)
continue
feature_list.append(item)
except AttributeError as elem_attr:
LOG.warn("Failed to find attribute %s" % elem_attr)
LOG.warning("Failed to find attribute %s" % elem_attr)
feature_list = []
finally:
return feature_list
Expand Down Expand Up @@ -138,7 +138,7 @@ def get_hostmodel_name(self):
if mode_node.get("name") == "host-model":
return mode_node.find("model").text
except AttributeError as elem_attr:
LOG.warn("Failed to find attribute %s" % elem_attr)
LOG.warning("Failed to find attribute %s" % elem_attr)
return ""


Expand Down
18 changes: 10 additions & 8 deletions virttest/libvirtd_decorator.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,15 +65,17 @@ def get_libvirt_version_compare(major, minor, update, session=None):
func = session.cmd_output

if LIBVIRTD is None:
LOG.warn("Can not find command to dertermin libvirt version")
LOG.warning("Can not find command to dertermin libvirt version")
return False
libvirt_ver_cmd = "%s -V" % LIBVIRTD
LOG.warn(libvirt_ver_cmd)
LOG.warning(libvirt_ver_cmd)
try:
regex = r"%s\s*.*[Ll]ibvirt.*\s*" % LIBVIRTD
regex += r"(\d+)\.(\d+)\.(\d+)"
lines = astring.to_text(func(libvirt_ver_cmd)).splitlines()
LOG.warn("libvirt version value by libvirtd or virtqemud command: %s" % lines)
LOG.warning(
"libvirt version value by libvirtd or virtqemud command: %s" % lines
)
for line in lines:
match = re.search(regex, line.strip())
if match:
Expand All @@ -84,7 +86,7 @@ def get_libvirt_version_compare(major, minor, update, session=None):
)
break
except (ValueError, TypeError, AttributeError):
LOG.warn("Error determining libvirt version")
LOG.warning("Error determining libvirt version")
return False

compare_version = major * 1000000 + minor * 1000 + update
Expand Down Expand Up @@ -122,13 +124,13 @@ def new_fn(*args, **kwargs):
"""
check_libvirt_version()
if not IS_LIBVIRTD_SPLIT_VERSION or not LIBVIRTD_SPLIT_ENABLE_BIT:
LOG.warn(
LOG.warning(
"legacy start libvirtd daemon NORMALLY with function name: %s"
% fn.__name__
)
return fn(*args, **kwargs)
else:
LOG.warn(
LOG.warning(
"legacy start libvirtd daemon IGNORED with function name: %s"
% fn.__name__
)
Expand All @@ -153,13 +155,13 @@ def new_fn(*args, **kwargs):
"""
check_libvirt_version()
if IS_LIBVIRTD_SPLIT_VERSION and LIBVIRTD_SPLIT_ENABLE_BIT:
LOG.warn(
LOG.warning(
"Split start libvirtd daemon NORMALLY with function name: %s"
% fn.__name__
)
return fn(*args, **kwargs)
else:
LOG.warn(
LOG.warning(
"Split start libvirtd daemon IGNORED with function name: %s"
% fn.__name__
)
Expand Down
10 changes: 7 additions & 3 deletions virttest/lvm.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def normalize_data_size(size):
def cmd_output(cmd, res="[\w/]+"):
result = process.run(cmd, ignore_status=True)
if result.exit_status != 0:
LOG.warn(result)
LOG.warning(result)
return None
output = result.stdout_text
for line in output.splitlines():
Expand Down Expand Up @@ -563,7 +563,9 @@ def setup_lv(self):
LOG.info("LogicalVolume(%s) really exists " % lv_name + "skip to create it")
if lv.size != lv_size:
lv.display()
LOG.warn("lv size(%s) mismath," % lv.size + "required size %s;" % lv_size)
LOG.warning(
"lv size(%s) mismath," % lv.size + "required size %s;" % lv_size
)
lv.resize(lv_size)
return lv

Expand Down Expand Up @@ -670,7 +672,9 @@ def setup_pv(self, vg):
self.register(pv)
self.pvs.append(pv)
else:
LOG.warn("PhysicalVolume(%s) really exists" % pv_name + "skip to create it")
LOG.warning(
"PhysicalVolume(%s) really exists" % pv_name + "skip to create it"
)
pv.set_vg(vg)
pvs.append(pv)
return pvs
Expand Down
4 changes: 2 additions & 2 deletions virttest/nfs.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def unexport(self):
unexport_cmd = "exportfs -u %s:%s" % (self.client, self.path)
self.func(unexport_cmd)
else:
LOG.warn(
LOG.warning(
"Target %s %s is not exported yet."
"Can not unexport it." % (self.client, self.path)
)
Expand Down Expand Up @@ -135,7 +135,7 @@ def export(self):
self.unexport()
else:
self.already_exported = True
LOG.warn("Already exported target. Don't need export it again")
LOG.warning("Already exported target. Don't need export it again")
return True
export_cmd = "exportfs"
if self.options:
Expand Down
Loading
Loading