Skip to content

Commit 523362f

Browse files
author
linesight
committed
py3 update for automate-git.py and automate.py
1 parent d9587bc commit 523362f

2 files changed

Lines changed: 26 additions & 31 deletions

File tree

‎tools/automate-git.py‎

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@
138138
import sys
139139
import tempfile
140140
import urllib
141-
import urllib2
141+
from urllib.request import urlopen, FancyURLopener
142142
import zipfile
143143

144144
##
@@ -258,7 +258,7 @@ def exec_cmd(cmd, path):
258258
stderr=subprocess.PIPE,
259259
shell=(sys.platform == 'win32'))
260260
out, err = process.communicate()
261-
except IOError, (errno, strerror):
261+
except IOError:
262262
raise
263263
except:
264264
raise
@@ -300,7 +300,7 @@ def download_and_extract(src, target):
300300

301301
if src[:4] == 'http':
302302
# Attempt to download a URL.
303-
opener = urllib.FancyURLopener({})
303+
opener = FancyURLopener({})
304304
response = opener.open(src)
305305

306306
temporary = True
@@ -462,7 +462,7 @@ def onerror(func, path, exc_info):
462462
def read_json_url(url):
463463
""" Read a JSON URL. """
464464
msg('Downloading %s' % url)
465-
response = urllib2.urlopen(url)
465+
response = urlopen(url)
466466
return json.loads(response.read())
467467

468468

@@ -1051,7 +1051,7 @@ def check_pattern_matches(output_file=None):
10511051
(options, args) = parser.parse_args()
10521052

10531053
if options.downloaddir is None:
1054-
print "The --download-dir option is required."
1054+
print("The --download-dir option is required.")
10551055
parser.print_help(sys.stderr)
10561056
sys.exit()
10571057

@@ -1074,7 +1074,7 @@ def check_pattern_matches(output_file=None):
10741074
if (options.nocefupdate and options.forceupdate):
10751075
pass
10761076
else:
1077-
print "Invalid combination of options."
1077+
print("Invalid combination of options.")
10781078
parser.print_help(sys.stderr)
10791079
sys.exit()
10801080
# --
@@ -1083,25 +1083,25 @@ def check_pattern_matches(output_file=None):
10831083
(options.minimaldistrib or options.minimaldistribonly or \
10841084
options.clientdistrib or options.clientdistribonly)) or \
10851085
(options.minimaldistribonly + options.clientdistribonly + options.sandboxdistribonly > 1):
1086-
print 'Invalid combination of options.'
1086+
print('Invalid combination of options.')
10871087
parser.print_help(sys.stderr)
10881088
sys.exit()
10891089

10901090
if options.x64build and options.armbuild:
1091-
print 'Invalid combination of options.'
1091+
print('Invalid combination of options.')
10921092
parser.print_help(sys.stderr)
10931093
sys.exit()
10941094

10951095
if (options.buildtests or options.runtests) and len(options.testtarget) == 0:
1096-
print "A test target must be specified via --test-target."
1096+
print("A test target must be specified via --test-target.")
10971097
parser.print_help(sys.stderr)
10981098
sys.exit()
10991099

11001100
# Operating system.
11011101
if options.dryrun and options.dryrunplatform is not None:
11021102
platform = options.dryrunplatform
11031103
if not platform in ['windows', 'macosx', 'linux']:
1104-
print 'Invalid dry-run-platform value: %s' % (platform)
1104+
print('Invalid dry-run-platform value: %s' % (platform))
11051105
sys.exit()
11061106
elif sys.platform == 'win32':
11071107
platform = 'windows'
@@ -1110,7 +1110,7 @@ def check_pattern_matches(output_file=None):
11101110
elif sys.platform.startswith('linux'):
11111111
platform = 'linux'
11121112
else:
1113-
print 'Unknown operating system platform'
1113+
print('Unknown operating system platform')
11141114
sys.exit()
11151115

11161116
# Script extension.
@@ -1125,25 +1125,25 @@ def check_pattern_matches(output_file=None):
11251125
else:
11261126
client_app = 'cefclient'
11271127
if options.buildtarget.find(client_app) == -1:
1128-
print 'A client distribution cannot be generated if --build-target '+\
1129-
'excludes %s.' % client_app
1128+
print('A client distribution cannot be generated if --build-target '+\
1129+
'excludes %s.' % client_app)
11301130
parser.print_help(sys.stderr)
11311131
sys.exit()
11321132

11331133
if platform != 'windows' and (options.sandboxdistrib or
11341134
options.sandboxdistribonly):
1135-
print 'The sandbox distribution is only supported on Windows.'
1135+
print('The sandbox distribution is only supported on Windows.')
11361136
sys.exit()
11371137

