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

Side by Side Diff: scripts/common/annotator.py

Issue 966993002: api.trigger: refactoring, made extensible (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/build
Patch Set: Created 5 years, 9 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 | Annotate | Revision Log
OLDNEW
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
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'
smut 2015/02/28 01:44:51 buildbot.changes -> buildbot_changes
nodir 2015/03/02 02:26:10 Done.
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
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())
OLDNEW
« no previous file with comments | « no previous file | scripts/slave/recipe_modules/step/config.py » ('j') | scripts/slave/recipe_modules/trigger/api.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698