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 429 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 if isinstance(when, datetime.datetime): | 440 if isinstance(when, datetime.datetime): |
441 when = calendar.timegm(when.utctimetuple()) | 441 when = calendar.timegm(when.utctimetuple()) |
442 change['when_timestamp'] = when | 442 change['when_timestamp'] = when |
443 | 443 |
444 return change | 444 return change |
445 | 445 |
446 | 446 |
447 def triggerBuilds(step, trigger_specs): | 447 def triggerBuilds(step, trigger_specs): |
448 assert trigger_specs is not None | 448 assert trigger_specs is not None |
449 for trig in trigger_specs: | 449 for trig in trigger_specs: |
450 props = trig.get('properties') | 450 builder_name = trig.get('builder_name') |
451 if not props: | |
452 raise ValueError('Trigger spec: properties are missing') | |
453 builder_name = props.pop('buildername', None) | |
454 if not builder_name: | 451 if not builder_name: |
455 raise ValueError('Trigger spec: buildername property is missing') | 452 raise ValueError('Trigger spec: builder_name is not set') |
456 | 453 |
457 changes = props.get('buildbot.changes', []) | 454 changes = trig.get('buildbot_changes', []) |
458 assert isinstance(changes, list), 'buildbot.changes must be a list' | 455 assert isinstance(changes, list), 'buildbot_changes must be a list' |
459 changes = map(normalizeChange, changes) | 456 changes = map(normalizeChange, changes) |
460 | 457 |
461 step.step_trigger(json.dumps({ | 458 step.step_trigger(json.dumps({ |
462 'builderNames': [builder_name], | 459 'builderNames': [builder_name], |
463 'changes': changes, | 460 'changes': changes, |
464 'properties': props, | 461 'properties': trig.get('properties'), |
465 }, sort_keys=True)) | 462 }, sort_keys=True)) |
466 | 463 |
467 | 464 |
468 def run_step(stream, name, cmd, | 465 def run_step(stream, name, cmd, |
469 cwd=None, env=None, | 466 cwd=None, env=None, |
470 allow_subannotations=False, | 467 allow_subannotations=False, |
471 trigger_specs=None, | 468 trigger_specs=None, |
472 **kwargs): | 469 **kwargs): |
473 """Runs a single step. | 470 """Runs a single step. |
474 | 471 |
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 steps.extend(json.load(sys.stdin, object_hook=force_dict_strs)) | 664 steps.extend(json.load(sys.stdin, object_hook=force_dict_strs)) |
668 else: | 665 else: |
669 with open(args[0], 'rb') as f: | 666 with open(args[0], 'rb') as f: |
670 steps.extend(json.load(f, object_hook=force_dict_strs)) | 667 steps.extend(json.load(f, object_hook=force_dict_strs)) |
671 | 668 |
672 return 1 if run_steps(steps, False)[0] else 0 | 669 return 1 if run_steps(steps, False)[0] else 0 |
673 | 670 |
674 | 671 |
675 if __name__ == '__main__': | 672 if __name__ == '__main__': |
676 sys.exit(main()) | 673 sys.exit(main()) |
OLD | NEW |