mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 11:55:04 +00:00
For Python > 2, always use shutil.which instead of custom Windows helper code. (#438)
This is related to https://github.com/docker/docker-py/commit/42789818bed5d86b487a030e2e60b02bf0cfa284 in the sense that for Python > 2, we also exclusively use shutil.which now, but we do not remove the helper function since we need it for Python 2 on Windows. Co-authored-by: Daniel Möller <n1ngu@riseup.net> Co-authored-by: Daniel Möller <n1ngu@riseup.net>
This commit is contained in:
@@ -26,11 +26,14 @@ def find_executable(executable, path=None):
|
||||
As distutils.spawn.find_executable, but on Windows, look up
|
||||
every extension declared in PATHEXT instead of just `.exe`
|
||||
"""
|
||||
if not PY2:
|
||||
# shutil.which() already uses PATHEXT on Windows, so on
|
||||
# Python 3 we can simply use shutil.which() in all cases.
|
||||
# (https://github.com/docker/docker-py/commit/42789818bed5d86b487a030e2e60b02bf0cfa284)
|
||||
return which(executable, path=path)
|
||||
|
||||
if sys.platform != 'win32':
|
||||
if PY2:
|
||||
return which(executable, path)
|
||||
else:
|
||||
return which(executable, path=path)
|
||||
return which(executable, path)
|
||||
|
||||
if path is None:
|
||||
path = os.environ['PATH']
|
||||
|
||||
Reference in New Issue
Block a user