OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 2 # Copyright (c) 2013 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 """Contains generating and parsing systems of the Chromium Buildbot Annotator. | 6 """Contains generating and parsing systems of the Chromium Buildbot Annotator. |
7 | 7 |
8 When executed as a script, this reads step name / command pairs from a file and | 8 When executed as a script, this reads step name / command pairs from a file and |
9 executes those lines while annotating the output. The input is json: | 9 executes those lines while annotating the output. The input is json: |
10 | 10 |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
387 print 'step was: %s' % json.dumps(step_dict) | 387 print 'step was: %s' % json.dumps(step_dict) |
388 s.step_failure() | 388 s.step_failure() |
389 build_failure = True | 389 build_failure = True |
390 except OSError: | 390 except OSError: |
391 # File wasn't found, error has been already reported to stream. | 391 # File wasn't found, error has been already reported to stream. |
392 build_failure = True | 392 build_failure = True |
393 | 393 |
394 return build_failure, ret | 394 return build_failure, ret |
395 | 395 |
396 | 396 |
397 def run_steps(steps, build_failure): | 397 def run_steps(steps, build_failure, seed_steps=None): |
398 for step in steps: | 398 for step in steps: |
399 error = _validate_step(step) | 399 error = _validate_step(step) |
400 if error: | 400 if error: |
401 print 'Invalid step - %s\n%s' % (error, json.dumps(step, indent=2)) | 401 print 'Invalid step - %s\n%s' % (error, json.dumps(step, indent=2)) |
402 sys.exit(1) | 402 sys.exit(1) |
403 | 403 |
404 seed_steps = [] | 404 if seed_steps is None: |
405 for step in steps: | 405 seed_steps = [s['name'] for s in steps] |
406 seed_steps.append(step['name']) | |
407 seed_steps.extend(step.get('seed_steps', [])) | |
408 | 406 |
409 stream = StructuredAnnotationStream(seed_steps=seed_steps) | 407 stream = StructuredAnnotationStream(seed_steps=seed_steps) |
410 ret_codes = [] | 408 ret_codes = [] |
411 for step in steps: | 409 for step in steps: |
412 build_failure, ret = _run_step(stream, build_failure, **step) | 410 build_failure, ret = _run_step(stream, build_failure, **step) |
413 ret_codes.append(ret) | 411 ret_codes.append(ret) |
414 return build_failure, ret_codes | 412 return build_failure, ret_codes |
415 | 413 |
416 | 414 |
417 def main(): | 415 def main(): |
(...skipping 11 matching lines...) Expand all Loading... |
429 steps.extend(json.load(sys.stdin)) | 427 steps.extend(json.load(sys.stdin)) |
430 else: | 428 else: |
431 with open(args[0], 'rb') as f: | 429 with open(args[0], 'rb') as f: |
432 steps.extend(json.load(f)) | 430 steps.extend(json.load(f)) |
433 | 431 |
434 return 1 if run_steps(steps, False)[0] else 0 | 432 return 1 if run_steps(steps, False)[0] else 0 |
435 | 433 |
436 | 434 |
437 if __name__ == '__main__': | 435 if __name__ == '__main__': |
438 sys.exit(main()) | 436 sys.exit(main()) |
OLD | NEW |