| 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): | 18 def __init__(self, factory=None, active_master=None): |
| 19 self._call_counts = {} | 19 self._call_counts = {} |
| 20 self.active_master = active_master |
| 20 # Set self._script_dir and self._python, among other things. | 21 # Set self._script_dir and self._python, among other things. |
| 21 commands.FactoryCommands.__init__(self, factory) | 22 commands.FactoryCommands.__init__(self, factory) |
| 22 | 23 |
| 23 def AddAnnotatedScript(self, factory_properties, timeout, max_time): | 24 def AddAnnotatedScript(self, factory_properties, timeout, max_time): |
| 24 call_count = self._call_counts.setdefault('AddAnnotatedScript', 0) | 25 call_count = self._call_counts.setdefault('AddAnnotatedScript', 0) |
| 25 if call_count != 0: | 26 if call_count != 0: |
| 26 raise Exception("AnnotatorCommands.AddAnnotatedScript called twice.") | 27 raise Exception("AnnotatorCommands.AddAnnotatedScript called twice.") |
| 27 self._call_counts['AddAnnotatedScript'] += 1 | 28 self._call_counts['AddAnnotatedScript'] += 1 |
| 28 factory_properties = factory_properties or {} | 29 factory_properties = factory_properties or {} |
| 29 runner = self.PathJoin(self._script_dir, 'annotated_run.py') | 30 runner = self.PathJoin(self._script_dir, 'annotated_run.py') |
| 30 cmd = [self._python, '-u', runner] | 31 cmd = [self._python, '-u', runner] |
| 31 cmd = self.AddBuildProperties(cmd) | 32 cmd = self.AddBuildProperties(cmd) |
| 32 cmd = self.AddFactoryProperties(factory_properties, cmd) | 33 cmd = self.AddFactoryProperties(factory_properties, cmd) |
| 33 self._factory.addStep(chromium_step.AnnotatedCommand, | 34 self._factory.addStep(chromium_step.AnnotatedCommand, |
| 34 name='steps', | 35 name='steps', |
| 35 description='running steps via annotated script', | 36 description='running steps via annotated script', |
| 36 timeout=timeout, | 37 timeout=timeout, |
| 37 maxTime=max_time, | 38 maxTime=max_time, |
| 38 haltOnFailure=True, | 39 haltOnFailure=True, |
| 39 command=cmd) | 40 command=cmd, |
| 41 active_master=self.active_master) |
| OLD | NEW |