| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 The Chromium Authors. All rights reserved. |
| 3 # Use of this source code is governed by a BSD-style license that can be | 3 # Use of this source code is governed by a BSD-style license that can be |
| 4 # found in the LICENSE file. | 4 # found in the LICENSE file. |
| 5 | 5 |
| 6 """Tool to interact with recipe repositories. | 6 """Tool to interact with recipe repositories. |
| 7 | 7 |
| 8 This tool operates on the nearest ancestor directory containing an | 8 This tool operates on the nearest ancestor directory containing an |
| 9 infra/config/recipes.cfg. | 9 infra/config/recipes.cfg. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 import argparse | 12 import argparse |
| 13 import ast |
| 13 import json | 14 import json |
| 14 import logging | 15 import logging |
| 15 import os | 16 import os |
| 16 import subprocess | 17 import subprocess |
| 17 import sys | 18 import sys |
| 18 | 19 |
| 19 ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) | 20 ROOT_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 20 sys.path.insert(0, os.path.join(ROOT_DIR, 'recipe_engine', 'third_party')) | 21 sys.path.insert(0, os.path.join(ROOT_DIR, 'recipe_engine', 'third_party')) |
| 21 sys.path.insert(0, ROOT_DIR) | 22 sys.path.insert(0, ROOT_DIR) |
| 22 | 23 |
| (...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 properties = get_properties_from_file(args.properties_file) | 113 properties = get_properties_from_file(args.properties_file) |
| 113 else: | 114 else: |
| 114 properties = arg_properties | 115 properties = arg_properties |
| 115 | 116 |
| 116 properties['recipe'] = args.recipe | 117 properties['recipe'] = args.recipe |
| 117 | 118 |
| 118 os.environ['PYTHONUNBUFFERED'] = '1' | 119 os.environ['PYTHONUNBUFFERED'] = '1' |
| 119 os.environ['PYTHONIOENCODING'] = 'UTF-8' | 120 os.environ['PYTHONIOENCODING'] = 'UTF-8' |
| 120 | 121 |
| 121 _, config_file = get_package_config(args) | 122 _, config_file = get_package_config(args) |
| 122 universe = loader.UniverseView( | 123 universe_view = loader.UniverseView( |
| 123 loader.RecipeUniverse( | 124 loader.RecipeUniverse( |
| 124 package_deps, config_file), package_deps.root_package) | 125 package_deps, config_file), package_deps.root_package) |
| 125 | 126 |
| 126 workdir = (args.workdir or | 127 workdir = (args.workdir or |
| 127 os.path.join(os.path.dirname(os.path.realpath(__file__)), 'workdir')) | 128 os.path.join(os.path.dirname(os.path.realpath(__file__)), 'workdir')) |
| 128 logging.info('Using %s as work directory' % workdir) | 129 logging.info('Using %s as work directory' % workdir) |
| 129 if not os.path.exists(workdir): | 130 if not os.path.exists(workdir): |
| 130 os.makedirs(workdir) | 131 os.makedirs(workdir) |
| 131 | 132 |
| 132 if args.local_run: | 133 if args.local_run: |
| 133 stream_engine = stream.LocalRunStreamEngine(sys.stdout) | 134 stream_engine = stream.LocalRunStreamEngine(sys.stdout) |
| 134 else: | 135 else: |
| 135 stream_engine = stream.AnnotatorStreamEngine(sys.stdout) | 136 stream_engine = stream.AnnotatorStreamEngine(sys.stdout) |
| 136 | 137 |
| 137 old_cwd = os.getcwd() | 138 old_cwd = os.getcwd() |
| 138 os.chdir(workdir) | 139 os.chdir(workdir) |
| 139 stream_engine = stream.ProductStreamEngine( | 140 stream_engine = stream.ProductStreamEngine( |
| 140 stream.StreamEngineInvariants(), stream_engine) | 141 stream.StreamEngineInvariants(), stream_engine) |
| 141 | 142 |
| 142 try: | 143 try: |
| 143 ret = recipe_run.run_steps( | 144 ret = recipe_run.run_steps( |
| 144 properties, stream_engine, | 145 properties, stream_engine, |
| 145 step_runner.SubprocessStepRunner(stream_engine), | 146 step_runner.SubprocessStepRunner(stream_engine), |
| 146 universe=universe) | 147 universe_view=universe_view) |
| 147 | 148 |
| 148 finally: | 149 finally: |
| 149 os.chdir(old_cwd) | 150 os.chdir(old_cwd) |
| 150 | 151 |
| 151 if args.local_run: | 152 if args.local_run: |
| 152 print 'Finished recipe execution. Return value was %s' % ret | 153 print 'Finished recipe execution. Return value was %s' % ret |
| 153 return handle_recipe_return(ret, args.output_result_json, stream_engine) | 154 return handle_recipe_return(ret, args.output_result_json, stream_engine) |
| 154 | 155 |
| 155 | 156 |
| 156 def roll(args): | 157 def roll(args): |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 419 | 420 |
| 420 Warmly, | 421 Warmly, |
| 421 recipes.py | 422 recipes.py |
| 422 """ | 423 """ |
| 423 return 1 | 424 return 1 |
| 424 | 425 |
| 425 return 0 | 426 return 0 |
| 426 | 427 |
| 427 if __name__ == '__main__': | 428 if __name__ == '__main__': |
| 428 sys.exit(main()) | 429 sys.exit(main()) |
| OLD | NEW |