################################################################################
-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):
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')
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!")
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!")
if platform == 'Linux' or platform == 'OSX':
print("Making bootstrap executable")
- os.chmod(bootstrapPath, 0751)
+ os.chmod(bootstrapPath, 0o751)
print(bootstrapPath)
##########################################################################
def del_rw(action, name, exc):
- os.chmod(name, 0651)
+ os.chmod(name, 0o651)
os.remove(name)
##########################################################################
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.
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
##########################################################################
##########################################################################
def del_rw(action, name, exc):
- os.chmod(name, 0651)
+ os.chmod(name, 0o651)
os.remove(name)
##########################################################################
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.
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')