OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2015 The LUCI Authors. All rights reserved. | 2 # Copyright 2015 The LUCI Authors. All rights reserved. |
3 # Use of this source code is governed under the Apache License, Version 2.0 | 3 # Use of this source code is governed under the Apache License, Version 2.0 |
4 # that can be found in the LICENSE file. | 4 # that can be 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 """ |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 os.path.join(os.path.dirname(os.path.realpath(__file__)), 'workdir')) | 147 os.path.join(os.path.dirname(os.path.realpath(__file__)), 'workdir')) |
148 logging.info('Using %s as work directory' % workdir) | 148 logging.info('Using %s as work directory' % workdir) |
149 if not os.path.exists(workdir): | 149 if not os.path.exists(workdir): |
150 os.makedirs(workdir) | 150 os.makedirs(workdir) |
151 | 151 |
152 old_cwd = os.getcwd() | 152 old_cwd = os.getcwd() |
153 os.chdir(workdir) | 153 os.chdir(workdir) |
154 stream_engine = stream.ProductStreamEngine( | 154 stream_engine = stream.ProductStreamEngine( |
155 stream.StreamEngineInvariants(), | 155 stream.StreamEngineInvariants(), |
156 stream.AnnotatorStreamEngine( | 156 stream.AnnotatorStreamEngine( |
157 sys.stdout, emit_timestamps=(args.timestamps or | 157 sys.stdout, |
158 op_args.annotation_flags.emit_timestamp))) | 158 emit_timestamps=(args.timestamps or |
| 159 op_args.annotation_flags.emit_timestamp))) |
159 with stream_engine: | 160 with stream_engine: |
160 # Emit initial properties if configured to do so. | 161 # Emit initial properties if configured to do so. |
161 if op_args.annotation_flags.emit_initial_properties: | 162 if op_args.annotation_flags.emit_initial_properties: |
162 with stream_engine.new_step_stream('Initial Properties') as s: | 163 with stream_engine.new_step_stream('Initial Properties') as s: |
163 for key in sorted(properties.iterkeys()): | 164 for key in sorted(properties.iterkeys()): |
164 s.set_build_property(key, json.dumps(properties[key], sort_keys=True)) | 165 s.set_build_property(key, json.dumps(properties[key], sort_keys=True)) |
165 | 166 |
166 try: | 167 try: |
167 ret = recipe_run.run_steps( | 168 ret = recipe_run.run_steps( |
168 properties, stream_engine, | 169 properties, stream_engine, |
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
566 ret = main() | 567 ret = main() |
567 if not isinstance(ret, int): | 568 if not isinstance(ret, int): |
568 if ret is None: | 569 if ret is None: |
569 ret = 0 | 570 ret = 0 |
570 else: | 571 else: |
571 print >> sys.stderr, ret | 572 print >> sys.stderr, ret |
572 ret = 1 | 573 ret = 1 |
573 sys.stdout.flush() | 574 sys.stdout.flush() |
574 sys.stderr.flush() | 575 sys.stderr.flush() |
575 os._exit(ret) | 576 os._exit(ret) |
OLD | NEW |