From d1f16120886647778d809599263a56729d9c8303 Mon Sep 17 00:00:00 2001 From: Florence Blanc-Renaud Date: Mon, 21 Nov 2022 09:03:56 +0100 Subject: [PATCH] pylint: replace deprecated distutils module PEP 632 deprecates the distutils module. Replace - distutils.spawn.find_executable with shutil.which - distutils.log with logging Related: https://pagure.io/freeipa/issue/9278 Signed-off-by: Florence Blanc-Renaud Reviewed-By: Stanislav Levin --- install/tools/ipa-replica-conncheck.in | 4 ++-- ipasetup.py.in | 6 +++--- ipatests/test_cmdline/cmdline.py | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/install/tools/ipa-replica-conncheck.in b/install/tools/ipa-replica-conncheck.in index 948fc5a0c..8eee82483 100644 --- a/install/tools/ipa-replica-conncheck.in +++ b/install/tools/ipa-replica-conncheck.in @@ -45,7 +45,7 @@ import time import threading import traceback from socket import SOCK_STREAM, SOCK_DGRAM -import distutils.spawn +import shutil from ipaplatform.paths import paths import gssapi @@ -62,7 +62,7 @@ class SshExec: def __init__(self, user, addr): self.user = user self.addr = addr - self.cmd = distutils.spawn.find_executable('ssh') + self.cmd = shutil.which('ssh') # Bail if ssh is not installed if self.cmd is None: raise RuntimeError("ssh not installed") diff --git a/ipasetup.py.in b/ipasetup.py.in index e1cb64bb7..25eac3b21 100644 --- a/ipasetup.py.in +++ b/ipasetup.py.in @@ -14,7 +14,7 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see . # -from distutils import log +import logging import os import sys from setuptools.command.build_py import build_py as setuptools_build_py @@ -38,8 +38,8 @@ class build_py(setuptools_build_py): # platform override module 'ipaplatform.override', ) - log.warn("bdist_wheel: Ignore package: %s", - ', '.join(self.skip_modules)) + logging.warning("bdist_wheel: Ignore package: %s", + ', '.join(self.skip_modules)) def build_module(self, module, module_file, package): if isinstance(package, str): diff --git a/ipatests/test_cmdline/cmdline.py b/ipatests/test_cmdline/cmdline.py index 478231eb5..37aaad084 100644 --- a/ipatests/test_cmdline/cmdline.py +++ b/ipatests/test_cmdline/cmdline.py @@ -23,10 +23,10 @@ Base class for all cmdline tests from __future__ import absolute_import -import distutils.spawn import os import pytest +import shutil from ipalib import api from ipalib import errors @@ -60,7 +60,7 @@ class cmdline_test(XMLRPC_test): cls = request.cls original_command = cls.command if not os.path.isabs(cls.command): - cls.command = distutils.spawn.find_executable(cls.command) + cls.command = shutil.which(cls.command) # raise an error if the command is missing even if the remote # server is not available. if not cls.command: