Skip to content

Commit

Permalink
Merge pull request dotnet/coreclr#21532 from BruceForstall/FixPython3…
Browse files Browse the repository at this point in the history
…Issue

Fix Python 3 issues

Commit migrated from dotnet/coreclr@07674dc
  • Loading branch information
BruceForstall authored Dec 18, 2018
2 parents c25ee35 + 2e66926 commit dffe4d3
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 21 deletions.
25 changes: 14 additions & 11 deletions src/coreclr/tests/scripts/format.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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')
Expand Down Expand Up @@ -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!")
Expand Down Expand Up @@ -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!")
Expand All @@ -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)

Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/tests/scripts/run-corefx-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
##########################################################################

def del_rw(action, name, exc):
os.chmod(name, 0651)
os.chmod(name, 0o651)
os.remove(name)

##########################################################################
Expand Down Expand Up @@ -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.
Expand Down
19 changes: 11 additions & 8 deletions src/coreclr/tests/scripts/run-pmi-diffs.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,17 @@
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
##########################################################################
Expand Down Expand Up @@ -67,7 +72,7 @@
##########################################################################

def del_rw(action, name, exc):
os.chmod(name, 0651)
os.chmod(name, 0o651)
os.remove(name)

##########################################################################
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit dffe4d3

Please sign in to comment.