diff --git a/infra/config/recipes.cfg b/infra/config/recipes.cfg index e5f733ecd5..d758e49a3f 100644 --- a/infra/config/recipes.cfg +++ b/infra/config/recipes.cfg @@ -15,7 +15,7 @@ "deps": { "recipe_engine": { "branch": "master", - "revision": "bae937d72f6b21b53a3218efdb0471861a332c0c", + "revision": "c923df1b4ecf75345768d71a09e0ce17fd21c9aa", "url": "https://chromium.googlesource.com/infra/luci/recipes-py.git" } }, diff --git a/recipes/README.recipes.md b/recipes/README.recipes.md index 8b05fd0acd..43a65368f9 100644 --- a/recipes/README.recipes.md +++ b/recipes/README.recipes.md @@ -997,19 +997,19 @@ Move things around in a loop! — **def [RunSteps](/recipes/recipe_modules/windows_sdk/examples/full.py#13)(api):** -[recipe_engine/recipe_modules/buildbucket]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/README.recipes.md#recipe_modules-buildbucket -[recipe_engine/recipe_modules/cipd]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/README.recipes.md#recipe_modules-cipd -[recipe_engine/recipe_modules/commit_position]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/README.recipes.md#recipe_modules-commit_position -[recipe_engine/recipe_modules/context]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/README.recipes.md#recipe_modules-context -[recipe_engine/recipe_modules/file]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/README.recipes.md#recipe_modules-file -[recipe_engine/recipe_modules/json]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/README.recipes.md#recipe_modules-json -[recipe_engine/recipe_modules/path]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/README.recipes.md#recipe_modules-path -[recipe_engine/recipe_modules/platform]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/README.recipes.md#recipe_modules-platform -[recipe_engine/recipe_modules/properties]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/README.recipes.md#recipe_modules-properties -[recipe_engine/recipe_modules/python]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/README.recipes.md#recipe_modules-python -[recipe_engine/recipe_modules/raw_io]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/README.recipes.md#recipe_modules-raw_io -[recipe_engine/recipe_modules/runtime]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/README.recipes.md#recipe_modules-runtime -[recipe_engine/recipe_modules/source_manifest]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/README.recipes.md#recipe_modules-source_manifest -[recipe_engine/recipe_modules/step]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/README.recipes.md#recipe_modules-step -[recipe_engine/recipe_modules/url]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/README.recipes.md#recipe_modules-url -[recipe_engine/wkt/RecipeApi]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/bae937d72f6b21b53a3218efdb0471861a332c0c/recipe_engine/recipe_api.py#836 +[recipe_engine/recipe_modules/buildbucket]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/README.recipes.md#recipe_modules-buildbucket +[recipe_engine/recipe_modules/cipd]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/README.recipes.md#recipe_modules-cipd +[recipe_engine/recipe_modules/commit_position]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/README.recipes.md#recipe_modules-commit_position +[recipe_engine/recipe_modules/context]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/README.recipes.md#recipe_modules-context +[recipe_engine/recipe_modules/file]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/README.recipes.md#recipe_modules-file +[recipe_engine/recipe_modules/json]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/README.recipes.md#recipe_modules-json +[recipe_engine/recipe_modules/path]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/README.recipes.md#recipe_modules-path +[recipe_engine/recipe_modules/platform]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/README.recipes.md#recipe_modules-platform +[recipe_engine/recipe_modules/properties]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/README.recipes.md#recipe_modules-properties +[recipe_engine/recipe_modules/python]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/README.recipes.md#recipe_modules-python +[recipe_engine/recipe_modules/raw_io]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/README.recipes.md#recipe_modules-raw_io +[recipe_engine/recipe_modules/runtime]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/README.recipes.md#recipe_modules-runtime +[recipe_engine/recipe_modules/source_manifest]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/README.recipes.md#recipe_modules-source_manifest +[recipe_engine/recipe_modules/step]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/README.recipes.md#recipe_modules-step +[recipe_engine/recipe_modules/url]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/README.recipes.md#recipe_modules-url +[recipe_engine/wkt/RecipeApi]: https://chromium.googlesource.com/infra/luci/recipes-py.git/+/c923df1b4ecf75345768d71a09e0ce17fd21c9aa/recipe_engine/recipe_api.py#836 diff --git a/recipes/recipes.py b/recipes/recipes.py index 6cdc365cad..c6b37aea1a 100755 --- a/recipes/recipes.py +++ b/recipes/recipes.py @@ -13,7 +13,6 @@ # pylint: disable=pointless-string-statement ''''exec python -u -- "$0" ${1+"$@"} # ''' # vi: syntax=python - """Bootstrap script to clone and forward to the recipe engine tool. ******************* @@ -41,14 +40,14 @@ from collections import namedtuple # revision (str) - the git revision for the engine to get. # branch (str) - the branch to fetch for the engine as an absolute ref (e.g. # refs/heads/master) -EngineDep = namedtuple('EngineDep', - 'url revision branch') +EngineDep = namedtuple('EngineDep', 'url revision branch') class MalformedRecipesCfg(Exception): + def __init__(self, msg, path): - super(MalformedRecipesCfg, self).__init__('malformed recipes.cfg: %s: %r' - % (msg, path)) + full_message = 'malformed recipes.cfg: %s: %r' % (msg, path) + super(MalformedRecipesCfg, self).__init__(full_message) def parse(repo_root, recipes_cfg_path): @@ -86,8 +85,8 @@ def parse(repo_root, recipes_cfg_path): if 'url' not in engine: raise MalformedRecipesCfg( - 'Required field "url" in dependency "recipe_engine" not found', - recipes_cfg_path) + 'Required field "url" in dependency "recipe_engine" not found', + recipes_cfg_path) engine.setdefault('revision', '') engine.setdefault('branch', 'refs/heads/master') @@ -97,8 +96,8 @@ def parse(repo_root, recipes_cfg_path): if not engine['branch'].startswith('refs/'): engine['branch'] = 'refs/heads/' + engine['branch'] - recipes_path = os.path.join( - repo_root, recipes_path.replace('/', os.path.sep)) + recipes_path = os.path.join(repo_root, + recipes_path.replace('/', os.path.sep)) return EngineDep(**engine), recipes_path except KeyError as ex: raise MalformedRecipesCfg(ex.message, recipes_cfg_path) @@ -114,6 +113,7 @@ REQUIRED_BINARIES = {GIT, VPYTHON, CIPD} def _is_executable(path): return os.path.isfile(path) and os.access(path, os.X_OK) + # TODO: Use shutil.which once we switch to Python3. def _is_on_path(basename): for path in os.environ['PATH'].split(os.pathsep): @@ -129,13 +129,13 @@ def _subprocess_call(argv, **kwargs): def _git_check_call(argv, **kwargs): - argv = [GIT]+argv + argv = [GIT] + argv logging.info('Running %r', argv) subprocess.check_call(argv, **kwargs) def _git_output(argv, **kwargs): - argv = [GIT]+argv + argv = [GIT] + argv logging.info('Running %r', argv) return subprocess.check_output(argv, **kwargs) @@ -181,10 +181,15 @@ def checkout_engine(engine_path, repo_root, recipes_cfg_path): _git_check_call(['init', engine_path], stdout=NUL) try: - _git_check_call(['rev-parse', '--verify', '%s^{commit}' % revision], - cwd=engine_path, stdout=NUL, stderr=NUL) + _git_check_call(['rev-parse', '--verify', + '%s^{commit}' % revision], + cwd=engine_path, + stdout=NUL, + stderr=NUL) except subprocess.CalledProcessError: - _git_check_call(['fetch', url, branch], cwd=engine_path, stdout=NUL, + _git_check_call(['fetch', url, branch], + cwd=engine_path, + stdout=NUL, stderr=NUL) try: @@ -213,13 +218,12 @@ def main(): if recipes_cfg_path: # calculate repo_root from recipes_cfg_path repo_root = os.path.dirname( - os.path.dirname( - os.path.dirname(recipes_cfg_path))) + os.path.dirname(os.path.dirname(recipes_cfg_path))) else: # find repo_root with git and calculate recipes_cfg_path - repo_root = (_git_output( - ['rev-parse', '--show-toplevel'], - cwd=os.path.abspath(os.path.dirname(__file__))).strip()) + repo_root = ( + _git_output(['rev-parse', '--show-toplevel'], + cwd=os.path.abspath(os.path.dirname(__file__))).strip()) repo_root = os.path.abspath(repo_root) recipes_cfg_path = os.path.join(repo_root, 'infra', 'config', 'recipes.cfg') args = ['--package', recipes_cfg_path] + args @@ -227,9 +231,9 @@ def main(): engine_path = checkout_engine(engine_override, repo_root, recipes_cfg_path) try: - return _subprocess_call([ - VPYTHON, '-u', - os.path.join(engine_path, 'recipe_engine', 'main.py')] + args) + return _subprocess_call( + [VPYTHON, '-u', + os.path.join(engine_path, 'recipe_engine', 'main.py')] + args) except KeyboardInterrupt: return 1