11381138
# CEF branch.
11391139
if options.branch != 'trunk' and not options.branch.isdigit():
1140-
print 'Invalid branch value: %s' % (options.branch)
1140+
print('Invalid branch value: %s' % (options.branch))
11411141
sys.exit()
11421142

11431143
cef_branch = options.branch
11441144

11451145
if cef_branch != 'trunk' and int(cef_branch) <= 1453:
1146-
print 'The requested branch is too old to build using this tool.'
1146+
print('The requested branch is too old to build using this tool.')
11471147
sys.exit()
11481148

11491149
# True if the requested branch is 2272 or newer.
@@ -1166,28 +1166,28 @@ def check_pattern_matches(output_file=None):
11661166
use_gn = bool(int(os.environ.get('CEF_USE_GN', '0')))
11671167
if use_gn:
11681168
if branch_is_2743_or_older:
1169-
print 'GN is not supported with branch 2743 and older (set CEF_USE_GN=0).'
1169+
print('GN is not supported with branch 2743 and older (set CEF_USE_GN=0).')
11701170
sys.exit()
11711171

11721172
if options.armbuild:
11731173
if platform != 'linux':
1174-
print 'The ARM build option is only supported on Linux.'
1174+
print('The ARM build option is only supported on Linux.')
11751175
sys.exit()
11761176

11771177
if not branch_is_newer_than_2785:
1178-
print 'The ARM build option is not supported with branch 2785 and older.'
1178+
print('The ARM build option is not supported with branch 2785 and older.')
11791179
sys.exit()
11801180
else:
11811181
if options.armbuild:
1182-
print 'The ARM build option is not supported by GYP.'
1182+
print('The ARM build option is not supported by GYP.')
11831183
sys.exit()
11841184

11851185
if options.x64build and platform != 'windows' and platform != 'macosx':
1186-
print 'The x64 build option is only used on Windows and Mac OS X.'
1186+
print('The x64 build option is only used on Windows and Mac OS X.')
11871187
sys.exit()
11881188

11891189
if platform == 'windows' and not 'GYP_MSVS_VERSION' in os.environ.keys():
1190-
print 'You must set the GYP_MSVS_VERSION environment variable on Windows.'
1190+
print('You must set the GYP_MSVS_VERSION environment variable on Windows.')
11911191
sys.exit()
11921192

11931193
# True if GYP_DEFINES=target_arch=x64 must be set.
@@ -1203,8 +1203,8 @@ def check_pattern_matches(output_file=None):
12031203
deps_file = '.DEPS.git'
12041204

12051205
if platform == 'macosx' and not options.x64build and branch_is_2272_or_newer:
1206-
print '32-bit Mac OS X builds are no longer supported with 2272 branch and '+\
1207-
'newer. Add --x64-build flag to generate a 64-bit build.'
1206+
print('32-bit Mac OS X builds are no longer supported with 2272 branch and '+\
1207+
'newer. Add --x64-build flag to generate a 64-bit build.')
12081208
sys.exit()
12091209

12101210
# Options that force the sources to change.
@@ -1214,7 +1214,7 @@ def check_pattern_matches(output_file=None):
12141214
discard_local_changes = force_change or options.forcecefupdate
12151215

12161216
if options.resave and (options.forcepatchupdate or discard_local_changes):
1217-
print '--resave cannot be combined with options that modify or discard patches.'
1217+
print('--resave cannot be combined with options that modify or discard patches.')
12181218
parser.print_help(sys.stderr)
12191219
sys.exit()
12201220

‎tools/automate.py‎

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
import shutil
9494
import multiprocessing
9595
from collections import OrderedDict
96-
from setuptools.msvc import msvc9_query_vcvarsall
9796

9897
# Constants
9998
CEF_UPSTREAM_GIT_URL = "https://bitbucket.org/chromiumembedded/cef.git"
@@ -147,11 +146,6 @@ def main():
147146
setup_options(docopt.docopt(__doc__))
148147

149148
if Options.build_cef:
150-
if not sys.version_info[:2] == (2, 7):
151-
print("ERROR: To build CEF from sources you need Python 2.7.")
152-
print(" Upstream automate-git.py works only with that")
153-
print(" version of python.")
154-
sys.exit(1)
155149
build_cef()
156150
elif Options.prebuilt_cef:
157151
prebuilt_cef()
@@ -525,6 +519,7 @@ def build_wrapper_library_windows(runtime_library, msvs, vcvars):
525519
if msvs == "2010":
526520
# When Using WinSDK 7.1 vcvarsall.bat doesn't work. Use
527521
# setuptools.msvc.msvc9_query_vcvarsall to query env vars.
522+
from setuptools.msvc import msvc9_query_vcvarsall
528523
env.update(msvc9_query_vcvarsall(10.0, arch=VS_PLATFORM_ARG))
529524
# On Python 2.7 env values returned by both distutils
530525
# and setuptools are unicode, but Python expects env

0 commit comments

Comments
 (0)