diff --git a/tests/clitest.py b/tests/clitest.py index 2c425cc03..07a9ff551 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -4,7 +4,6 @@ # See the COPYING file in the top-level directory. import atexit -from distutils.spawn import find_executable import io import logging import os @@ -29,7 +28,7 @@ os.environ["DISPLAY"] = ":3.4" TMP_IMAGE_DIR = "/tmp/__virtinst_cli_" XMLDIR = "tests/cli-test-xml" OLD_OSINFO = utils.has_old_osinfo() -HAS_ISOINFO = find_executable("isoinfo") +HAS_ISOINFO = shutil.which("isoinfo") # Images that will be created by virt-install/virt-clone, and removed before # each run diff --git a/virtcli/cliconfig.py b/virtcli/cliconfig.py index b270a7857..5b3d28a71 100644 --- a/virtcli/cliconfig.py +++ b/virtcli/cliconfig.py @@ -50,16 +50,13 @@ def _setup_gsettings_path(schemadir): schema and use it directly """ import subprocess - from distutils.spawn import find_executable + import shutil - exe = find_executable("glib-compile-schemas") + exe = shutil.which("glib-compile-schemas") if not exe: raise RuntimeError("You must install glib-compile-schemas to run " "virt-manager from git.") - - ret = subprocess.call([exe, "--strict", schemadir]) - if ret != 0: - raise RuntimeError("Failed to compile local gsettings schemas") + subprocess.check_call([exe, "--strict", schemadir]) __version__ = "2.1.0" diff --git a/virtconv/formats.py b/virtconv/formats.py index ed019e17d..ff4b97f52 100644 --- a/virtconv/formats.py +++ b/virtconv/formats.py @@ -7,7 +7,6 @@ # See the COPYING file in the top-level directory. # -from distutils.spawn import find_executable import logging import os import re @@ -143,7 +142,7 @@ def _find_input(input_file, parser, print_cb): binname = "xz" pkg = "xz" cmd = ["tar", "Jxf", input_file, "-C", tempdir] - if not find_executable(binname): + if not shutil.which(binname): raise RuntimeError(_("%s appears to be an archive, " "but '%s' is not installed. " "Please either install '%s', or extract the archive " @@ -252,7 +251,7 @@ class VirtConverter(object): executable = "/usr/bin/qemu-img" else: for binname in binnames: - executable = find_executable(binname) + executable = shutil.which(binname) if executable: break @@ -262,7 +261,7 @@ class VirtConverter(object): base = os.path.basename(absin) ext = os.path.splitext(base)[1] if (ext and ext[1:] == "gz"): - if not find_executable("gzip"): + if not shutil.which("gzip"): raise RuntimeError("'gzip' is needed to decompress the file, " "but not found.") decompress_cmd = ["gzip", "-d", absin]