[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH 05/22] tests/functional: remove duplicated 'which' function i
From: |
Daniel P . Berrangé |
Subject: |
Re: [PATCH 05/22] tests/functional: remove duplicated 'which' function impl |
Date: |
Mon, 2 Dec 2024 11:45:03 +0000 |
User-agent: |
Mutt/2.2.13 (2024-03-09) |
On Sat, Nov 30, 2024 at 09:08:21AM -0600, Richard Henderson wrote:
> 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()?
Agreed, will simplify that.
With regards,
Daniel
--
|: https://berrange.com -o- https://www.flickr.com/photos/dberrange :|
|: https://libvirt.org -o- https://fstop138.berrange.com :|
|: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|