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é <berra...@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.hender...@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 :|