diff --git a/CIME/Tools/code_checker b/CIME/Tools/code_checker index 85de0fcfd17..6f7510337ab 100755 --- a/CIME/Tools/code_checker +++ b/CIME/Tools/code_checker @@ -12,7 +12,7 @@ from CIME.code_checker import check_code, expect import argparse, sys, os # pylint: disable=import-error -from distutils.spawn import find_executable +from shutil import which logger = logging.getLogger(__name__) @@ -62,7 +62,7 @@ OR ############################################################################### def _main_func(description): ############################################################################### - pylint = find_executable("pylint") + pylint = which("pylint") expect(pylint is not None, "pylint not found") num_procs, files = parse_command_line(sys.argv, description) diff --git a/CIME/Tools/xmlconvertors/config_pes_converter.py b/CIME/Tools/xmlconvertors/config_pes_converter.py index d1926ab7e9b..cf57c21fb9b 100755 --- a/CIME/Tools/xmlconvertors/config_pes_converter.py +++ b/CIME/Tools/xmlconvertors/config_pes_converter.py @@ -17,7 +17,7 @@ from CIME import utils from CIME.Tools.standard_script_setup import * from CIME.utils import run_cmd -from distutils.spawn import find_executable +from shutil import which import xml.etree.ElementTree as ET import grid_xml_converter @@ -242,7 +242,7 @@ def writexml(self, addlist, newfilename): root.append(ET.Element("WITH")) if a is not None: root.append(a.to_cime5()) - xmllint = find_executable("xmllint") + xmllint = which("xmllint") if xmllint is not None: run_cmd( "{} --format --output {} -".format(xmllint, newfilename), diff --git a/CIME/Tools/xmlconvertors/grid_xml_converter.py b/CIME/Tools/xmlconvertors/grid_xml_converter.py index 009cbf03add..01de9ddcf9f 100755 --- a/CIME/Tools/xmlconvertors/grid_xml_converter.py +++ b/CIME/Tools/xmlconvertors/grid_xml_converter.py @@ -25,7 +25,7 @@ from CIME import utils from CIME.Tools.standard_script_setup import * from CIME.utils import run_cmd_no_fail -from distutils.spawn import find_executable +from shutil import which import xml.etree.ElementTree as ET import operator @@ -307,6 +307,7 @@ def __init__(self, xmlfilename): self.n = 0 self.nodes = [] self.populate() + self._xmllint = which(xmllint) def next(self): if self.index >= len(self.nodes): @@ -358,10 +359,9 @@ def writexml(self, addlist, newfilename): if a is not None: grids.append(a.to_cime5()) - xmllint = find_executable("xmllint") - if xmllint is not None: + if self._xmllint is not None: run_cmd_no_fail( - "{} --format --output {} -".format(xmllint, newfilename), + "{} --format --output {} -".format(self._xmllint, newfilename), input_str=ET.tostring(root), ) @@ -392,10 +392,10 @@ def writexml(self, addlist, newfilename): domains.append(ET.Element("WITH")) if a is not None: domains.append(a.to_cime5()) - xmllint = find_executable("xmllint") - if xmllint is not None: + + if self._xmllint is not None: run_cmd_no_fail( - "{} --format --output {} -".format(xmllint, newfilename), + "{} --format --output {} -".format(self._xmllint, newfilename), input_str=ET.tostring(root), ) @@ -422,10 +422,9 @@ def writexml(self, addlist, newfilename): gridmaps.append(ET.Element("WITH")) if a is not None: gridmaps.append(a.to_cime5()) - xmllint = find_executable("xmllint") - if xmllint is not None: + if self._xmllint is not None: run_cmd_no_fail( - "{} --format --output {} -".format(xmllint, newfilename), + "{} --format --output {} -".format(self._xmllint, newfilename), input_str=ET.tostring(root), )