1
0
Fork 0
mirror of https://github.com/containers/ansible-podman-collections.git synced 2026-02-04 07:11:49 +00:00

Remove distutils as deprecated (#437)

Fix #422
The distutils package is deprecated and slated for removal in Python 3.12

Signed-off-by: Sagi Shnaidman <sshnaidm@redhat.com>
This commit is contained in:
Sergey 2022-06-12 22:54:03 +03:00 committed by GitHub
parent 1003e966ee
commit 2577f5b0f5
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 20 additions and 9 deletions

View file

@ -56,12 +56,12 @@ DOCUMENTATION = '''
- name: ANSIBLE_PODMAN_EXECUTABLE
'''
import distutils.spawn
import os
import shlex
import shutil
import subprocess
from ansible.module_utils.common.process import get_bin_path
from ansible.errors import AnsibleError
from ansible.module_utils._text import to_bytes, to_native
from ansible.plugins.connection import ConnectionBase, ensure_connect
@ -103,7 +103,10 @@ class Connection(ConnectionBase):
:return: return code, stdout, stderr
"""
podman_exec = self.get_option('podman_executable')
podman_cmd = distutils.spawn.find_executable(podman_exec)
try:
podman_cmd = get_bin_path(podman_exec)
except ValueError:
raise AnsibleError("%s command not found in PATH" % podman_exec)
if not podman_cmd:
raise AnsibleError("%s command not found in PATH" % podman_exec)
local_cmd = [podman_cmd]