From 859949e967fd4a5aedfdfa8f772c2b3d991f3f00 Mon Sep 17 00:00:00 2001 From: Cleber Rosa Date: Sun, 4 Aug 2024 10:08:58 -0400 Subject: [PATCH] avocado/utils/archive.py: make probe function for zstd public There's value in making the zstd probe function public (which was previously not perceived). This function can be used to skip/cancel tests when a suitable zstd is not found. Signed-off-by: Cleber Rosa --- avocado/utils/archive.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/avocado/utils/archive.py b/avocado/utils/archive.py index 65510c000a..1d6b4a3052 100644 --- a/avocado/utils/archive.py +++ b/avocado/utils/archive.py @@ -116,7 +116,13 @@ def is_zstd_file(path): return zstd_file.read(len(ZSTD_MAGIC)) == ZSTD_MAGIC -def _probe_zstd_cmd(): +def probe_zstd_cmd(): + """ + Attempts to find a suitable zstd tool that behaves as expected + + :rtype: str or None + :returns: path to a suitable zstd executable or None if not found + """ zstd_cmd = shutil.which("zstd") if zstd_cmd is not None: proc = subprocess.run( @@ -136,7 +142,7 @@ def zstd_uncompress(path, output_path=None, force=False): """ Extracts a zstd compressed file. """ - zstd_cmd = _probe_zstd_cmd() + zstd_cmd = probe_zstd_cmd() if not zstd_cmd: raise ArchiveException("Unable to find a suitable zstd compression tool") output_path = _decide_on_path(path, ".zst", output_path)