mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
patcher: Add Python 3 support (see issue #2856)
This commit is contained in:
@ -2,6 +2,7 @@
|
|||||||
# reserved. Use of this source code is governed by a BSD-style license that
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
# can be found in the LICENSE file
|
# can be found in the LICENSE file
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from subprocess import Popen, PIPE
|
from subprocess import Popen, PIPE
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@ -32,8 +33,9 @@ def exec_cmd(cmd, path, input_string=None):
|
|||||||
shell=(sys.platform == 'win32'))
|
shell=(sys.platform == 'win32'))
|
||||||
out, err = process.communicate(input=input_string)
|
out, err = process.communicate(input=input_string)
|
||||||
ret = process.returncode
|
ret = process.returncode
|
||||||
except IOError, (errno, strerror):
|
except IOError as e:
|
||||||
|
(errno, strerror) = e.args
|
||||||
raise
|
raise
|
||||||
except:
|
except:
|
||||||
raise
|
raise
|
||||||
return {'out': out, 'err': err, 'ret': ret}
|
return {'out': out.decode(), 'err': err.decode(), 'ret': ret}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# reserved. Use of this source code is governed by a BSD-style license that
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
# can be found in the LICENSE file.
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from glob import iglob
|
from glob import iglob
|
||||||
import os
|
import os
|
||||||
import shutil
|
import shutil
|
||||||
@ -19,7 +20,8 @@ def read_file(name, normalize=True):
|
|||||||
# normalize line endings
|
# normalize line endings
|
||||||
data = data.replace("\r\n", "\n")
|
data = data.replace("\r\n", "\n")
|
||||||
return data
|
return data
|
||||||
except IOError, (errno, strerror):
|
except IOError as e:
|
||||||
|
(errno, strerror) = e.args
|
||||||
sys.stderr.write('Failed to read file ' + name + ': ' + strerror)
|
sys.stderr.write('Failed to read file ' + name + ': ' + strerror)
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
@ -32,7 +34,8 @@ def write_file(name, data):
|
|||||||
f = open(name, 'w')
|
f = open(name, 'w')
|
||||||
# write the data
|
# write the data
|
||||||
f.write(data)
|
f.write(data)
|
||||||
except IOError, (errno, strerror):
|
except IOError as e:
|
||||||
|
(errno, strerror) = e.args
|
||||||
sys.stderr.write('Failed to write file ' + name + ': ' + strerror)
|
sys.stderr.write('Failed to write file ' + name + ': ' + strerror)
|
||||||
raise
|
raise
|
||||||
else:
|
else:
|
||||||
@ -55,7 +58,8 @@ def copy_file(src, dst, quiet=True):
|
|||||||
shutil.copy2(src, dst)
|
shutil.copy2(src, dst)
|
||||||
if not quiet:
|
if not quiet:
|
||||||
sys.stdout.write('Transferring ' + src + ' file.\n')
|
sys.stdout.write('Transferring ' + src + ' file.\n')
|
||||||
except IOError, (errno, strerror):
|
except IOError as e:
|
||||||
|
(errno, strerror) = e.args
|
||||||
sys.stderr.write('Failed to copy file from ' + src + ' to ' + dst + ': ' +
|
sys.stderr.write('Failed to copy file from ' + src + ' to ' + dst + ': ' +
|
||||||
strerror)
|
strerror)
|
||||||
raise
|
raise
|
||||||
@ -67,7 +71,8 @@ def move_file(src, dst, quiet=True):
|
|||||||
shutil.move(src, dst)
|
shutil.move(src, dst)
|
||||||
if not quiet:
|
if not quiet:
|
||||||
sys.stdout.write('Moving ' + src + ' file.\n')
|
sys.stdout.write('Moving ' + src + ' file.\n')
|
||||||
except IOError, (errno, strerror):
|
except IOError as e:
|
||||||
|
(errno, strerror) = e.args
|
||||||
sys.stderr.write('Failed to move file from ' + src + ' to ' + dst + ': ' +
|
sys.stderr.write('Failed to move file from ' + src + ' to ' + dst + ': ' +
|
||||||
strerror)
|
strerror)
|
||||||
raise
|
raise
|
||||||
@ -90,7 +95,8 @@ def remove_file(name, quiet=True):
|
|||||||
os.remove(name)
|
os.remove(name)
|
||||||
if not quiet:
|
if not quiet:
|
||||||
sys.stdout.write('Removing ' + name + ' file.\n')
|
sys.stdout.write('Removing ' + name + ' file.\n')
|
||||||
except IOError, (errno, strerror):
|
except IOError as e:
|
||||||
|
(errno, strerror) = e.args
|
||||||
sys.stderr.write('Failed to remove file ' + name + ': ' + strerror)
|
sys.stderr.write('Failed to remove file ' + name + ': ' + strerror)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -102,7 +108,8 @@ def copy_dir(src, dst, quiet=True):
|
|||||||
shutil.copytree(src, dst)
|
shutil.copytree(src, dst)
|
||||||
if not quiet:
|
if not quiet:
|
||||||
sys.stdout.write('Transferring ' + src + ' directory.\n')
|
sys.stdout.write('Transferring ' + src + ' directory.\n')
|
||||||
except IOError, (errno, strerror):
|
except IOError as e:
|
||||||
|
(errno, strerror) = e.args
|
||||||
sys.stderr.write('Failed to copy directory from ' + src + ' to ' + dst +
|
sys.stderr.write('Failed to copy directory from ' + src + ' to ' + dst +
|
||||||
': ' + strerror)
|
': ' + strerror)
|
||||||
raise
|
raise
|
||||||
@ -115,7 +122,8 @@ def remove_dir(name, quiet=True):
|
|||||||
shutil.rmtree(name)
|
shutil.rmtree(name)
|
||||||
if not quiet:
|
if not quiet:
|
||||||
sys.stdout.write('Removing ' + name + ' directory.\n')
|
sys.stdout.write('Removing ' + name + ' directory.\n')
|
||||||
except IOError, (errno, strerror):
|
except IOError as e:
|
||||||
|
(errno, strerror) = e.args
|
||||||
sys.stderr.write('Failed to remove directory ' + name + ': ' + strerror)
|
sys.stderr.write('Failed to remove directory ' + name + ': ' + strerror)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
@ -127,7 +135,8 @@ def make_dir(name, quiet=True):
|
|||||||
if not quiet:
|
if not quiet:
|
||||||
sys.stdout.write('Creating ' + name + ' directory.\n')
|
sys.stdout.write('Creating ' + name + ' directory.\n')
|
||||||
os.makedirs(name)
|
os.makedirs(name)
|
||||||
except IOError, (errno, strerror):
|
except IOError as e:
|
||||||
|
(errno, strerror) = e.args
|
||||||
sys.stderr.write('Failed to create directory ' + name + ': ' + strerror)
|
sys.stderr.write('Failed to create directory ' + name + ': ' + strerror)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# reserved. Use of this source code is governed by a BSD-style license that
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
# can be found in the LICENSE file
|
# can be found in the LICENSE file
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
from exec_util import exec_cmd
|
from exec_util import exec_cmd
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
@ -130,7 +131,7 @@ def git_apply_patch_file(patch_path, patch_dir):
|
|||||||
if sys.platform == 'win32':
|
if sys.platform == 'win32':
|
||||||
# Convert the patch to Unix line endings. This is necessary to avoid
|
# Convert the patch to Unix line endings. This is necessary to avoid
|
||||||
# whitespace errors with git apply.
|
# whitespace errors with git apply.
|
||||||
patch_string = patch_string.replace('\r\n', '\n')
|
patch_string = patch_string.replace(b'\r\n', b'\n')
|
||||||
|
|
||||||
# Git apply fails silently if not run relative to a respository root.
|
# Git apply fails silently if not run relative to a respository root.
|
||||||
if not is_checkout(patch_dir):
|
if not is_checkout(patch_dir):
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# reserved. Use of this source code is governed by a BSD-style license that
|
# reserved. Use of this source code is governed by a BSD-style license that
|
||||||
# can be found in the LICENSE file.
|
# can be found in the LICENSE file.
|
||||||
|
|
||||||
|
from __future__ import absolute_import
|
||||||
import pickle
|
import pickle
|
||||||
from optparse import OptionParser
|
from optparse import OptionParser
|
||||||
import os
|
import os
|
||||||
@ -54,7 +55,7 @@ def apply_patch_config():
|
|||||||
|
|
||||||
# Parse the configuration file.
|
# Parse the configuration file.
|
||||||
scope = {}
|
scope = {}
|
||||||
execfile(config_file, scope)
|
exec (compile(open(config_file, "rb").read(), config_file, 'exec'), scope)
|
||||||
patches = scope["patches"]
|
patches = scope["patches"]
|
||||||
|
|
||||||
results = {'apply': 0, 'skip': 0, 'fail': 0}
|
results = {'apply': 0, 'skip': 0, 'fail': 0}
|
||||||
|
Reference in New Issue
Block a user