File Convert-python2-isms-to-python3.patch of Package trilinos.22623
From: Egbert Eich <eich@suse.com>
Date: Mon Jan 17 12:30:30 2022 +0100
Subject: Convert python2-isms to python3
Patch-mainline: Not yet
Git-commit: a7bc2605c6d1ee59d2cf944d2b640757269ecd36
References:
Signed-off-by: Egbert Eich <eich@suse.com>
---
.../tribits/ci_support/is_checkin_tested_commit.py | 10 +-
cmake/tribits/dashboard_driver/tdd_driver.py | 64 +++++-----
cmake/tribits/devtools_install/install-gcc.py | 2 +-
cmake/tribits/python_utils/download-cmake.py | 136 ++++++++++-----------
4 files changed, 106 insertions(+), 106 deletions(-)
diff --git a/cmake/tribits/ci_support/is_checkin_tested_commit.py b/cmake/tribits/ci_support/is_checkin_tested_commit.py
index 6d195e27..988b0ca9 100755
--- a/cmake/tribits/ci_support/is_checkin_tested_commit.py
+++ b/cmake/tribits/ci_support/is_checkin_tested_commit.py
@@ -54,13 +54,13 @@ else:
debugDump = False
if debugDump:
- print "NOTE: TRIBITS_IS_CHECKIN_TESTED_COMMIT=ON set in env, doing debug dump ..."
+ print("NOTE: TRIBITS_IS_CHECKIN_TESTED_COMMIT=ON set in env, doing debug dump ...")
thisFilePath = __file__
-if debugDump: print "\nthisFilePath =", thisFilePath
+if debugDump: print("\nthisFilePath =", thisFilePath)
thisFileRealAbsBasePath = os.path.dirname(os.path.abspath(os.path.realpath(thisFilePath)))
-if debugDump: print "\nthisFileRealAbsBasePath = '"+thisFileRealAbsBasePath+"'"
+if debugDump: print("\nthisFileRealAbsBasePath = '"+thisFileRealAbsBasePath+"'")
sys.path = [thisFileRealAbsBasePath+"/../python_utils"] + sys.path
@@ -137,8 +137,8 @@ else:
isCheckinTestedCommit = False
if isCheckinTestedCommit:
- print "The commit "+gitRef+" is checkin-test.py tested!"
+ print("The commit "+gitRef+" is checkin-test.py tested!")
sys.exit(0)
else:
- print "The commit "+gitRef+" is *NOT* checkin-test.py tested!"
+ print("The commit "+gitRef+" is *NOT* checkin-test.py tested!")
sys.exit(1)
diff --git a/cmake/tribits/dashboard_driver/tdd_driver.py b/cmake/tribits/dashboard_driver/tdd_driver.py
index ff6801d6..cbe8eef5 100755
--- a/cmake/tribits/dashboard_driver/tdd_driver.py
+++ b/cmake/tribits/dashboard_driver/tdd_driver.py
@@ -62,7 +62,7 @@ else:
#
this_path = os.path.abspath(os.path.realpath(__file__))
tribitsDDDir = os.path.dirname(this_path)
-print "tribitsDDDir = '"+tribitsDDDir+"'"
+print("tribitsDDDir = '"+tribitsDDDir+"'")
# Load the general script support python code
pythonUtilsDir = os.path.join(tribitsDDDir, "../python_utils")
@@ -75,14 +75,14 @@ def install_ctest(tddDashboardRootDir, tribitsDir):
# dashboardToolsDir is the directory to which any needed tools will be downloaded.
#
dashboardToolsDir = tddDashboardRootDir + "/tools"
- print "dashboardToolsDir = '"+dashboardToolsDir+"'"
+ print("dashboardToolsDir = '"+dashboardToolsDir+"'")
# Make sure tools directory exists:
#
if not os.path.exists(dashboardToolsDir):
os.makedirs(dashboardToolsDir)
if not os.path.exists(dashboardToolsDir):
- print "error: could not create directory \"" + dashboardToolsDir + "\""
+ print("error: could not create directory \"" + dashboardToolsDir + "\"")
sys.exit(1)
# Download and install CMake/CTest to use for the outer driver
@@ -105,20 +105,20 @@ def install_ctest(tddDashboardRootDir, tribitsDir):
# (Requires network connectivity; avoid when possible.)
#
- print "\n***"
- print "*** Downloading and installing CMake to \"" + cmakeTddDownloadBaseDir + "\"..."
- print "***\n"
+ print("\n***")
+ print("*** Downloading and installing CMake to \"" + cmakeTddDownloadBaseDir + "\"...")
+ print("***\n")
installMasterCMake = False
if not os.path.exists(cmakeTddDownloadBaseDir):
- print "Forcing install of master CMake because '"+cmakeTddDownloadBaseDir+"' does not exist!"
+ print("Forcing install of master CMake because '"+cmakeTddDownloadBaseDir+"' does not exist!")
installMasterCMake = True
elif TDD_FORCE_CMAKE_INSTALL == "1":
- print "Forcing install of master CMake because" \
- + " TDD_FORCE_CMAKE_INSTALL == 1!"
+ print("Forcing install of master CMake because" \
+ + " TDD_FORCE_CMAKE_INSTALL == 1!")
installMasterCMake = True
else:
- print "Leaving current CMake in place ..." \
+ print("Leaving current CMake in place ...") \
if installMasterCMake:
@@ -136,9 +136,9 @@ def install_ctest(tddDashboardRootDir, tribitsDir):
timeCmnd = True,
workingDir = dashboardToolsDir \
)
- except Exception, e:
- print "WARNING! The following command failed!\n"+cmnd
- print "However, not updating CMake is not the end of the world!"
+ except Exception as e:
+ print("WARNING! The following command failed!\n"+cmnd)
+ print("However, not updating CMake is not the end of the world!")
# Find ctest under cmakeTddDownloadBaseDir:
@@ -149,7 +149,7 @@ def install_ctest(tddDashboardRootDir, tribitsDir):
if 0 == len(ctestGlobStr):
ctestGlobStr = glob.glob(cmakeTddDownloadBaseDir + "/*/*/bin/ctest*")
if 1 != len(ctestGlobStr):
- print "error: could not find ctest executable after download..."
+ print("error: could not find ctest executable after download...")
sys.exit(2)
ctestExe = ctestGlobStr[0]
@@ -169,7 +169,7 @@ def invoke_ctest(ctestExe, script, tddDashboardRootDir, environment = {}):
# until ctest supports something like CMake's -D argument, this is
# how it has to be done.
if environment:
- print "environment =", environment
+ print("environment =", environment)
cmd = ctestExe
if verbose:
@@ -182,10 +182,10 @@ def invoke_ctest(ctestExe, script, tddDashboardRootDir, environment = {}):
extraEnv = environment
)
- print "ctestRtn: '" + str(ctestRtn) + "'"
+ print("ctestRtn: '" + str(ctestRtn) + "'")
if ctestRtn != 0:
- print "error: ctest returned non-zero error value, script will exit with " + str(ctestRtn)
+ print("error: ctest returned non-zero error value, script will exit with " + str(ctestRtn))
# Propagate ctest return value
#
@@ -201,18 +201,18 @@ def run_driver(ctestSourceDirectory, projectRepoBaseDir):
"""
origDir = os.getcwd()
try:
- print "\n******************************************************************"
- print "*** Tribits Driver Dashboard tdd_driver.py ***"
- print "******************************************************************\n"
+ print("\n******************************************************************")
+ print("*** Tribits Driver Dashboard tdd_driver.py ***")
+ print("******************************************************************\n")
- print "\nPWD=\""+os.getcwd()+"\"...\n"
- print "projectRepoBaseDir = '" + projectRepoBaseDir + "'"
- print "tribitsDDDir = '" + tribitsDDDir + "'"
+ print("\nPWD=\""+os.getcwd()+"\"...\n")
+ print("projectRepoBaseDir = '" + projectRepoBaseDir + "'")
+ print("tribitsDDDir = '" + tribitsDDDir + "'")
# tribitsDir is the root directory of the TriBITS system:
#
tribitsDir = os.path.abspath(os.path.join(tribitsDDDir, ".."))
- print "tribitsDir = '"+tribitsDir+"'"
+ print("tribitsDir = '"+tribitsDir+"'")
# dashboardBaseDir is the parent directory of our containing source tree,
# which we compute relative to tribitsDir:
@@ -220,7 +220,7 @@ def run_driver(ctestSourceDirectory, projectRepoBaseDir):
tddDashboardRootDir = os.path.dirname(projectRepoBaseDir)
if "TDD_DASHBOARD_ROOT" in os.environ:
tddDashboardRootDir = os.environ["TDD_DASHBOARD_ROOT"]
- print "tddDashboardRootDir = '"+tddDashboardRootDir+"'"
+ print("tddDashboardRootDir = '"+tddDashboardRootDir+"'")
os.chdir(tddDashboardRootDir)
if verbose: "\nNew PWD = '"+os.getcwd()+"'"
@@ -230,16 +230,16 @@ def run_driver(ctestSourceDirectory, projectRepoBaseDir):
and os.environ["TRIBITS_TDD_USE_SYSTEM_CTEST"] == "1" \
:
tddUseSystemCTest = True
- print "tddUseSystemCTest =", tddUseSystemCTest
+ print("tddUseSystemCTest =", tddUseSystemCTest)
if tddUseSystemCTest:
ctestExe = getCmndOutput("which ctest", True, False)
else:
ctestExe = install_ctest(tddDashboardRootDir, tribitsDir)
- print "\nctestExe = '" + ctestExe + "'"
+ print("\nctestExe = '" + ctestExe + "'")
if not os.path.exists(ctestExe):
- print "error: ctest does not exist after installation..."
+ print("error: ctest does not exist after installation...")
sys.exit(3)
# Escape any spaces in the path of the ctest exe. This has to be done
@@ -252,14 +252,14 @@ def run_driver(ctestSourceDirectory, projectRepoBaseDir):
#
ctestVersion = getCmndOutput(ctestExe+" --version", True, False)
- print "ctestVersion = '"+ctestVersion+"'"
+ print("ctestVersion = '"+ctestVersion+"'")
# Run one driver dashboard for this source tree:
#
- print "\n***"
- print "*** Running the main dashboards as CTest tests .."
- print "***\n"
+ print("\n***")
+ print("*** Running the main dashboards as CTest tests ..")
+ print("***\n")
sys.exit(
invoke_ctest(ctestExe,
os.path.join(tribitsDDDir, "TribitsDriverDashboard.cmake"),
diff --git a/cmake/tribits/devtools_install/install-gcc.py b/cmake/tribits/devtools_install/install-gcc.py
index 68d3c01f..c604d68b 100755
--- a/cmake/tribits/devtools_install/install-gcc.py
+++ b/cmake/tribits/devtools_install/install-gcc.py
@@ -137,7 +137,7 @@ command --download-cmnd=<download-cmnd> is:
echoRunSysCmnd(self.inOptions.downloadCmnd)
def doUntar(self):
- print "Nothing to untar!"
+ print("Nothing to untar!")
def doConfigure(self):
createDir(self.gccBuildBaseDir)
diff --git a/cmake/tribits/python_utils/download-cmake.py b/cmake/tribits/python_utils/download-cmake.py
index f4652f93..a8cd4e2b 100755
--- a/cmake/tribits/python_utils/download-cmake.py
+++ b/cmake/tribits/python_utils/download-cmake.py
@@ -233,7 +233,7 @@ def DetectLatestCMakeBuilds(basedir, baseurl, vdir):
if not os.path.exists(basedir):
raise
- print "Querying " + url + "..."
+ print("Querying " + url + "...")
proxyDict = {}
if not options.httpProxy == "":
@@ -255,7 +255,7 @@ def DetectLatestCMakeBuilds(basedir, baseurl, vdir):
outfile.write(url_file.read())
outfile.close()
- print "Detecting ..."
+ print("Detecting ...")
lines = []
regex = re.compile(
@@ -280,8 +280,8 @@ def DetectLatestCMakeBuilds(basedir, baseurl, vdir):
version = versionRegEx.match(line).group(1)
if version == "" or version == line:
- print "error: line does not match version extraction regex"
- print " line: [" + line + "]"
+ print("error: line does not match version extraction regex")
+ print(" line: [" + line + "]")
sys.exit(1)
date = dateRegEx.match(version).group(1)
@@ -310,18 +310,18 @@ def DetectLatestCMakeBuilds(basedir, baseurl, vdir):
whref = href
w = 1
else:
- print "error: unexpected non-matching line"
+ print("error: unexpected non-matching line")
sys.exit(1)
count = count + 1
if l == 1 and m == 1 and w == 1:
found = 1
- print "Detected latest available CMake " + vdir + " build: " + version
+ print("Detected latest available CMake " + vdir + " build: " + version)
break
if not found:
- print "error: could not find a " + vdir + " version with all 3 platforms available"
+ print("error: could not find a " + vdir + " version with all 3 platforms available")
return ()
return (('linux2', lhref, version), ('darwin', mhref, version), ('win32', whref, version))
@@ -332,7 +332,7 @@ def Download(basedir, url):
href = cmps[1]
filename = ''.join([basedir, "/", href])
- print 'Downloading ' + href + '...'
+ print('Downloading ' + href + '...')
try:
createDir(basedir)
@@ -366,15 +366,15 @@ def Extract(basedir, url):
href = cmps[1]
filename = ''.join([basedir, "/", href])
- print 'Extracting ' + href + '...'
+ print('Extracting ' + href + '...')
if href[-4:] == ".zip":
if sys.version < '2.6':
if sys.platform == 'win32':
- print "error: cannot extract zip files on win32 with older python < 2.6"
+ print("error: cannot extract zip files on win32 with older python < 2.6")
else:
- print "warning: avoiding zipfile.extractall on older python < 2.6"
- print " skipping this extraction..."
+ print("warning: avoiding zipfile.extractall on older python < 2.6")
+ print(" skipping this extraction...")
else:
z = zipfile.ZipFile(filename)
z.extractall(basedir)
@@ -382,10 +382,10 @@ def Extract(basedir, url):
else:
if sys.version < '2.6':
if sys.platform == 'win32':
- print "error: cannot extract tar files on win32 with older python < 2.6"
+ print("error: cannot extract tar files on win32 with older python < 2.6")
else:
- print "warning: avoiding tarfile.extractall on older python < 2.6"
- print " trying command line tar instead..."
+ print("warning: avoiding tarfile.extractall on older python < 2.6")
+ print(" trying command line tar instead...")
origDir = os.getcwd()
echoChDir(basedir)
echoRunSysCmnd("tar -xzf " + href)
@@ -407,13 +407,13 @@ def Install(basedir, url):
dirname = ''.join([basedir, "/", href])
- print 'Installing ' + href + '...'
- print ' src dir: [' + dirname + ']'
- print ' dst dir: [' + options.installDir + ']'
+ print('Installing ' + href + '...')
+ print(' src dir: [' + dirname + ']')
+ print(' dst dir: [' + options.installDir + ']')
if sys.platform == 'win32':
if os.path.exists(options.installDir):
- print "error: --install-dir '" + options.installDir + "' already exists - remove it or rename it and try again -- or manually copy the source directory '" + dirname + "' to the final installation location..."
+ print("error: --install-dir '" + options.installDir + "' already exists - remove it or rename it and try again -- or manually copy the source directory '" + dirname + "' to the final installation location...")
sys.exit(1)
shutil.copytree(dirname, options.installDir)
@@ -451,7 +451,7 @@ def Install(basedir, url):
pre = "bin"
if pre == '':
- print "error: could not determine CMake install tree structure - cannot create symlinks into unexpected directory structure"
+ print("error: could not determine CMake install tree structure - cannot create symlinks into unexpected directory structure")
sys.exit(1)
if not os.path.exists(options.symlinksDir):
@@ -459,7 +459,7 @@ def Install(basedir, url):
for exe in ('ccmake', 'cmake', 'cmake-gui', 'cmakexbuild', 'cpack', 'ctest'):
if os.path.exists(options.installDir + "/" + pre + "/" + exe):
- print "Creating " + exe + " symlink..."
+ print("Creating " + exe + " symlink...")
echoRunSysCmnd("ln -fs \"" + options.installDir + "/" + pre + "/" + exe + "\" \"" + options.symlinksDir + "/" + exe + "\"")
@@ -472,8 +472,8 @@ def DownloadForPlatform(p):
def PrintDetectedDownloads(detected):
- print ""
- print "Detected CMake downloads available:"
+ print ("")
+ print ("Detected CMake downloads available:")
sorted_keys = detected.keys()
sorted_keys.sort()
@@ -486,12 +486,12 @@ def PrintDetectedDownloads(detected):
detected_urls.append(cmake_baseurl + "/" + k + "/" + v[1])
for u in detected_urls:
- print "[" + u + "]"
+ print("[" + u + "]")
def PrintVerifiedDownloads():
- print ""
- print "Verified CMake downloads:"
+ print("")
+ print("Verified CMake downloads:")
verified_urls = list()
@@ -512,7 +512,7 @@ def PrintVerifiedDownloads():
verified_urls.append(v[1])
for u in verified_urls:
- print "[" + u + "]"
+ print("[" + u + "]")
# Read file "CMakeVersions.py" from the same directory that this script lives
@@ -554,42 +554,42 @@ def ReadWriteCMakeVersionsFile(download_dir, detected):
else:
fw.write(line)
- print ""
- print "Wrote new '" + wfname + "' -- copy to '" + rfname + "' (if different) to use newly detected installers."
+ print("")
+ print("Wrote new '" + wfname + "' -- copy to '" + rfname + "' (if different) to use newly detected installers.")
#
# The main script
#
-print ""
-print "**************************************************************************"
-print "Script: download-cmake.py \\"
+print("")
+print("**************************************************************************")
+print("Script: download-cmake.py \\")
if options.allPlatforms:
- print " --all-platforms \\"
-print " --http-proxy="+options.httpProxy+" \\"
-print " --https-proxy="+options.httpsProxy+" \\"
-print " --install-dir="+options.installDir+" \\"
-print " --installer-type="+options.installerType+" \\"
+ print(" --all-platforms \\")
+print(" --http-proxy="+options.httpProxy+" \\")
+print(" --https-proxy="+options.httpsProxy+" \\")
+print(" --install-dir="+options.installDir+" \\")
+print(" --installer-type="+options.installerType+" \\")
if options.skipDetect:
- print " --skip-detect \\"
+ print(" --skip-detect \\")
if options.skipDownload:
- print " --skip-download \\"
+ print(" --skip-download \\")
if options.skipExtract:
- print " --skip-extract \\"
+ print(" --skip-extract \\")
if options.skipInstall:
- print " --skip-install \\"
+ print(" --skip-install \\")
if options.symlinks:
- print " --symlinks \\"
+ print(" --symlinks \\")
if options.symlinksDir != '':
- print " --symlinks-dir="+options.symlinksDir+" \\"
+ print(" --symlinks-dir="+options.symlinksDir+" \\")
if not options.httpProxy and not default_http_proxy:
- print "\nWARNING: Could not detect default http proxy for '"+hostname+"'!"
+ print("\nWARNING: Could not detect default http proxy for '"+hostname+"'!")
if not options.httpsProxy and not default_https_proxy:
- print "\nWARNING: Could not detect default https proxy for '"+hostname+"'!"
+ print("\nWARNING: Could not detect default https proxy for '"+hostname+"'!")
download_dir = "download_area"
@@ -603,17 +603,17 @@ if options.installerType == 'rc':
if options.installerType == 'dev':
binaries = cmake_dev_binaries
if binaries == None:
- print "error: unknown --installer-type: [" + options.installerType + "]"
+ print("error: unknown --installer-type: [" + options.installerType + "]")
sys.exit(1)
-print ""
-print ""
-print "A) Detect the latest available builds of CMake ..."
-print " (requires network access to www.cmake.org)"
-print ""
+print("")
+print("")
+print("A) Detect the latest available builds of CMake ...")
+print(" (requires network access to www.cmake.org)")
+print("")
if options.skipDetect:
- print "Skipping on request ..."
+ print("Skipping on request ...")
else:
detected = dict()
@@ -627,40 +627,40 @@ else:
ReadWriteCMakeVersionsFile(download_dir, detected)
-print ""
-print ""
-print "B) Download CMake for --installer-type '" + options.installerType + "' ..."
-print " (requires network access to www.cmake.org)"
-print ""
+print("")
+print("")
+print("B) Download CMake for --installer-type '" + options.installerType + "' ...")
+print(" (requires network access to www.cmake.org)")
+print("")
if options.skipDownload:
- print "Skipping on request ..."
+ print("Skipping on request ...")
else:
for binary in binaries:
if DownloadForPlatform(binary[0]):
Download(download_dir, binary[1])
-print ""
-print ""
-print "C) Extract the CMake install tree ..."
-print ""
+print("")
+print("")
+print("C) Extract the CMake install tree ...")
+print("")
if options.skipExtract:
- print "Skipping on request ..."
+ print("Skipping on request ...")
else:
for binary in binaries:
if DownloadForPlatform(binary[0]):
Extract(download_dir, binary[1])
-print ""
-print ""
-print "D) Install (copy the CMake install tree) ..."
-print ""
+print("")
+print("")
+print("D) Install (copy the CMake install tree) ...")
+print("")
if options.skipInstall:
- print "Skipping on request ..."
+ print("Skipping on request ...")
else:
for binary in binaries:
if binary[0] == sys.platform: