qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 05/22] tests/functional: remove duplicated 'which' function i


From: Richard Henderson
Subject: Re: [PATCH 05/22] tests/functional: remove duplicated 'which' function impl
Date: Sat, 30 Nov 2024 09:08:21 -0600
User-agent: Mozilla Thunderbird

On 11/29/24 11:31, Daniel P. Berrangé wrote:
Put the 'which' function into shared code.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
---
  tests/functional/qemu_test/__init__.py |  2 +-
  tests/functional/qemu_test/cmd.py      | 10 ++++++++++
  tests/functional/test_acpi_bits.py     | 13 +------------
  tests/functional/test_ppc64_hv.py      | 13 +------------
  4 files changed, 13 insertions(+), 25 deletions(-)

As code movement,
Reviewed-by: Richard Henderson <richard.henderson@linaro.org>

+def which(tool):
+    """ looks up the full path for @tool, returns None if not found
+        or if @tool does not have executable permissions.
+    """
+    paths=os.getenv('PATH')
+    for p in paths.split(os.path.pathsep):
+        p = os.path.join(p, tool)
+        if os.path.exists(p) and os.access(p, os.X_OK):

But surely exists() is redundant with access()?


r~



reply via email to

[Prev in Thread] Current Thread [Next in Thread]