| 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 """Utility class to generate and manage a factory to be passed to a | 5 """Utility class to generate and manage a factory to be passed to a |
| 6 builder dictionary as the 'factory' member, for each builder in c['builders']. | 6 builder dictionary as the 'factory' member, for each builder in c['builders']. |
| 7 | 7 |
| 8 Specifically creates a basic factory that will execute an arbirary annotator | 8 Specifically creates a basic factory that will execute an arbirary annotator |
| 9 script. | 9 script. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 from master.factory import annotator_commands | 12 from master.factory import annotator_commands |
| 13 from master.factory import commands | 13 from master.factory import commands |
| 14 from master.factory.build_factory import BuildFactory | 14 from master.factory.build_factory import BuildFactory |
| 15 | 15 |
| 16 | 16 |
| 17 class AnnotatorFactory(object): | 17 class AnnotatorFactory(object): |
| 18 """Encapsulates data and methods common to all annotators.""" | 18 """Encapsulates data and methods common to all annotators.""" |
| 19 | 19 |
| 20 def __init__(self): | 20 def __init__(self, active_master=None): |
| 21 self._factory_properties = None | 21 self._factory_properties = None |
| 22 self.active_master = active_master |
| 22 | 23 |
| 23 def BaseFactory(self, recipe=None, factory_properties=None, triggers=None, | 24 def BaseFactory(self, recipe=None, factory_properties=None, triggers=None, |
| 24 timeout=1200, max_time=None): | 25 timeout=1200, max_time=None): |
| 25 """The primary input for the factory is the |recipe|, which specifies the | 26 """The primary input for the factory is the |recipe|, which specifies the |
| 26 name of a recipe file to search for. The recipe file will fill in the rest | 27 name of a recipe file to search for. The recipe file will fill in the rest |
| 27 of the |factory_properties|. This setup allows for major changes to factory | 28 of the |factory_properties|. This setup allows for major changes to factory |
| 28 properties to occur on slave-side without master restarts. | 29 properties to occur on slave-side without master restarts. |
| 29 | 30 |
| 30 NOTE: Please be very discerning with what |factory_properties| you pass to | 31 NOTE: Please be very discerning with what |factory_properties| you pass to |
| 31 this method. Ideally, you will pass none, and that will be sufficient in the | 32 this method. Ideally, you will pass none, and that will be sufficient in the |
| (...skipping 11 matching lines...) Expand all Loading... |
| 43 |max_time| refers to the maximum number of seconds a step should be allowed | 44 |max_time| refers to the maximum number of seconds a step should be allowed |
| 44 to run, regardless of output. After |max_time| seconds, the step is forcibly | 45 to run, regardless of output. After |max_time| seconds, the step is forcibly |
| 45 killed. | 46 killed. |
| 46 """ | 47 """ |
| 47 factory_properties = factory_properties or {} | 48 factory_properties = factory_properties or {} |
| 48 if recipe: | 49 if recipe: |
| 49 factory_properties.update({'recipe': recipe}) | 50 factory_properties.update({'recipe': recipe}) |
| 50 self._factory_properties = factory_properties | 51 self._factory_properties = factory_properties |
| 51 factory = BuildFactory() | 52 factory = BuildFactory() |
| 52 factory.properties.update(self._factory_properties, 'AnnotatorFactory') | 53 factory.properties.update(self._factory_properties, 'AnnotatorFactory') |
| 53 cmd_obj = annotator_commands.AnnotatorCommands(factory) | 54 cmd_obj = annotator_commands.AnnotatorCommands( |
| 55 factory, active_master=self.active_master) |
| 54 cmd_obj.AddAnnotatedScript( | 56 cmd_obj.AddAnnotatedScript( |
| 55 factory_properties, timeout=timeout, max_time=max_time) | 57 factory_properties, timeout=timeout, max_time=max_time) |
| 56 | 58 |
| 57 for t in triggers or []: | 59 for t in triggers or []: |
| 58 factory.addStep(commands.CreateTriggerStep( | 60 factory.addStep(commands.CreateTriggerStep( |
| 59 t, trigger_copy_properties=['swarm_hashes'])) | 61 t, trigger_copy_properties=['swarm_hashes'])) |
| 60 | 62 |
| 61 return factory | 63 return factory |
| OLD | NEW |