mirror of
https://bitbucket.org/chromiumembedded/cef
synced 2025-06-05 21:39:12 +02:00
gclient_hook: Add Python 3 support (see issue #2856)
This commit is contained in:
@@ -3,12 +3,14 @@
|
||||
# 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 os, sys
|
||||
|
||||
try:
|
||||
# depot_tools may already be in the import path.
|
||||
import gclient_utils
|
||||
except ImportError, e:
|
||||
except ImportError as e:
|
||||
# Search the PATH environment variable to find the depot_tools folder.
|
||||
depot_tools = None
|
||||
paths = os.environ.get('PATH').split(os.pathsep)
|
||||
@@ -18,7 +20,7 @@ except ImportError, e:
|
||||
break
|
||||
|
||||
if depot_tools is None:
|
||||
print >> sys.stderr, 'Error: could not find depot_tools in PATH.'
|
||||
print('Error: could not find depot_tools in PATH.', file=sys.stderr)
|
||||
sys.exit(2)
|
||||
|
||||
# Add depot_tools to import path.
|
||||
@@ -29,18 +31,12 @@ except ImportError, e:
|
||||
# Copied from gclient.py python code.
|
||||
def RunAction(dir, command):
|
||||
"""Runs the action."""
|
||||
if command[0] == 'python':
|
||||
# If the hook specified "python" as the first item, the action is a
|
||||
# Python script. Run it by starting a new copy of the same
|
||||
# interpreter.
|
||||
command[0] = sys.executable
|
||||
|
||||
try:
|
||||
gclient_utils.CheckCallAndFilter(
|
||||
command, cwd=dir, always_show_header=True, print_stdout=True)
|
||||
except gclient_utils.Error, e:
|
||||
except gclient_utils.Error as e:
|
||||
# Use a discrete exit status code of 2 to indicate that a hook action
|
||||
# failed. Users of this script may wish to treat hook action failures
|
||||
# differently from VC failures.
|
||||
print >> sys.stderr, 'Error: %s' % str(e)
|
||||
print('Error: %s' % str(e), file=sys.stderr)
|
||||
sys.exit(2)
|
||||
|
Reference in New Issue
Block a user