mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-28 09:57:50 +01:00
cefbuilds: Add Python 3 support (see issue #2856)
This commit is contained in:
parent
8d0ae1f894
commit
11ee7e984c
@ -2,6 +2,8 @@
|
||||
# reserved. Use of this source code is governed by a BSD-style license that
|
||||
# can be found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
from cef_json_builder import cef_json_builder
|
||||
import datetime
|
||||
import math
|
||||
@ -72,7 +74,7 @@ class cef_html_builder:
|
||||
|
||||
@staticmethod
|
||||
def _replace_all(str, dict):
|
||||
for key, value in dict.iteritems():
|
||||
for (key, value) in dict.items():
|
||||
str = cef_html_builder._replace(str, key, value)
|
||||
return str
|
||||
|
||||
@ -295,8 +297,8 @@ class cef_html_builder:
|
||||
if __name__ == '__main__':
|
||||
# Verify command-line arguments.
|
||||
if len(sys.argv) < 4:
|
||||
sys.stderr.write(
|
||||
'Usage: %s <json_file_in> <html_file_in> <html_file_out>' % sys.argv[0])
|
||||
sys.stderr.write('Usage: %s <json_file_in> <html_file_in> <html_file_out>\n'
|
||||
% sys.argv[0])
|
||||
sys.exit()
|
||||
|
||||
json_file_in = sys.argv[1]
|
||||
@ -304,18 +306,18 @@ if __name__ == '__main__':
|
||||
html_file_out = sys.argv[3]
|
||||
|
||||
# Create the HTML builder and load the HTML template.
|
||||
print '--> Reading %s' % html_file_in
|
||||
print('--> Reading %s' % html_file_in)
|
||||
html_builder = cef_html_builder()
|
||||
with open(html_file_in, 'r') as f:
|
||||
html_builder.load(f.read())
|
||||
|
||||
# Create the JSON builder and load the JSON file.
|
||||
print '--> Reading %s' % json_file_in
|
||||
print('--> Reading %s' % json_file_in)
|
||||
json_builder = cef_json_builder(silent=False)
|
||||
with open(json_file_in, 'r') as f:
|
||||
json_builder.load(f.read())
|
||||
|
||||
# Write the HTML output file.
|
||||
print '--> Writing %s' % html_file_out
|
||||
print('--> Writing %s' % html_file_out)
|
||||
with open(html_file_out, 'w') as f:
|
||||
f.write(html_builder.generate(json_builder))
|
||||
|
@ -2,11 +2,19 @@
|
||||
# reserved. Use of this source code is governed by a BSD-style license that
|
||||
# can be found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
import datetime
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import urllib
|
||||
|
||||
try:
|
||||
# Python 2
|
||||
from urllib2 import urlopen
|
||||
except Exception as e:
|
||||
# Python 3
|
||||
from urllib.request import urlopen
|
||||
|
||||
# Class used to build the cefbuilds JSON file. See cef_json_builder_example.py
|
||||
# for example usage. See cef_json_builder_test.py for unit tests.
|
||||
@ -152,7 +160,7 @@ class cef_json_builder:
|
||||
if self._fatalerrors:
|
||||
raise Exception(msg)
|
||||
if not self._silent:
|
||||
print msg
|
||||
print(msg)
|
||||
|
||||
def get_query_count(self):
|
||||
""" Returns the number of queries sent while building. """
|
||||
@ -166,11 +174,11 @@ class cef_json_builder:
|
||||
query_url = 'https://bitbucket.org/chromiumembedded/cef/raw/%s/CHROMIUM_BUILD_COMPATIBILITY.txt' % git_hash
|
||||
self._queryct = self._queryct + 1
|
||||
if not self._silent:
|
||||
print 'Reading %s' % query_url
|
||||
print('Reading %s' % query_url)
|
||||
|
||||
try:
|
||||
# Read the remote URL contents.
|
||||
handle = urllib.urlopen(query_url)
|
||||
handle = urlopen(query_url)
|
||||
compat_value = handle.read().strip()
|
||||
handle.close()
|
||||
|
||||
@ -182,8 +190,8 @@ class cef_json_builder:
|
||||
val = config['chromium_checkout']
|
||||
if val.find('refs/tags/') == 0:
|
||||
chromium_version = val[10:]
|
||||
except Exception, e:
|
||||
print 'Failed to read Chromium version information'
|
||||
except Exception as e:
|
||||
print('Failed to read Chromium version information')
|
||||
raise
|
||||
|
||||
return chromium_version
|
||||
@ -392,7 +400,7 @@ class cef_json_builder:
|
||||
# Parse the file name.
|
||||
(platform, version, type) = self._parse_name(name)
|
||||
|
||||
if not isinstance(size, (int, long)):
|
||||
if not isinstance(size, int):
|
||||
size = int(size)
|
||||
if not isinstance(last_modified, datetime.datetime):
|
||||
last_modified = parse_date(last_modified)
|
||||
|
@ -16,6 +16,8 @@
|
||||
# After creating an index.json file you can use the cef_html_builder.py tool to
|
||||
# create an HTML file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from __future__ import print_function
|
||||
from cef_json_builder import cef_json_builder
|
||||
import datetime
|
||||
import os
|
||||
@ -70,8 +72,9 @@ def create_fake_files(platform, version):
|
||||
if __name__ == '__main__':
|
||||
# Verify command-line arguments.
|
||||
if len(sys.argv) < 5 or sys.argv[1] != 'add':
|
||||
sys.stderr.write('Usage: %s add <platform> <cef_version> <chromium_version>'
|
||||
% sys.argv[0])
|
||||
sys.stderr.write(
|
||||
'Usage: %s add <platform> <cef_version> <chromium_version>\n' %
|
||||
sys.argv[0])
|
||||
sys.exit()
|
||||
|
||||
# Requested platform.
|
||||
@ -80,19 +83,19 @@ if __name__ == '__main__':
|
||||
elif sys.argv[2] in cef_json_builder.get_platforms():
|
||||
platforms = [sys.argv[2]]
|
||||
else:
|
||||
sys.stderr.write('Invalid platform: %s' % platform)
|
||||
sys.stderr.write('Invalid platform: %s\n' % platform)
|
||||
sys.exit()
|
||||
|
||||
# Requested CEF version.
|
||||
cef_version = sys.argv[3]
|
||||
if not cef_json_builder.is_valid_version(cef_version):
|
||||
sys.stderr.write('Invalid CEF version: %s' % cef_version)
|
||||
sys.stderr.write('Invalid CEF version: %s\n' % cef_version)
|
||||
sys.exit()
|
||||
|
||||
# Requested Chromium version.
|
||||
chromium_version = sys.argv[4]
|
||||
if not cef_json_builder.is_valid_chromium_version(chromium_version):
|
||||
sys.stderr.write('Invalid Chromium version: %s' % chromium_version)
|
||||
sys.stderr.write('Invalid Chromium version: %s\n' % chromium_version)
|
||||
sys.exit()
|
||||
|
||||
# Write the JSON file in the same directory as this file.
|
||||
@ -109,7 +112,7 @@ if __name__ == '__main__':
|
||||
# Load the existing JSON file, if any. Ignore format errors for example
|
||||
# purposes.
|
||||
if os.path.exists(json_file):
|
||||
print '--> Reading index.json'
|
||||
print('--> Reading index.json')
|
||||
with open(json_file, 'r') as f:
|
||||
builder.load(f.read(), fatalerrors=False)
|
||||
|
||||
@ -140,10 +143,10 @@ if __name__ == '__main__':
|
||||
|
||||
if len(changed_files) > 0:
|
||||
# Write the updated JSON file.
|
||||
print '--> Writing index.json'
|
||||
print('--> Writing index.json')
|
||||
with open(json_file, 'w') as f:
|
||||
f.write(str(builder))
|
||||
|
||||
# A real implementation would now upload the changed files.
|
||||
for file in changed_files:
|
||||
print '--> Upload file %s' % file['name']
|
||||
print('--> Upload file %s' % file['name'])
|
||||
|
@ -2,6 +2,7 @@
|
||||
# reserved. Use of this source code is governed by a BSD-style license that
|
||||
# can be found in the LICENSE file.
|
||||
|
||||
from __future__ import absolute_import
|
||||
from cef_json_builder import cef_json_builder
|
||||
import datetime
|
||||
import unittest
|
||||
|
Loading…
x
Reference in New Issue
Block a user