mirror of
https://github.com/ansible-collections/community.docker.git
synced 2025-12-16 03:52:05 +00:00
For Python > 2, always use shutil.which instead of custom Windows helper code. (#438)
This is related to
42789818be
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:
parent
bc6757d3b8
commit
1e4633a606
2
changelogs/fragments/438-docker-py.yml
Normal file
2
changelogs/fragments/438-docker-py.yml
Normal file
@ -0,0 +1,2 @@
|
||||
minor_changes:
|
||||
- "modules and plugins communicating directly with the Docker daemon - simplify use of helper function that was removed in Docker SDK for Python to find executables (https://github.com/ansible-collections/community.docker/pull/438)."
|
||||
@ -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']
|
||||
|
||||
Loading…
Reference in New Issue
Block a user