Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / build / buildman / bin / bmcore / BuildMan.py @ 27363

History | View | Annotate | Download (1.17 KB)

1
from bmbase.PlugInManager import PlugInManager
2

    
3
"""
4
        BuildMan manages the loading of plugins and 
5
        dispatch the requested tasks to the appropiate
6
        plug-in. Each plug-in defines its parameters and
7
        its help environment, so an ArgumentParse is 
8
        necessary in the construction. 
9
"""
10
class BuildMan:
11
        # constructor
12
        def __init__(self,arguments):
13
                self._arguments = arguments
14
                self._errorMessages = []
15
                self.__configurePlugins(self._arguments)
16

    
17
        # configure arguments of the automatic loaded plugins
18
        def __configurePlugins(self, arguments):
19
                for plugin in PlugInManager().getPlugInInstances().values():
20
                        plugin.initArguments(arguments)
21
                for plugin in PlugInManager().getPlugInInstances().values():
22
                        plugin.init()
23
                        if plugin.error():
24
                                self._errorMessages += plugin.getErrorMessages()
25

    
26
        # execute all plugins, any plugin with his arguments has the responsability of do the correct
27
        def run(self):
28
                for plugin in PlugInManager().getPlugInInstances().values():
29
                        plugin.run()
30
                        if plugin.error():
31
                                self._errorMessages += plugin.getErrorMessages()
32
                                return False
33
                return True        
34
                                
35

    
36
        def writeErrorMessages(self):
37
                for error in self._errorMessages:
38
                        print "ERROR: " + error + "\n"
39
        
40

    
41