Statistics
| Revision:

svn-gvsig-desktop / branches / v2_0_0_prep / build / buildman / bin / bmplugins / DepManCleanPlugIn.py @ 27363

History | View | Annotate | Download (2.04 KB)

1
from bmbase.IPlugIn import IPlugIn
2
from bmbase.PlugInManager import PlugInManager
3
from bmcore.BMUtil import BMUtil
4
from xml.dom import minidom
5
import os
6

    
7
class DepManCleanPlugIn(IPlugIn):
8
        def __init__(self):
9
                IPlugIn.__init__(self)
10
                self._delete_cache = False
11
                self._default_repository = ""
12

    
13
        def init(self):
14
                self.addGoal("clean", "Cleans dependency files")
15
                self.addGoalOption("clean","--all", "Cleans also cache files")
16
        
17
                isClean = False
18
                if self._arguments.read("clean"):
19
                        self.setExecute(True)
20
                        isClean = True
21

    
22
                if not isClean:
23
                        return        
24
                
25
                if self._arguments.read("--all"):
26
                        self._delete_cache = True        
27

    
28
        def initFromXML(self,node):
29
                if node.localName=="clean":
30
                        if node.hasAttributes():
31
                                if node.attributes.has_key("all"):
32
                                        value = node.attributes.get("all").value
33
                                        if value=="True" or value == "true":
34
                                                self._delete_cache = True
35

    
36
        def execute(self):
37
                print "Executing Plugin:" + str(self.__class__)
38
                return self.clean()
39

    
40
        def clean(self):
41
                self._dmplugin = PlugInManager().getPlugInInstance("DepManPlugIn")
42
                if self._dmplugin == None:
43
                        self.reportError("PlugIn `depman` not found")
44
                        self.setExecute(False)
45
                        return
46
                self._default_repository = self._dmplugin.getDepManPath()
47
                #the extra parameter "all" enables dmn to clear the cache directory
48
                print "* cleaning..."
49
                util = BMUtil()
50
                util.rmdir(self._default_repository+os.path.sep+"include")
51
                util.rmdir(self._default_repository+os.path.sep+"lib")
52
                util.rmdir(self._default_repository+os.path.sep+"bin")
53
                util.rmdir(self._default_repository+os.path.sep+"share")
54
                util.rmdir(self._default_repository+os.path.sep+"Frameworks")
55
                if self._delete_cache:
56
                        util.rmdir(self._default_repository+os.path.sep+".cache")
57
                return True
58
        
59
        def setDeleteCache(self,value):
60
                self._delete_cache = value
61
                
62
        def getDeleteCache(self):
63
                return self._delete_cache
64
        
65
        def setDefaultRepository(self,defrepo):
66
                self._default_repository = defrepo
67
                
68
        def getDefaultRepository(self):
69
                return self._default_repository
70

    
71

    
72
                
73

    
74
PlugInManager().registerPlugIn("DepManCleanPlugIn",DepManCleanPlugIn())
75

    
76