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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 ret = recipe_run.run_steps( | 144 ret = recipe_run.run_steps( |
145 properties, stream_engine, | 145 properties, stream_engine, |
146 step_runner.SubprocessStepRunner(stream_engine), | 146 step_runner.SubprocessStepRunner(stream_engine), |
147 universe=universe) | 147 universe=universe) |
148 finally: | 148 finally: |
149 os.chdir(old_cwd) | 149 os.chdir(old_cwd) |
150 | 150 |
151 return handle_recipe_return(ret, args.output_result_json, stream_engine) | 151 return handle_recipe_return(ret, args.output_result_json, stream_engine) |
152 | 152 |
153 | 153 |
| 154 def remote(args): |
| 155 from recipe_engine import remote |
| 156 |
| 157 return remote.main(args) |
| 158 |
| 159 |
154 def remote_run(args): | 160 def remote_run(args): |
155 from recipe_engine import remote_run | 161 from recipe_engine import remote_run |
156 | 162 |
157 return remote_run.main(args) | 163 return remote_run.main(args) |
158 | 164 |
159 | 165 |
160 def autoroll(args): | 166 def autoroll(args): |
161 from recipe_engine import autoroll | 167 from recipe_engine import autoroll |
162 | 168 |
163 repo_root, config_file = get_package_config(args) | 169 repo_root, config_file = get_package_config(args) |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
309 action='store_true', | 315 action='store_true', |
310 help='If true, emit CURRENT_TIMESTAMP annotations. ' | 316 help='If true, emit CURRENT_TIMESTAMP annotations. ' |
311 'Default: false. ' | 317 'Default: false. ' |
312 'CURRENT_TIMESTAMP annotation has one parameter, current time in ' | 318 'CURRENT_TIMESTAMP annotation has one parameter, current time in ' |
313 'Unix timestamp format. ' | 319 'Unix timestamp format. ' |
314 'CURRENT_TIMESTAMP annotation will be printed at the beginning and ' | 320 'CURRENT_TIMESTAMP annotation will be printed at the beginning and ' |
315 'end of the annotation stream and also immediately before each ' | 321 'end of the annotation stream and also immediately before each ' |
316 'STEP_STARTED and STEP_CLOSED annotations.', | 322 'STEP_STARTED and STEP_CLOSED annotations.', |
317 ) | 323 ) |
318 | 324 |
| 325 remote_p = subp.add_parser( |
| 326 'remote', |
| 327 description='Invoke a recipe command from specified repo and revision') |
| 328 remote_p.set_defaults(command='remote') |
| 329 remote_p.add_argument( |
| 330 '--repository', required=True, |
| 331 help='URL of a git repository to fetch') |
| 332 remote_p.add_argument( |
| 333 '--revision', |
| 334 help='Git commit hash to check out; defaults to latest revision (HEAD)') |
| 335 remote_p.add_argument( |
| 336 '--workdir', |
| 337 help='The working directory of repo checkout') |
| 338 remote_p.add_argument( |
| 339 '--use-gitiles', action='store_true', |
| 340 help='Use Gitiles-specific way to fetch repo (potentially cheaper for ' |
| 341 'large repos)') |
| 342 remote_p.add_argument( |
| 343 'remote_args', nargs='*', |
| 344 help='Arguments to pass to fetched repo\'s recipes.py') |
| 345 |
319 remote_run_p = subp.add_parser( | 346 remote_run_p = subp.add_parser( |
320 'remote_run', | 347 'remote_run', |
321 description='Run a recipe from specified repo and revision') | 348 description='Run a recipe from specified repo and revision') |
322 remote_run_p.set_defaults(command='remote_run') | 349 remote_run_p.set_defaults(command='remote_run') |
323 remote_run_p.add_argument( | 350 remote_run_p.add_argument( |
324 '--repository', required=True, | 351 '--repository', required=True, |
325 help='URL of a git repository to fetch') | 352 help='URL of a git repository to fetch') |
326 remote_run_p.add_argument( | 353 remote_run_p.add_argument( |
327 '--revision', | 354 '--revision', |
328 help='Git commit hash to check out; defaults to latest revision (HEAD)') | 355 help='Git commit hash to check out; defaults to latest revision (HEAD)') |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 args = sys.argv | 419 args = sys.argv |
393 return subprocess.call( | 420 return subprocess.call( |
394 ['ENV/bin/python'] + original_sys_argv, | 421 ['ENV/bin/python'] + original_sys_argv, |
395 cwd=os.path.dirname(os.path.realpath(__file__))) | 422 cwd=os.path.dirname(os.path.realpath(__file__))) |
396 | 423 |
397 if args.verbose: | 424 if args.verbose: |
398 logging.getLogger().setLevel(logging.INFO) | 425 logging.getLogger().setLevel(logging.INFO) |
399 | 426 |
400 # Commands which do not require config_file, package_deps, and other objects | 427 # Commands which do not require config_file, package_deps, and other objects |
401 # initialized later. | 428 # initialized later. |
402 if args.command == 'remote_run': | 429 if args.command == 'remote': |
| 430 return remote(args) |
| 431 elif args.command == 'remote_run': |
403 return remote_run(args) | 432 return remote_run(args) |
404 | 433 |
405 repo_root, config_file = get_package_config(args) | 434 repo_root, config_file = get_package_config(args) |
406 | 435 |
407 try: | 436 try: |
408 # TODO(phajdan.jr): gracefully handle inconsistent deps when rolling. | 437 # TODO(phajdan.jr): gracefully handle inconsistent deps when rolling. |
409 # This fails if the starting point does not have consistent dependency | 438 # This fails if the starting point does not have consistent dependency |
410 # graph. When performing an automated roll, it'd make sense to attempt | 439 # graph. When performing an automated roll, it'd make sense to attempt |
411 # to automatically find a consistent state, rather than bailing out. | 440 # to automatically find a consistent state, rather than bailing out. |
412 # Especially that only some subcommands refer to package_deps. | 441 # Especially that only some subcommands refer to package_deps. |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
461 ret = main() | 490 ret = main() |
462 if not isinstance(ret, int): | 491 if not isinstance(ret, int): |
463 if ret is None: | 492 if ret is None: |
464 ret = 0 | 493 ret = 0 |
465 else: | 494 else: |
466 print >> sys.stderr, ret | 495 print >> sys.stderr, ret |
467 ret = 1 | 496 ret = 1 |
468 sys.stdout.flush() | 497 sys.stdout.flush() |
469 sys.stderr.flush() | 498 sys.stderr.flush() |
470 os._exit(ret) | 499 os._exit(ret) |
OLD | NEW |