| Index: infra/recipes.py
|
| diff --git a/infra/recipes.py b/infra/recipes.py
|
| index f3d308119a0a076619517d0a6ad010b63c781950..b0ac43c0335bd613eff637a8fb651f1d328d2856 100755
|
| --- a/infra/recipes.py
|
| +++ b/infra/recipes.py
|
| @@ -1,8 +1,8 @@
|
| #!/usr/bin/env python
|
|
|
| -# Copyright 2016 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.
|
| +# Copyright 2016 The LUCI Authors. All rights reserved.
|
| +# Use of this source code is governed under the Apache License, Version 2.0
|
| +# that can be found in the LICENSE file.
|
|
|
| """Bootstrap script to clone and forward to the recipe engine tool.
|
|
|
| @@ -52,8 +52,10 @@ def parse_protobuf(fh):
|
| A recursive dictionary of lists.
|
| """
|
| def parse_atom(text):
|
| - if text == 'true': return True
|
| - if text == 'false': return False
|
| + if text == 'true':
|
| + return True
|
| + if text == 'false':
|
| + return False
|
| return ast.literal_eval(text)
|
|
|
| ret = {}
|
| @@ -70,8 +72,10 @@ def parse_protobuf(fh):
|
| ret.setdefault(m.group(1), []).append(subparse)
|
| continue
|
|
|
| - if line == '}': return ret
|
| - if line == '': continue
|
| + if line == '}':
|
| + return ret
|
| + if line == '':
|
| + continue
|
|
|
| raise ValueError('Could not understand line: <%s>' % line)
|
|
|
| @@ -89,7 +93,19 @@ def get_unique(things):
|
| return things[0]
|
|
|
|
|
| +def _subprocess_call(argv, **kwargs):
|
| + logging.info('Running %r', argv)
|
| + return subprocess.call(argv, **kwargs)
|
| +
|
| +def _subprocess_check_call(argv, **kwargs):
|
| + logging.info('Running %r', argv)
|
| + subprocess.check_call(argv, **kwargs)
|
| +
|
| +
|
| def main():
|
| + if '--verbose' in sys.argv:
|
| + logging.getLogger().setLevel(logging.INFO)
|
| +
|
| if sys.platform.startswith(('win', 'cygwin')):
|
| git = 'git.bat'
|
| else:
|
| @@ -120,28 +136,28 @@ def main():
|
| if not os.path.exists(deps_path):
|
| os.makedirs(deps_path)
|
| if not os.path.exists(engine_path):
|
| - subprocess.check_call([git, 'clone', engine_url, engine_path])
|
| + _subprocess_check_call([git, 'clone', engine_url, engine_path])
|
|
|
| - needs_fetch = subprocess.call(
|
| + needs_fetch = _subprocess_call(
|
| [git, 'rev-parse', '--verify', '%s^{commit}' % engine_revision],
|
| cwd=engine_path, stdout=open(os.devnull, 'w'))
|
| if needs_fetch:
|
| - subprocess.check_call([git, 'fetch'], cwd=engine_path)
|
| - subprocess.check_call(
|
| + _subprocess_check_call([git, 'fetch'], cwd=engine_path)
|
| + _subprocess_check_call(
|
| [git, 'checkout', '--quiet', engine_revision], cwd=engine_path)
|
|
|
| try:
|
| ensure_engine()
|
| - except subprocess.CalledProcessError as e:
|
| - if e.returncode == 128: # Thrown when git gets a lock error.
|
| - time.sleep(random.uniform(2,5))
|
| - ensure_engine()
|
| - else:
|
| - raise
|
| + except subprocess.CalledProcessError:
|
| + logging.exception('ensure_engine failed')
|
| +
|
| + # Retry errors.
|
| + time.sleep(random.uniform(2,5))
|
| + ensure_engine()
|
|
|
| args = ['--package', recipes_cfg_path,
|
| '--bootstrap-script', __file__] + sys.argv[1:]
|
| - return subprocess.call([
|
| + return _subprocess_call([
|
| sys.executable, '-u',
|
| os.path.join(engine_path, engine_subpath, 'recipes.py')] + args)
|
|
|
|
|