| OLD | NEW |
| 1 # Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 # Copyright (c) 2013 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 """Utilities to add commands to a buildbot factory. | 5 """Utilities to add commands to a buildbot factory. |
| 6 | 6 |
| 7 This is based on commands.py and adds annotator-specific commands. | 7 This is based on commands.py and adds annotator-specific commands. |
| 8 """ | 8 """ |
| 9 | 9 |
| 10 | 10 |
| 11 from master import chromium_step | 11 from master import chromium_step |
| 12 from master.factory import commands | 12 from master.factory import commands |
| 13 | 13 |
| 14 | 14 |
| 15 class AnnotatorCommands(commands.FactoryCommands): | 15 class AnnotatorCommands(commands.FactoryCommands): |
| 16 """Encapsulates methods to add annotator commands to a factory.""" | 16 """Encapsulates methods to add annotator commands to a factory.""" |
| 17 | 17 |
| 18 def __init__(self, factory=None, active_master=None): | 18 def __init__(self, factory=None, active_master=None): |
| 19 self._call_counts = {} | 19 self._call_counts = {} |
| 20 self.active_master = active_master | 20 self.active_master = active_master |
| 21 # Set self._script_dir and self._python, among other things. | 21 # Set self._script_dir and self._python, among other things. |
| 22 commands.FactoryCommands.__init__(self, factory) | 22 commands.FactoryCommands.__init__(self, factory) |
| 23 | 23 |
| 24 def AddAnnotatedScript(self, timeout, max_time): | 24 def AddAnnotatedScript(self, cmd, timeout, max_time): |
| 25 call_count = self._call_counts.setdefault('AddAnnotatedScript', 0) | 25 call_count = self._call_counts.setdefault('AddAnnotatedScript', 0) |
| 26 if call_count != 0: | 26 if call_count != 0: |
| 27 raise Exception("AnnotatorCommands.AddAnnotatedScript called twice.") | 27 raise Exception("AnnotatorCommands.AddAnnotatedScript called twice.") |
| 28 self._call_counts['AddAnnotatedScript'] += 1 | 28 self._call_counts['AddAnnotatedScript'] += 1 |
| 29 runner = self.PathJoin(self._script_dir, 'annotated_run.py') | |
| 30 cmd = [self._python, '-u', runner, '--use-factory-properties-from-disk'] | |
| 31 cmd = self.AddB64GzBuildProperties(cmd) | |
| 32 self._factory.addStep(chromium_step.AnnotatedCommand, | 29 self._factory.addStep(chromium_step.AnnotatedCommand, |
| 33 name='steps', | 30 name='steps', |
| 34 description='running steps via annotated script', | 31 description='running steps via annotated script', |
| 35 timeout=timeout, | 32 timeout=timeout, |
| 36 maxTime=max_time, | 33 maxTime=max_time, |
| 37 haltOnFailure=True, | 34 haltOnFailure=True, |
| 38 command=cmd, | 35 command=cmd, |
| 39 active_master=self.active_master) | 36 active_master=self.active_master) |
| OLD | NEW |