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 <flo@redhat.com>
Reviewed-By: Stanislav Levin <slev@altlinux.org>
This commit is contained in:
Florence Blanc-Renaud 2022-11-21 09:03:56 +01:00
parent 081dd26376
commit 328fb642f6
3 changed files with 7 additions and 7 deletions

View File

@ -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")

View File

@ -14,7 +14,7 @@
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
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):

View File

@ -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: