Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(124)

Side by Side Diff: recipes.py

Issue 2052543003: Emit CURRENT_TIMESTAMP annotation (Closed) Base URL: git@github.com:luci/recipes-py.git@master
Patch Set: nit Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « recipe_engine/unittests/stream_test.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 workdir = (args.workdir or 131 workdir = (args.workdir or
132 os.path.join(os.path.dirname(os.path.realpath(__file__)), 'workdir')) 132 os.path.join(os.path.dirname(os.path.realpath(__file__)), 'workdir'))
133 logging.info('Using %s as work directory' % workdir) 133 logging.info('Using %s as work directory' % workdir)
134 if not os.path.exists(workdir): 134 if not os.path.exists(workdir):
135 os.makedirs(workdir) 135 os.makedirs(workdir)
136 136
137 old_cwd = os.getcwd() 137 old_cwd = os.getcwd()
138 os.chdir(workdir) 138 os.chdir(workdir)
139 stream_engine = stream.ProductStreamEngine( 139 stream_engine = stream.ProductStreamEngine(
140 stream.StreamEngineInvariants(), 140 stream.StreamEngineInvariants(),
141 stream.AnnotatorStreamEngine(sys.stdout)) 141 stream.AnnotatorStreamEngine(sys.stdout, emit_timestamps=args.timestamps))
142 with stream_engine:
143 try:
144 ret = recipe_run.run_steps(
145 properties, stream_engine,
146 step_runner.SubprocessStepRunner(stream_engine),
147 universe=universe)
148 finally:
149 os.chdir(old_cwd)
142 150
143 try: 151 return handle_recipe_return(ret, args.output_result_json, stream_engine)
144 ret = recipe_run.run_steps(
145 properties, stream_engine,
146 step_runner.SubprocessStepRunner(stream_engine),
147 universe=universe)
148
149 finally:
150 os.chdir(old_cwd)
151
152 return handle_recipe_return(ret, args.output_result_json, stream_engine)
153 152
154 153
155 def remote_run(args): 154 def remote_run(args):
156 from recipe_engine import remote_run 155 from recipe_engine import remote_run
157 156
158 return remote_run.main(args) 157 return remote_run.main(args)
159 158
160 159
161 def autoroll(args): 160 def autoroll(args):
162 from recipe_engine import autoroll 161 from recipe_engine import autoroll
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 '--workdir', 287 '--workdir',
289 help='The working directory of recipe execution') 288 help='The working directory of recipe execution')
290 run_p.add_argument( 289 run_p.add_argument(
291 '--output-result-json', 290 '--output-result-json',
292 help='The file to write the JSON serialized returned value \ 291 help='The file to write the JSON serialized returned value \
293 of the recipe to') 292 of the recipe to')
294 run_p.add_argument( 293 run_p.add_argument(
295 'recipe', 294 'recipe',
296 help='The recipe to execute') 295 help='The recipe to execute')
297 run_p.add_argument( 296 run_p.add_argument(
298 'props', nargs=argparse.REMAINDER, 297 'props',
298 nargs=argparse.REMAINDER,
299 help='A list of property pairs; e.g. mastername=chromium.linux ' 299 help='A list of property pairs; e.g. mastername=chromium.linux '
300 'issue=12345') 300 'issue=12345')
301 run_p.add_argument(
302 '--timestamps',
303 action='store_true',
304 help='If true, emit CURRENT_TIMESTAMP annotations. '
305 'Default: false. '
306 'CURRENT_TIMESTAMP annotation has one parameter, current time in '
307 'Unix timestamp format. '
308 'CURRENT_TIMESTAMP annotation will be printed at the beginning and '
309 'end of the annotation stream and also immediately before each '
310 'STEP_START and STEP_END annotations.',
311 )
301 312
302 remote_run_p = subp.add_parser( 313 remote_run_p = subp.add_parser(
303 'remote_run', 314 'remote_run',
304 description='Run a recipe from specified repo and revision') 315 description='Run a recipe from specified repo and revision')
305 remote_run_p.set_defaults(command='remote_run') 316 remote_run_p.set_defaults(command='remote_run')
306 remote_run_p.add_argument( 317 remote_run_p.add_argument(
307 '--repository', required=True, 318 '--repository', required=True,
308 help='URL of a git repository to fetch') 319 help='URL of a git repository to fetch')
309 remote_run_p.add_argument( 320 remote_run_p.add_argument(
310 '--revision', 321 '--revision',
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
432 ret = main() 443 ret = main()
433 if not isinstance(ret, int): 444 if not isinstance(ret, int):
434 if ret is None: 445 if ret is None:
435 ret = 0 446 ret = 0
436 else: 447 else:
437 print >> sys.stderr, ret 448 print >> sys.stderr, ret
438 ret = 1 449 ret = 1
439 sys.stdout.flush() 450 sys.stdout.flush()
440 sys.stderr.flush() 451 sys.stderr.flush()
441 os._exit(ret) 452 os._exit(ret)
OLDNEW
« no previous file with comments | « recipe_engine/unittests/stream_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698