2012-04-03 03:34:16 +02:00
|
|
|
# Copyright (c) 2011 The Chromium Embedded Framework Authors.
|
|
|
|
# Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
2020-01-12 16:48:13 +01:00
|
|
|
from __future__ import absolute_import
|
|
|
|
from __future__ import print_function
|
2012-04-03 03:34:16 +02:00
|
|
|
import os, sys
|
|
|
|
|
|
|
|
try:
|
|
|
|
# depot_tools may already be in the import path.
|
|
|
|
import gclient_utils
|
2020-01-12 16:48:13 +01:00
|
|
|
except ImportError as e:
|
2012-04-03 03:34:16 +02:00
|
|
|
# Search the PATH environment variable to find the depot_tools folder.
|
2017-05-28 15:04:18 +02:00
|
|
|
depot_tools = None
|
2012-04-03 03:34:16 +02:00
|
|
|
paths = os.environ.get('PATH').split(os.pathsep)
|
|
|
|
for path in paths:
|
|
|
|
if os.path.exists(os.path.join(path, 'gclient_utils.py')):
|
|
|
|
depot_tools = path
|
|
|
|
break
|
|
|
|
|
|
|
|
if depot_tools is None:
|
2020-01-12 16:48:13 +01:00
|
|
|
print('Error: could not find depot_tools in PATH.', file=sys.stderr)
|
2012-04-03 03:34:16 +02:00
|
|
|
sys.exit(2)
|
|
|
|
|
|
|
|
# Add depot_tools to import path.
|
|
|
|
sys.path.append(depot_tools)
|
|
|
|
import gclient_utils
|
|
|
|
|
2017-05-28 15:04:18 +02:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
# Copied from gclient.py python code.
|
|
|
|
def RunAction(dir, command):
|
|
|
|
"""Runs the action."""
|
|
|
|
try:
|
2019-08-05 20:01:14 +02:00
|
|
|
gclient_utils.CheckCallAndFilter(
|
|
|
|
command, cwd=dir, always_show_header=True, print_stdout=True)
|
2020-01-12 16:48:13 +01:00
|
|
|
except gclient_utils.Error as e:
|
2012-04-03 03:34:16 +02:00
|
|
|
# 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.
|
2020-01-12 16:48:13 +01:00
|
|
|
print('Error: %s' % str(e), file=sys.stderr)
|
2012-04-03 03:34:16 +02:00
|
|
|
sys.exit(2)
|