Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 # Copyright 2016 The Chromium Authors. All rights reserved. | 1 # Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import cStringIO | 5 import cStringIO |
| 6 import collections | 6 import collections |
| 7 import contextlib | 7 import contextlib |
| 8 import datetime | 8 import datetime |
| 9 import json | 9 import json |
| 10 import os | 10 import os |
| (...skipping 25 matching lines...) Expand all Loading... | |
| 36 | 36 |
| 37 def open_step(self, step_dict): | 37 def open_step(self, step_dict): |
| 38 """Constructs an OpenStep object which can be used to actually run a step. | 38 """Constructs an OpenStep object which can be used to actually run a step. |
| 39 | 39 |
| 40 step_dict parameters: | 40 step_dict parameters: |
| 41 name: name of the step, will appear in buildbots waterfall | 41 name: name of the step, will appear in buildbots waterfall |
| 42 cmd: command to run, list of one or more strings | 42 cmd: command to run, list of one or more strings |
| 43 cwd: absolute path to working directory for the command | 43 cwd: absolute path to working directory for the command |
| 44 env: dict with overrides for environment variables | 44 env: dict with overrides for environment variables |
| 45 allow_subannotations: if True, lets the step emit its own annotations | 45 allow_subannotations: if True, lets the step emit its own annotations |
| 46 trigger_specs: a list of trigger specifications, which are dict with keys: | 46 trigger_specs: a list of trigger specifications, see also _trigger_builds. |
| 47 properties: a dict of properties. | |
| 48 Buildbot requires buildername property. | |
| 49 stdout: Path to a file to put step stdout into. If used, stdout won't | 47 stdout: Path to a file to put step stdout into. If used, stdout won't |
| 50 appear in annotator's stdout (and |allow_subannotations| is | 48 appear in annotator's stdout (and |allow_subannotations| is |
| 51 ignored). | 49 ignored). |
| 52 stderr: Path to a file to put step stderr into. If used, stderr won't | 50 stderr: Path to a file to put step stderr into. If used, stderr won't |
| 53 appear in annotator's stderr. | 51 appear in annotator's stderr. |
| 54 stdin: Path to a file to read step stdin from. | 52 stdin: Path to a file to read step stdin from. |
| 55 | 53 |
| 56 Returns an OpenStep object. | 54 Returns an OpenStep object. |
| 57 """ | 55 """ |
| 58 raise NotImplementedError() | 56 raise NotImplementedError() |
| (...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 330 raise ValueError('Trigger spec: builder_name is not set') | 328 raise ValueError('Trigger spec: builder_name is not set') |
| 331 | 329 |
| 332 changes = trig.get('buildbot_changes', []) | 330 changes = trig.get('buildbot_changes', []) |
| 333 assert isinstance(changes, list), 'buildbot_changes must be a list' | 331 assert isinstance(changes, list), 'buildbot_changes must be a list' |
| 334 changes = map(self._normalize_change, changes) | 332 changes = map(self._normalize_change, changes) |
| 335 | 333 |
| 336 step.trigger(json.dumps({ | 334 step.trigger(json.dumps({ |
| 337 'builderNames': [builder_name], | 335 'builderNames': [builder_name], |
| 338 'bucket': trig.get('bucket'), | 336 'bucket': trig.get('bucket'), |
| 339 'changes': changes, | 337 'changes': changes, |
| 338 # if True and triggering fails asynchronously, fail entire build. | |
|
nodir
2016/05/04 17:28:13
implemented in https://codereview.chromium.org/194
| |
| 339 'critical': trig.get('critical', True), | |
| 340 'properties': trig.get('properties'), | 340 'properties': trig.get('properties'), |
| 341 'tags': trig.get('tags'), | 341 'tags': trig.get('tags'), |
| 342 }, sort_keys=True)) | 342 }, sort_keys=True)) |
| 343 | 343 |
| 344 def _normalize_change(self, change): | 344 def _normalize_change(self, change): |
| 345 assert isinstance(change, dict), 'Change is not a dict' | 345 assert isinstance(change, dict), 'Change is not a dict' |
| 346 change = change.copy() | 346 change = change.copy() |
| 347 | 347 |
| 348 # Convert when_timestamp to UNIX timestamp. | 348 # Convert when_timestamp to UNIX timestamp. |
| 349 when = change.get('when_timestamp') | 349 when = change.get('when_timestamp') |
| (...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 supplied command, and only uses the |env| kwarg for modifying the environment | 612 supplied command, and only uses the |env| kwarg for modifying the environment |
| 613 of the child process. | 613 of the child process. |
| 614 """ | 614 """ |
| 615 saved_path = os.environ['PATH'] | 615 saved_path = os.environ['PATH'] |
| 616 try: | 616 try: |
| 617 if path is not None: | 617 if path is not None: |
| 618 os.environ['PATH'] = path | 618 os.environ['PATH'] = path |
| 619 yield | 619 yield |
| 620 finally: | 620 finally: |
| 621 os.environ['PATH'] = saved_path | 621 os.environ['PATH'] = saved_path |
| OLD | NEW |