diff options
author | Bruce Forstall <brucefo@microsoft.com> | 2018-12-17 17:22:35 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-12-17 17:22:35 -0800 |
commit | 07674dcc5f76a494bbdeccf0a20353c4da338fd7 (patch) | |
tree | d6c1ca1c9f05e6ea1b9bb61ab8350397650a5d5e /tests | |
parent | 534e93d3cfead0aa1c719fa911e2c61694ed6c51 (diff) | |
parent | bba070bf2f7d975e9b0c6b45a601e0a43b6a6b38 (diff) | |
download | coreclr-07674dcc5f76a494bbdeccf0a20353c4da338fd7.tar.gz coreclr-07674dcc5f76a494bbdeccf0a20353c4da338fd7.tar.bz2 coreclr-07674dcc5f76a494bbdeccf0a20353c4da338fd7.zip |
Merge pull request #21532 from BruceForstall/FixPython3Issue
Fix Python 3 issues
Diffstat (limited to 'tests')
-rw-r--r-- | tests/scripts/format.py | 25 | ||||
-rw-r--r-- | tests/scripts/run-corefx-tests.py | 4 | ||||
-rw-r--r-- | tests/scripts/run-pmi-diffs.py | 19 |
3 files changed, 27 insertions, 21 deletions
diff --git a/tests/scripts/format.py b/tests/scripts/format.py index 658e7f93e5..b622cf4625 100644 --- a/tests/scripts/format.py +++ b/tests/scripts/format.py @@ -12,21 +12,26 @@ ################################################################################ -import urllib import argparse import os import sys import tarfile import zipfile import subprocess -import urllib2 import shutil +# Version specific imports + +if sys.version_info.major < 3: + import urllib +else: + import urllib.request + def expandPath(path): return os.path.abspath(os.path.expanduser(path)) def del_rw(action, name, exc): - os.chmod(name, 0651) + os.chmod(name, 0o651) os.remove(name) def main(argv): @@ -42,13 +47,13 @@ def main(argv): args, unknown = parser.parse_known_args(argv) if unknown: - print('Ignorning argument(s): ', ','.join(unknown)) + print('Ignoring argument(s): ', ','.join(unknown)) if args.coreclr is None: print('Specify --coreclr') return -1 if args.os is None: - print('Specifiy --os') + print('Specify --os') return -1 if args.arch is None: print('Specify --arch') @@ -97,10 +102,8 @@ def main(argv): print('Unknown os ', os) return -1 - response = urllib2.urlopen(dotnetcliUrl) - request_url = response.geturl() - testfile = urllib.URLopener() - testfile.retrieve(request_url, dotnetcliFilename) + urlretrieve = urllib.urlretrieve if sys.version_info.major < 3 else urllib.request.urlretrieve + urlretrieve(dotnetcliUrl, dotnetcliFilename) if not os.path.isfile(dotnetcliFilename): print("Did not download .Net CLI!") @@ -145,7 +148,7 @@ def main(argv): bootstrapUrl = "https://raw.githubusercontent.com/dotnet/jitutils/master/" + bootstrapFilename bootstrapPath = os.path.join(coreclr, bootstrapFilename) - testfile.retrieve(bootstrapUrl, bootstrapPath) + urlretrieve(bootstrapUrl, bootstrapPath) if not os.path.isfile(bootstrapPath): print("Did not download bootstrap!") @@ -155,7 +158,7 @@ def main(argv): if platform == 'Linux' or platform == 'OSX': print("Making bootstrap executable") - os.chmod(bootstrapPath, 0751) + os.chmod(bootstrapPath, 0o751) print(bootstrapPath) diff --git a/tests/scripts/run-corefx-tests.py b/tests/scripts/run-corefx-tests.py index 57b21f3d52..76adfe2d54 100644 --- a/tests/scripts/run-corefx-tests.py +++ b/tests/scripts/run-corefx-tests.py @@ -50,7 +50,7 @@ Is_windows = (os.name == 'nt') ########################################################################## def del_rw(action, name, exc): - os.chmod(name, 0651) + os.chmod(name, 0o651) os.remove(name) ########################################################################## @@ -181,7 +181,7 @@ def log(message): message (str): message to be printed """ - print '[%s]: %s' % (sys.argv[0], message) + print('[%s]: %s' % (sys.argv[0], message)) def copy_files(source_dir, target_dir): """ Copy any files in the source_dir to the target_dir. diff --git a/tests/scripts/run-pmi-diffs.py b/tests/scripts/run-pmi-diffs.py index acf15fcc40..2be7b8ebbc 100644 --- a/tests/scripts/run-pmi-diffs.py +++ b/tests/scripts/run-pmi-diffs.py @@ -26,12 +26,17 @@ import os import re import shutil import subprocess -import urllib -import urllib2 import sys import tarfile import zipfile +# Version specific imports + +if sys.version_info.major < 3: + import urllib +else: + import urllib.request + ########################################################################## # Globals ########################################################################## @@ -67,7 +72,7 @@ Clr_os = 'Windows_NT' if Is_windows else Unix_name_map[os.uname()[0]] ########################################################################## def del_rw(action, name, exc): - os.chmod(name, 0651) + os.chmod(name, 0o651) os.remove(name) ########################################################################## @@ -221,7 +226,7 @@ def log(message): message (str): message to be printed """ - print '[%s]: %s' % (sys.argv[0], message) + print('[%s]: %s' % (sys.argv[0], message)) def copy_files(source_dir, target_dir): """ Copy any files in the source_dir to the target_dir. @@ -453,10 +458,8 @@ def do_pmi_diffs(): log('Downloading: %s => %s' % (dotnetcliUrl, dotnetcliFilename)) if not testing: - response = urllib2.urlopen(dotnetcliUrl) - request_url = response.geturl() - testfile = urllib.URLopener() - testfile.retrieve(request_url, dotnetcliFilename) + urlretrieve = urllib.urlretrieve if sys.version_info.major < 3 else urllib.request.urlretrieve + urlretrieve(dotnetcliUrl, dotnetcliFilename) if not os.path.isfile(dotnetcliFilename): log('ERROR: Did not download .Net CLI') |