mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-02-16 20:20:51 +01:00
Use explicit check for python version (see issue #2856)
This commit is contained in:
parent
3afa29d499
commit
1a406d079b
@ -8,12 +8,11 @@ import datetime
|
|||||||
import json
|
import json
|
||||||
import os
|
import os
|
||||||
import re
|
import re
|
||||||
|
import sys
|
||||||
|
|
||||||
try:
|
if sys.version_info.major == 2:
|
||||||
# Python 2
|
|
||||||
from urllib2 import urlopen
|
from urllib2 import urlopen
|
||||||
except Exception as e:
|
else:
|
||||||
# Python 3
|
|
||||||
from urllib.request import urlopen
|
from urllib.request import urlopen
|
||||||
|
|
||||||
# Class used to build the cefbuilds JSON file. See cef_json_builder_example.py
|
# Class used to build the cefbuilds JSON file. See cef_json_builder_example.py
|
||||||
|
@ -32,11 +32,9 @@ def write_file(name, data):
|
|||||||
try:
|
try:
|
||||||
with open(name, 'w', encoding='utf-8') as f:
|
with open(name, 'w', encoding='utf-8') as f:
|
||||||
# write the data
|
# write the data
|
||||||
try:
|
if sys.version_info.major == 2:
|
||||||
# Python 2
|
|
||||||
f.write(data.decode('utf-8'))
|
f.write(data.decode('utf-8'))
|
||||||
except Exception as e:
|
else:
|
||||||
# Python 3
|
|
||||||
f.write(data)
|
f.write(data)
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
(errno, strerror) = e.args
|
(errno, strerror) = e.args
|
||||||
|
@ -97,11 +97,9 @@ def process_file(path):
|
|||||||
|
|
||||||
with open(path, 'w', encoding='utf-8') as fp:
|
with open(path, 'w', encoding='utf-8') as fp:
|
||||||
str = "\n".join(result) + "\n"
|
str = "\n".join(result) + "\n"
|
||||||
try:
|
if sys.version_info.major == 2:
|
||||||
# Python 2
|
|
||||||
fp.write(str.decode('utf-8'))
|
fp.write(str.decode('utf-8'))
|
||||||
except Exception as e:
|
else:
|
||||||
# Python 3
|
|
||||||
fp.write(str)
|
fp.write(str)
|
||||||
|
|
||||||
|
|
||||||
|
@ -252,11 +252,9 @@ def eval_transfer_file(cef_dir, script_dir, transfer_cfg, output_dir, quiet):
|
|||||||
|
|
||||||
str = cfg['source'] + "\n"
|
str = cfg['source'] + "\n"
|
||||||
with open(readme, 'a', encoding='utf-8') as fp:
|
with open(readme, 'a', encoding='utf-8') as fp:
|
||||||
try:
|
if sys.version_info.major == 2:
|
||||||
# Python 2
|
|
||||||
fp.write(str.decode('utf-8'))
|
fp.write(str.decode('utf-8'))
|
||||||
except Exception as e:
|
else:
|
||||||
# Python 3
|
|
||||||
fp.write(str)
|
fp.write(str)
|
||||||
|
|
||||||
# perform any required post-processing
|
# perform any required post-processing
|
||||||
|
Loading…
x
Reference in New Issue
Block a user