Revision 26254

View differences:

trunk/extensions/ext3Dgui/buildman/bin/bmplugins/SVNPlugIn.py
1
from bmbase.IPlugIn import IPlugIn
2
from bmbase.PlugInManager import PlugInManager
3
from bmcore.BMUtil import BMUtil
4
import os
5

  
6
class SVNPlugIn(IPlugIn):
7
	def __init__(self):
8
		IPlugIn.__init__(self)
9
		self._options = ['co','up', 'checkout', 'update']
10
		self._option = ""
11
		self._projectPath = ""
12
		self._svnUrl = ""
13
		
14

  
15
	def init(self):
16
		self.addGoal("svn", "This plugin is able to do checkout or update of a svn repository")
17
		self.addGoalOption("svn","--option", "sets the option of subversion: "+ str(self._options))
18
		self.addGoalOption("svn","--project-path", "sets the path of the project.")
19
		self.addGoalOption("svn","--url", "sets the path of the url")
20
		execute = False		
21
		while self._arguments.read("svn"):
22
			execute = True
23
		if execute:
24
			args = [""]
25
			while self._arguments.read("--option",args):
26
				self._option = args[0]
27

  
28
			args = [""]
29
			while self._arguments.read("--project-path",args):
30
				self._projectPath=args[0]
31
		
32
			args = [""]
33
			while self._arguments.read("--url",args):
34
				self._svnUrl=args[0]
35
				
36
			self.setExecute(True)
37
			
38
	def initFromXML(self,node):
39
		if node.localName=="svn":
40
			if node.hasAttributes():
41
				if node.attributes.has_key("option"):
42
					self._option = node.attributes.get("option").value
43
				if node.attributes.has_key("project-path"):
44
					self._projectPath = node.attributes.get("project-path").value
45
				if node.attributes.has_key("url"):
46
					self._svnUrl = node.attributes.get("url").value
47
										
48
	def execute(self):
49
		if self._option=="":
50
			self.reportError("Missing svn option, use one of " + str(self._options))
51
			return False
52
		if self._option not in self._options:
53
			self.reportError("not supported svn option, use one of " + str(self._options))
54
			return False
55
		if self._projectPath=="":
56
			self.reportError("Missing required project path option")
57
			return False
58
		if self._option == "co" or self._option == "checkout":
59
			if self._svnUrl == "":
60
				self.reportError("Missing required svn url ption")
61
				return False
62
			
63
		self._projectPath = os.path.abspath(self._projectPath)
64
		projectName = os.path.basename(self._projectPath)
65
		
66
		print "Executing Plugin:" + str(self.__class__)
67
		bmutil = BMUtil()
68
		svnCommand = "svn " + self._option
69
		if self._option in ['co', 'checkout']:
70
			svnCommand += " " + self._svnUrl + " " + self._projectPath
71
		else: 
72
			if self._option in ['up', 'update']:
73
				svnCommand += " " + self._projectPath
74
		os.system(svnCommand)
75
		return True
76
	
77
PlugInManager().registerPlugIn("SVNPlugIn",SVNPlugIn())
78

  
79

  
trunk/extensions/ext3Dgui/buildman/bin/bmplugins/DepManCleanPlugIn.py
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

  
trunk/extensions/ext3Dgui/buildman/bin/bmplugins/DepManUpdatePlugIn.py
1
#depman update plugin
2

  
3
from bmbase.IPlugIn import IPlugIn
4
from bmbase.PlugInManager import PlugInManager
5
from bmcore.BMUtil import BMUtil
6
import os
7

  
8

  
9
class DepManUpdatePlugIn(IPlugIn):
10
	
11
	def __init__(self):
12
		IPlugIn.__init__(self)
13
		
14
		self._must_Clean=True
15
		self._isFromCache=False
16
		self._isInteractive=True
17
		self._xmlfile="depman.xml"
18
		self._depmanNode = None
19
		
20
		self._defurl="http://murray.ai2.upv.es/depman"
21
		
22
	def init(self):
23
		self.addGoal("update", "Update current project")
24
		self.addGoalOption("update","--no-clean", "Do not perform a repository clean before update")
25
		self.addGoalOption("update","--cache", "Cache is preferred")
26
		self.addGoalOption("update","--remote", "Remote repository is preferred")
27
		self.addGoalOption("update","--file", "Specifies a dependency xml file")
28
				
29
		isUpdate = False
30
		if self._arguments.read("update"):
31
			self.setExecute(True)
32
			isUpdate = True
33

  
34
		if not isUpdate:
35
			return
36

  
37
		if self._arguments.read("--no-clean"):
38
			self._must_Clean = False
39
			
40
		if self._arguments.read("--cache"):
41
			self._isInteractive=False
42
			self._isFromCache = True
43
		
44
		if self._arguments.read("--remote"):
45
			self._isInteractive=False
46
			self._isFromCache = False
47
		
48
		args=[""]
49
		if self._arguments.read("--file",args):
50
			self._xmlfile=args[0]
51
		
52
	def initFromXML(self,node):
53
		if node.localName == "update":
54
			if node.hasAttributes():
55
				if node.attributes.has_key("file"):
56
					self.loadXMLFile(node.attributes.get("file").value)
57
				if node.attributes.has_key("no-clean"):
58
					value = node.attributes.get("no-clean").value
59
					if value == "True" or value == "true":
60
						self._must_Clean = True
61
				foundCache = False
62
				if node.attributes.has_key("cache"):
63
					value = node.attributes.get("cache").value
64
					if value == "True" or value == "true":
65
						self._isFromCache = True
66
				if node.attributes.has_key("remote") and not foundCache:
67
					value = node.attributes.get("remote").value
68
					if value == "True" or value == "true":
69
						self._isFromCache = False
70
			self._isInteractive = False
71
		else:	
72
			self._depmanNode = node
73
		
74
	def execute(self):
75
		print "Executing Plugin:" + str(self.__class__)
76
		return self.update()
77

  
78

  
79

  
80
	def update(self):
81
		
82
		if self._must_Clean:
83
			self._dmclean = PlugInManager().getPlugInInstance("DepManCleanPlugIn")
84
			if self._dmclean == None:
85
				self.reportError("PlugIn `depman clean` not found")
86
				return
87
			delete_cache = self._dmclean.getDeleteCache()
88
			self._dmclean.setDeleteCache(False)
89
			self._dmclean.clean()	
90
			self._dmclean.setDeleteCache(delete_cache)
91

  
92
		if self._depmanNode == None:
93
			self.loadXMLFile(self._xmlfile)
94
		unPackList = self.getDependencies(self._depmanNode)
95

  
96
		
97
		#once the xml is parsed and files downloaded, lets unpack them
98
		self.unpack(unPackList)
99
	
100
	def getDependencies(self,node):
101
		self._dmplugin = PlugInManager().getPlugInInstance("DepManPlugIn")
102
		if self._dmplugin == None:
103
			self.reportError("PlugIn `depman` not found")
104
			return
105
		
106
		self._dmget = PlugInManager().getPlugInInstance("DepManGetPlugIn")
107
		if self._dmget == None:
108
			self.reportError("PlugIn `depman get` not found")
109
			return
110
		
111
		group="none"
112
		artifact="none"
113
		version="0"
114
		platform="none"
115
		compiler="none"
116
		arch="none"
117
		ltype="none"
118
		
119
		#os default values
120
		defplatform=self._dmplugin.getOSPlatform()
121
		defarch=self._dmplugin.getOSArch()
122
		defcompiler=self._dmplugin.getOSCompiler()
123
		
124
		#hardcoded default url
125
		#defurl=default_url
126
		
127
		defurl=self._defurl
128
		
129
		unPackList = []
130
		if node.hasAttributes():
131
		    if node.attributes.has_key("url"):
132
		        defurl=node.attributes.get("url").value
133
		
134
		for i in node.childNodes:
135
		    if i.localName=="dependencies":
136
		        url=defurl
137
		        #os default values
138
		        defplatform=self._dmplugin._osplatform
139
		        defarch=self._dmplugin._osarch
140
		        defcompiler=self._dmplugin._oscompiler
141
		        
142
		        if i.hasAttributes():
143
		            if i.attributes.has_key("platform"):
144
		                defplatform=i.attributes.get("platform").value
145
		            if i.attributes.has_key("architecture"):
146
		                defarch=i.attributes.get("architecture").value
147
		            if i.attributes.has_key("compiler"):
148
		                defcompiler=i.attributes.get("compiler").value
149
		            if i.attributes.has_key("url"):
150
		                url=i.attributes.get("url").value
151
		        
152
		        list_of_platforms=defplatform.split(",")
153
		        #depedencies platform checking
154
		        #we just go on whenever host os or all matches
155
		        
156
		        if len(list_of_platforms)>0 and self._dmplugin.getOSPlatform() not in list_of_platforms and "all" not in list_of_platforms:
157
		            invalid_platform=True
158
		        else:
159
		            invalid_platform=False
160
		            defplatform=self._dmplugin.getOSPlatform()
161
		        
162
		        del list_of_platforms[:]
163
		        
164
		        #print "Url: ",url
165
		        if not invalid_platform:
166
		            for j in i.childNodes:
167
		                
168
		                if j.localName=="dependency":
169
		                    #set default values
170
		                    platform=defplatform
171
		                    arch=defarch
172
		                    compiler=defcompiler
173
		                    group="none"
174
		                    artifact="none"
175
		                    version="0"
176
		                    ltype="none"
177
		                    durl = url
178
		                    if j.hasAttributes():
179
		                        if j.attributes.has_key("url"):
180
		                            durl=j.attributes.get("url").value
181
		                    
182
		                    for h in j.childNodes:
183
		                        if h.localName=="group":
184
		                            group=h.childNodes[0].nodeValue
185
		                        if h.localName=="artifact":
186
		                            artifact=h.childNodes[0].nodeValue
187
		                        if h.localName=="version":
188
		                            version=h.childNodes[0].nodeValue
189
		                        if h.localName=="platform":
190
		                            platform=h.childNodes[0].nodeValue
191
		                        if h.localName=="compiler":
192
		                            compiler=h.childNodes[0].nodeValue
193
		                        if h.localName=="architecture":
194
		                            arch=h.childNodes[0].nodeValue
195
		                        if h.localName=="type":
196
		                            ltype=h.childNodes[0].nodeValue
197
		                    self._dmget.setURL(durl)
198
		                    self._dmget.setGroup(group)
199
		                    self._dmget.setArtifact(artifact)
200
		                    self._dmget.setVersion(version)
201
		                    self._dmget.setPlatform(platform)
202
		                    self._dmget.setCompiler(compiler)
203
		                    self._dmget.setArch(arch)
204
		                    self._dmget.setLibraryType(ltype)
205
		                    #prevents downloading of not matching platforms but overrided
206
		                    if not self._isInteractive:
207
		                        if self._isFromCache:
208
		                            self._dmget.setForceCache()
209
		                        else:
210
		                            self._dmget.setForceRemote()
211
		                    self._dmget.get(unPackList)
212
		return unPackList
213
	
214
	def unpack(self,unPackList):
215
		sep=os.path.sep
216
		dmutil = BMUtil()
217
		for file in unPackList:
218
			tmpstr=file[file.rfind(sep)+1:]
219
			print "* unpacking ",tmpstr
220
			dmutil.untargz(file,self._dmplugin.getDepManPath())
221
			
222
	def setForceCache(self):
223
		self._isFromCache = True
224
		self._isInteractive = False
225
		
226
	def setForceRemote(self):
227
		self._isFromCache = False
228
		self._isInteractive = False
229

  
230
		#after unpacking, the unpack list is freed
231
		
232
PlugInManager().registerPlugIn("DepManUpdatePlugIn",DepManUpdatePlugIn())
trunk/extensions/ext3Dgui/buildman/bin/bmplugins/DepManCreatePlugIn.py
1
#depman create plugin
2

  
3
from bmbase.IPlugIn import IPlugIn
4
from bmbase.PlugInManager import PlugInManager
5
from bmcore.BMUtil import BMUtil
6
from xml.dom import minidom
7
import string
8
import shutil
9
import os
10
import sys
11
import subprocess
12

  
13
class DepManCreatePlugIn(IPlugIn):
14
	
15
	def __init__(self):
16
		IPlugIn.__init__(self)
17
		
18
		self._path="."
19
		self._group=""
20
		self._artifact=""
21
		self._version=""
22
		self._platform="default"
23
		self._arch="default"
24
		self._compiler="default"
25
		self._ltype=""
26
		self._upload=False
27
		self._is_Interactive=True
28
		self._xmlfile = ""
29
		self._packageNode = None
30
		
31
		self._default_ssh="murray.ai2.upv.es"
32
		self._default_login="depman"
33
		self._default_destdir = "/projects/AI2/www-aliases/depman/"
34
		
35
		
36
	def init(self):
37
		self.addGoal("create", "Create an artifact")
38
		self.addGoalOption("create","--path", "Specifies source directory")
39
		self.addGoalOption("create","--group", "Specifies artifact group name")
40
		self.addGoalOption("create","--artifact", "Specifies artifact name")
41
		self.addGoalOption("create","--version", "Specifies artifact version")
42
		self.addGoalOption("create","--platform", "Specifies artifact OS platform")
43
		self.addGoalOption("create","--arch", "Specifies artifact hardware architecture")
44
		self.addGoalOption("create","--compiler", "Specifies artifact compiler version")
45
		self.addGoalOption("create","--ltype", "Specifies library type if needed")
46
		self.addGoalOption("create","--upload", "Whenever the artifact must be uploaded or not")
47
		self.addGoalOption("create","--from-xml", "Uses the given depman.xml file to create the package")
48
		
49
		isCreate = False
50
		if self._arguments.read("create"):
51
			self.setExecute(True)
52
			isCreate = True
53

  
54
		if not isCreate:
55
			return
56

  
57
		args=[""]
58
		use_xml=False
59
		if self._arguments.read("--from-xml",args):
60
			self._xmlfile=args[0]
61
			use_xml=True
62
			
63
		if use_xml:
64
			self.loadXMLFile(self._xmlfile)
65
			
66
			
67
		args=[""]
68
		if self._arguments.read("--path",args):
69
			self._path=args[0]
70
		
71
		args=[""]
72
		if self._arguments.read("--group",args):
73
			self._group=args[0]
74
			self._is_Interactive=False
75
			
76
		args=[""]
77
		if self._arguments.read("--artifact",args):
78
			self._artifact=args[0]
79
			self._is_Interactive=False	
80
			
81
		args=[""]
82
		if self._arguments.read("--version",args):
83
			self._version=args[0]
84
			self._is_Interactive=False	
85
			
86
			
87
		args=[""]
88
		if self._arguments.read("--platform",args):
89
			self._platform=args[0]
90
			self._is_Interactive=False	
91
		
92
		args=[""]
93
		if self._arguments.read("--arch",args):
94
			self._arch=args[0]
95
			self._is_Interactive=False
96

  
97
		args=[""]
98
		if self._arguments.read("--compiler",args):
99
			self._compiler=args[0]
100
			self._is_Interactive=False
101
			
102
		args=[""]
103
		if self._arguments.read("--ltype",args):
104
			self._ltype=args[0]
105
			self._is_Interactive=False	
106
			
107
		if self._arguments.read("--upload"):
108
			self._upload=True	
109

  
110

  
111
	def initFromXML(self,node):
112
		if node.localName == "create":
113
			if node.hasAttributes():
114
				if node.attributes.has_key("from-xml"):
115
					self._xmlfile=node.attributes.get("from-xml").value
116
					self.loadXMLFile(self._xmlfile)
117
				if node.attributes.has_key("path"):
118
					self._path = node.attributes.get("path").value
119
				if node.attributes.has_key("upload"):
120
					value = node.attributes.get("upload").value
121
					if value =="True" or value =="true":
122
						self._upload = True
123

  
124
		else:
125
			if node.localName == "depman":
126
				self._packageNode = node
127
				self._is_Interactive=False
128
		
129
	def execute(self):
130
		print "Executing Plugin:" + str(self.__class__)
131
		return self.create()
132
	
133
	def create(self):
134
		
135
		self._dmplugin = PlugInManager().getPlugInInstance("DepManPlugIn")
136
		if self._dmplugin == None:
137
			self.reportError("PlugIn `depman` not found")
138
			return False
139
		
140
		#user questions
141
		if self._is_Interactive:
142
			self._group=raw_input("Group: ")
143
			
144
			self._artifact=raw_input("Artifact: ")
145
			
146
			self._version=raw_input("Version: ")
147
			
148
			tmpstr=""
149
			for p in self._dmplugin.getSupportedPlatforms():
150
				tmpstr=tmpstr+p+" "
151
			print "( ",tmpstr,")"
152
			tmstr="Platform [*]:"
153
			self._platform=raw_input(string.replace(tmstr,"*",self._dmplugin.getOSPlatform()))
154
			if len(self._platform)==0:
155
				self._platform=self._dmplugin.getOSPlatform()
156
			
157
			tmpstr=""
158
			for p in self._dmplugin.getSupportedCompilers():
159
				tmpstr=tmpstr+p+" "
160
			print "( ",tmpstr,")"
161
			tmstr="Compiler [*]:"
162
			self._compiler=raw_input(string.replace(tmstr,"*",self._dmplugin.getOSCompiler()))
163
			if len(self._compiler)==0:
164
				self._compiler=self._dmplugin.getOSCompiler()
165
				
166
			tmpstr=""
167
			for p in self._dmplugin.getSupportedArchs():
168
				tmpstr=tmpstr+p+" "
169
			print "( ",tmpstr,")"
170
			tmstr="Architecture [*]:"
171
			self._arch=raw_input(string.replace(tmstr,"*",self._dmplugin.getOSArch()))
172
			if len(self._arch)==0:
173
				self._arch=self._dmplugin.getOSArch()
174
			
175
			tmpstr=""
176
			for p in self._dmplugin.getSupportedLibraryTypes():
177
				tmpstr=tmpstr+p+" "
178
			print "( ",tmpstr,")"
179
			self._ltype=raw_input("Library Type: ")
180
			
181
			upload_response = raw_input("Upload to server? (y/n): ")
182
			if upload_response == "y" or upload_response == "yes":
183
				self._upload=True
184
		
185
		if self._packageNode != None:
186
			for n in self._packageNode.childNodes:
187
				if n.localName=="package":
188
					processPackage = True
189
					if n.hasAttributes():
190
						if n.attributes.has_key("platform"):
191
							values = n.attributes.get("platform").value.split(",")
192
							if self._dmplugin.getOSPlatform() in values:
193
								processPackage = True
194
							else:
195
								processPackage = False
196
					if processPackage:
197
						print "Processing for platform..."
198
						for p in n.childNodes:
199
							if p.localName=="group":
200
								self._group=p.childNodes[0].nodeValue
201
							if p.localName=="artifact":
202
								self._artifact=p.childNodes[0].nodeValue
203
							if p.localName=="version":
204
								self._version=p.childNodes[0].nodeValue
205
							if p.localName=="platform":
206
								self._platform=p.childNodes[0].nodeValue
207
							if p.localName=="compiler":
208
								self._compiler=p.childNodes[0].nodeValue
209
							if p.localName=="arch":
210
								self._arch=p.childNodes[0].nodeValue
211
							if p.localName=="libraryType":
212
								self._ltype=p.childNodes[0].nodeValue
213
							
214
							if p.localName =="upload":
215
								#TODO: Maybe upload should be an external plugin
216
								for k in p.childNodes:
217
									if k.localName == "sshserver":
218
										self._default_ssh = k.childNodes[0].nodeValue
219
									if k.localName == "destdir":
220
										self._default_destdir = k.childNodes[0].nodeValue
221
									if k.localName == "username":
222
										self._default_login = k.childNodes[0].nodeValue
223
						
224
		if self._group == "":
225
			self.reportError("Group cannot be empty")
226
			return False
227
		if self._artifact == "":
228
			self.reportError("Artifact cannot be empty")
229
			return False
230
		if self._version == "":
231
			self.reportError("Version cannog be empty")
232
			return 
233
		self._group=self._group.replace(".","/")
234
		if self._platform=="default":
235
			self._platform=self._dmplugin.getOSPlatform()
236
		if self._compiler=="default":
237
			self._compiler=self._dmplugin.getOSCompiler()
238
		if self._arch=="default":
239
			self._arch=self._dmplugin.getOSArch()
240
			
241
		
242
		#let's check user input consistency
243
		
244
		if self._platform not in self._dmplugin.getSupportedPlatforms():
245
			self.reportError("Platform not supported: " + self._platform + ". Supported platforms:" + str(self._dmplugin.getSupportedPlatforms()))
246
			return False
247
		
248
		if self._compiler not in self._dmplugin.getSupportedCompilers():
249
			self.reportError("Compiler not supported: " + self._compiler + ". Supported compilers:" +str(self._dmplugin.getSupportedCompilers()))
250
			return False
251
		
252
		if self._arch not in self._dmplugin.getSupportedArchs():
253
			self.reportError("Architecture not supported: " + self._arch + ". Supported archs:" +str(self._dmplugin.getSupportedArchs()))
254
			return False
255
		
256
		if self._ltype not in self._dmplugin.getSupportedLibraryTypes():
257
			self.reportError("Library type not supported: " + self._ltype + ". Supported libraries:" +str(self._dmplugin.getSupportedLibraryTypes()))
258
			return False
259
		
260
		#artifact and md5 generation
261
		
262
		file_name=self._artifact+"-"+self._version+"-"+self._platform+"-"+self._compiler+"-"+self._arch+"-"+self._ltype
263
		
264
		
265
		tarname=file_name+".tar.gz"
266
		md5name=tarname+".md5"
267
		dmfile=file_name+".xml"
268
		
269
		dmutil = BMUtil()
270
		
271
		tmpdir=self._dmplugin.getDepManPath()+os.path.sep+".cache"+os.path.sep+self._group+os.path.sep+self._artifact+os.path.sep+self._version+os.path.sep+self._platform+os.path.sep+self._compiler+os.path.sep+self._arch+os.path.sep+self._ltype
272
		
273
		dmutil.mkdir(tmpdir)
274
		print tmpdir+os.path.sep+tarname,self._path
275
		dmutil.targz(os.path.join(tmpdir,tarname),self._path)
276
		#print "targz ",tmpdir+os.path.sep+tarname
277
		dmutil.createMD5(tmpdir+os.path.sep+tarname,tmpdir+os.path.sep+md5name)
278
		if self._xmlfile != "":
279
			shutil.copyfile(self._xmlfile,tmpdir+os.path.sep+dmfile)	
280
		print "Artifact " + tarname + " created in:\n" + tmpdir
281
		
282
		if self._upload:
283
			dmutil.rmdir(".dmn_tmp") # Prevent for uploading bad previous compilations!
284
			sshtmpdir=".dmn_tmp"+os.path.sep+self._group+os.path.sep+self._artifact+os.path.sep+self._version+os.path.sep+self._platform+os.path.sep+self._compiler+os.path.sep+self._arch+os.path.sep+self._ltype
285
			dmutil.mkdir(sshtmpdir)
286
			shutil.copyfile(tmpdir+os.path.sep+tarname,sshtmpdir+os.path.sep+tarname)
287
			shutil.copyfile(tmpdir+os.path.sep+md5name,sshtmpdir+os.path.sep+md5name)
288
			if self._xmlfile != "":
289
				shutil.copyfile(tmpdir+os.path.sep+dmfile,sshtmpdir+os.path.sep+dmfile)	
290
			url = self._default_ssh;
291
			destdir = self._default_destdir
292
			login = self._default_login
293
			
294
			if self._is_Interactive:
295
				tmstr="SSH Server [*]:"
296
				url=raw_input(string.replace(tmstr,"*",self._default_ssh))
297
				if len(url)==0:
298
					url=self._default_ssh
299
				
300
				tmstr="Destination Directory [*]:"
301
				destdir=raw_input(string.replace(tmstr,"*",self._default_destdir))
302
				if len(destdir)==0:
303
					destdir=self._default_destdir
304
			
305
				tmstr="Login [*]:"
306
				login=raw_input(string.replace(tmstr,"*",self._default_login))
307
				if len(login)==0:
308
					login=self._default_login
309
			
310
			download_dir = self._group+"/"+self._artifact+"/"+self._version+"/"+self._platform+"/"+self._compiler+"/"+self._arch+"/"+self._ltype
311
			
312
			print "* Uploading ",tarname
313
			print "* Uploading ",md5name
314
			
315
			#scp
316
			base_ssh=destdir
317
			url_ssh=url
318
			scpcommand = "scp"
319
			pscppath = ""
320
			if sys.platform == "win32":
321
				scpcommand=self._dmplugin.getDepManDataPath()+os.path.sep+"win32"+os.path.sep+"pscp.exe"
322
				scpcommand  = '"'+os.path.normpath(scpcommand)+'"'
323
			cmdstr=scpcommand +" -r "+".dmn_tmp"+os.path.sep+"*"+" "+login+"@"+url_ssh+":"+base_ssh
324
			
325
			print cmdstr
326
			os.system(cmdstr)
327
			
328
			#scp
329
			
330
			dmutil.rmdir(".dmn_tmp")
331
			
332
				
333

  
334

  
335

  
336
PlugInManager().registerPlugIn("DepManCreatePlugIn",DepManCreatePlugIn())		
trunk/extensions/ext3Dgui/buildman/bin/bmplugins/BuildManPlugIn.py
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 BuildManPlugIn(IPlugIn):
8
	def __init__(self):
9
		IPlugIn.__init__(self)
10
		self.reset()
11
	
12
	def getFile(self):
13
		return self._file
14
	
15
	def getGoalList(self):
16
		return self._goalList
17
	
18
	def reset(self):
19
		self._goalList = []
20
		self._file = "buildman.xml"
21

  
22
	def init(self):
23
		self.addGoal("buildman", "executes goals from a buildman file")
24
		self.addGoalOption("buildman","--file", "Sets the file to execute, otherwise search for buildman.xml")
25
		
26
		self._dmplugin = PlugInManager().getPlugInInstance("DepManPlugIn")
27
		if self._dmplugin == None:
28
			self.reportError("PlugIn `depman` not found")
29
			return
30
		isBuildMan = False
31
		while self._arguments.read("buildman"):
32
			self.setExecute(True)
33
			isBuildMan = True
34

  
35
		if not isBuildMan:
36
			return	
37
		
38
		args=[""]
39
		while self._arguments.read("--file",args):
40
			self._file = args[0]	
41

  
42
	def initFromXML(self,node):	
43
		if node.localName=="buildman":
44
				for g in node.childNodes:
45
					if g.localName == "goals":
46
						addGoals = False
47
						if g.hasAttributes():
48
							if g.attributes.has_key("platform"):
49
								value = g.attributes.get("platform").value
50
								platforms = value.split(",")
51
								for platform in platforms:
52
									if platform == self._dmplugin.getOSPlatform():
53
										addGoals = True
54
						else:
55
							addGoals = True
56
						if addGoals:
57
							for goalNode in g.childNodes:
58
								#print goalNode.localName, " in ", PlugInManager().supportedGoals(), "?"
59
								if goalNode.localName=="buildman":
60
									if goalNode.hasAttributes():
61
										if goalNode.attributes.has_key("file"):
62
											self.loadXMLFile(goalNode.attributes.get("file").value)
63
								else:
64
									if goalNode.localName in PlugInManager().supportedGoals():
65
										self._goalList.append(goalNode)
66

  
67
	def execute(self):
68
		print "Executing Plugin:" + str(self.__class__)
69
		return self.buildman()
70

  
71
	def buildman(self):
72
		self.loadXMLFile(self._file)
73
		for goal in self._goalList:
74
			plugin = PlugInManager().getPlugInInstanceByGoal(goal.localName)
75
			plugin.initFromXML(goal)
76
			plugin.execute()
77
			if plugin.error():
78
				for error in plugin.getErrorMessages():
79
					self.reportError(error)
80
				return False
81
		return True
82

  
83

  
84
PlugInManager().registerPlugIn("BuildManPlugIn",BuildManPlugIn())	
85
		
trunk/extensions/ext3Dgui/buildman/bin/bmplugins/TestPlugIn.py_
1
from bmbase.IPlugIn import IPlugIn
2
from bmbase.PlugInManager import PlugInManager
3
import pprint
4

  
5

  
6
class TestPlugIn(IPlugIn):
7
	def __init__(self):
8
		IPlugIn.__init__(self)
9

  
10
	def init(self):
11
		self.addGoal("test", "Tests user buildman plugin path")
12
		while self._arguments.read("test"):
13
			self.setExecute(True)		
14

  
15
	def execute(self):
16
		print "Executing Plugin:" + str(self.__class__)
17
		l=[] 
18
		for id,plugin in PlugInManager().getPlugInInstances().items():
19
			l.append((id,plugin))	
20
		pp = pprint.PrettyPrinter(indent=4)
21
		pp.pprint(l) 
22
		return True
23

  
24
PlugInManager().registerPlugIn("TestPlugIn",TestPlugIn())
25

  
26

  
trunk/extensions/ext3Dgui/buildman/bin/bmplugins/DepManExtractPlugIn.py
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 DepManExtractPlugIn(IPlugIn):
8
    def __init__(self):
9
        IPlugIn.__init__(self)
10
        self._xmlFile = "depman.xml"
11
        self._destDir = "."
12
        self._filter = "*"
13
        self._isFromCache=False
14
        self._isInteractive=True
15
        self._depmanNode = None
16

  
17
    def init(self):
18
        self.addGoal("extract", "Extract the files of dependencies and package sections of a depman xml file.")
19
        self.addGoalOption("extract","--file", "Sets an alternate xml file. Default: depman.xml")
20
        self.addGoalOption("extract","--destdir", "Sets the destination directory of the extraction. Default: `.`")
21
        self.addGoalOption("extract","--filter", "Sets the the filter of the files to extract. Default: `*`")
22
        self.addGoalOption("extract","--cache", "Cache is preferred")
23
        self.addGoalOption("extract","--remote", "Remote repository is preferred")
24
    
25
        isExtract = False
26
        if self._arguments.read("extract"):
27
            self.setExecute(True)
28
            isExtract = True
29

  
30
        if not isExtract:
31
            return    
32
        
33
        args = [""]
34
        if self._arguments.read("--file", args):
35
            self._xmlFile = args[0]   
36
            
37
        args = [""]
38
        if self._arguments.read("--destdir", args):
39
            self._destDir = args[0]
40
            
41
        args = [""]
42
        if self._arguments.read("--filter", args):
43
            self._filter = args[0] 
44
            
45
        if self._arguments.read("--cache"):
46
            self._isFromCache = True
47
            self._isInteractive = False
48
        
49
        if self._arguments.read("--remote"):
50
            self._isFromCache = False
51
            self._isInteractive = False
52

  
53
    def initFromXML(self,node):
54
        if node.localName=="extract":
55
            if node.hasAttributes():
56
                if node.attributes.has_key("file"):
57
                    elf._xmlFile = node.attributes.get("file").value
58
                if node.attributes.has_key("destdir"):
59
                    elf._destDir = node.attributes.get("destdir").value                   
60
                if node.attributes.has_key("filter"):
61
                    elf._filter = node.attributes.get("filter").value    
62
                foundCache = False
63
                if node.attributes.has_key("cache"):
64
                    value = node.attributes.get("cache").value
65
                    if value == "True" or value == "true":
66
                        self._isFromCache = True
67
                        self._isInteractive = False
68
                if node.attributes.has_key("remote") and not foundCache:
69
                    value = node.attributes.get("remote").value
70
                    if value == "True" or value == "true":
71
                        self._isFromCache = False
72
                        self._isInteractive = False
73
        else:
74
            self._depmanNode = node
75
                    
76
    def execute(self):
77
        print "Executing Plugin:" + str(self.__class__)
78
        return self.extract()
79

  
80
    def extract(self):
81
        self._dmupdate = PlugInManager().getPlugInInstance("DepManUpdatePlugIn")
82
        if self._dmupdate == None:
83
            self.reportError("PlugIn `depman update` not found")
84
            return
85
        
86
        if self._depmanNode == None:
87
            self.loadXMLFile(self._xmlFile)
88
        
89
        if not self._isInteractive:
90
            if self._isFromCache:
91
                self._dmupdate.setForceCache()
92
            else:
93
                self._dmupdate.setForceRemote()
94
                
95
        dependency_filenamepaths = self._dmupdate.getDependencies(self._depmanNode)
96
        package_namepath = self.parsePackage(self._depmanNode)
97
        print dependency_filenamepaths, self._destDir, self._filter
98
        
99
        bmutil = BMUtil()
100
        for file in dependency_filenamepaths:
101
            bmutil.untargzFiltered(file, self._destDir, self._filter)
102
        
103
    
104
    def parsePackage(self,node):
105
        return ""
106

  
107

  
108
PlugInManager().registerPlugIn("DepManExtractPlugIn",DepManExtractPlugIn())
109

  
110

  
trunk/extensions/ext3Dgui/buildman/bin/bmplugins/CreateSolutionPlugIn.py
1
from bmbase.IPlugIn import IPlugIn
2
from bmbase.PlugInManager import PlugInManager
3
from bmcore.BMUtil import BMUtil
4
import os
5

  
6
class CreateSolutionPlugIn(IPlugIn):
7
	def __init__(self):
8
		IPlugIn.__init__(self)
9
		self._buildType = "Release"
10
		self._supportedGenerators = dict()
11
		self._supportedGenerators["vs8"] = "Visual Studio 8 2005"
12
		self._supportedGenerators["vs7"] = "Visual Studio 7 .NET 2003"
13
		self._supportedGenerators["unix"] = "Unix Makefiles"
14
		self._supportedGenerators["xcode"] = "Xcode"
15
		self._cmakeGenerator = ""
16
		self._projectPath = ""
17
		self._projectGenerationPath = ""
18
		self._installPath = ""
19
		self._cmakeOtherOptions = ""
20
		
21

  
22
	def init(self):
23
		self.addGoal("create-solution", "Creates the solution Makefiles/VisualStudio for Win/Linux/Mac based on CMake")
24
		self.addGoalOption("create-solution","--build-type", "sets the build path (Release/Debug). default=Release.")
25
		self.addGoalOption("create-solution","--generator", "selects the generator (vs8,vs7,unix,xcode).")
26
		self.addGoalOption("create-solution","--project-path", "sets the path of the project.")
27
		self.addGoalOption("create-solution","--project-gen-path", "sets the path to generate project files. default=${project-path}/CMake")
28
		self.addGoalOption("create-solution","--install", "sets the path to generate the product installation. default=${project-path}/../install")
29
		self.addGoalOption("create-solution","--cmake-options", "Adds other cmake command line options.")
30
		execute = False		
31
		if self._arguments.read("create-solution"):
32
			execute = True
33
		if execute:
34
			args = [""]
35
			if self._arguments.read("--build-type",args):
36
				self._buildType = args[0]
37
		
38
			args = [""]
39
			if self._arguments.read("--generator",args):
40
				if args[0] in self._supportedGenerators:
41
					self._cmakeGenerator = self._supportedGenerators[args[0]]
42

  
43
			args = [""]
44
			if self._arguments.read("--project-path",args):
45
				self._projectPath=args[0]
46
		
47
			args = [""]
48
			if self._arguments.read("--project-gen-path",args):
49
				self._projectGenerationPath=args[0]
50
	
51
			args = [""]
52
			if self._arguments.read("--install",args):
53
				self._installPath=args[0]
54
				
55
			args = [""]
56
			if self._arguments.read("--cmake-options",args):
57
				self._cmakeOtherOptions=args[0]
58
				
59
			self.setExecute(True)
60
			
61
	def initFromXML(self,node):
62
		if node.localName=="create-solution":
63
			if node.hasAttributes():
64
				if node.attributes.has_key("build-type"):
65
					self._buildType = node.attributes.get("build-type").value
66
				if node.attributes.has_key("generator"):
67
					gen = node.attributes.get("generator").value
68
					if gen in self._supportedGenerators:
69
						self._cmakeGenerator = self._supportedGenerators[gen]
70
				if node.attributes.has_key("project-path"):
71
					self._projectPath = node.attributes.get("project-path").value
72
				if node.attributes.has_key("project-gen-path"):
73
					self._projectGenerationPath = os.path.abspath(node.attributes.get("project-gen-path").value)
74
				if node.attributes.has_key("install"):
75
					self._installPath = os.path.abspath(node.attributes.get("install").value)
76
				if node.attributes.has_key("cmake-options"):
77
					self._cmakeOtherOptions = node.attributes.get("cmake-options").value
78
										
79
	def execute(self):
80
		if self._cmakeGenerator=="":
81
			self.reportError("Missing valid generator option")
82
			return False
83
		if self._projectPath=="":
84
			self.reportError("Missing required project path option")
85
			return False
86
			
87
		if self._cmakeGenerator!="" and self._projectPath!="":
88
			self._projectPath = os.path.abspath(self._projectPath)
89
			projectName = os.path.basename(self._projectPath)
90
			if self._projectGenerationPath=="":
91
				self._projectGenerationPath=os.path.abspath(os.path.join(self._projectPath,"BMCMake"))
92
			if self._installPath=="":
93
				self._installPath=os.path.abspath(self._projectPath+os.path.sep+".."+os.path.sep+projectName+"-install")
94
			if self._buildType=="":
95
				self._buildType="Release"
96
				
97
		print "Executing Plugin:" + str(self.__class__)
98
		bmutil = BMUtil()
99
		print " * Creating Project Generation Path: "+self._projectGenerationPath
100
		bmutil.mkdir(self._projectGenerationPath)
101
		olddir = os.getcwd()
102
		os.chdir(self._projectGenerationPath)
103
		if os.path.exists("CMakeCache.txt"):
104
			os.remove("CMakeCache.txt")
105
		cmakeCommand = "cmake "+self._cmakeOtherOptions+" -G\""+self._cmakeGenerator+"\" -DCMAKE_BUILD_TYPE="+self._buildType+" -DCMAKE_INSTALL_PREFIX="+self._installPath+" "+self._projectPath 
106
		print " * Running CMAKE: " + cmakeCommand
107
		os.system(cmakeCommand)
108
		os.chdir(olddir)
109
		return True
110

  
111
PlugInManager().registerPlugIn("CreateSolutionPlugIn",CreateSolutionPlugIn())
112

  
113

  
trunk/extensions/ext3Dgui/buildman/bin/bmplugins/__init__.py
1
"""
2
	Path where plugins reside
3
	Each plugin should implement IPlugIn interface
4
	from bmbase.
5
"""
6

  
7

  
8

  
9
import os
10
import sys
11
from bmcore.BMUtil import BMUtil
12
import imp
13

  
14
def bmimport(name, paths):
15
	# Fast path: see if the module has already been imported.
16
    try:
17
        return sys.modules[name]
18
    except KeyError:
19
        pass
20

  
21
    # If any of the following calls raises an exception,
22
    # there's a problem we can't handle -- let the caller handle it.
23

  
24
    fp, pathname, description = imp.find_module(name,paths)
25

  
26
    try:
27
        return imp.load_module(name, fp, pathname, description)
28
    finally:
29
        # Since we may exit via an exception, close fp explicitly.
30
        if fp:
31
            fp.close()
32

  
33
util = BMUtil()
34
searchPaths=[os.path.join(sys.path[0],'bmplugins'),util.buildmanPlugInPath(),os.path.join(sys.path[0],'../bmplugins')]
35

  
36
plugList = []
37
for dir in searchPaths:
38
	if not os.path.exists(dir):
39
		continue
40
	for f in os.listdir(dir):
41
		if f.endswith('.py') and not f.startswith('__init__'):
42
			plugList.append(f[0:-3])
43

  
44
print plugList
45
for m in plugList:
46
	bmimport(m,searchPaths)
47

  
trunk/extensions/ext3Dgui/buildman/bin/bmplugins/DeleteFilePlugIn.py
1
from bmbase.IPlugIn import IPlugIn
2
from bmbase.PlugInManager import PlugInManager
3
from bmcore.BMUtil import BMUtil
4
import os
5
import sys
6
import shutil
7

  
8
class DeleteFilePlugIn(IPlugIn):
9
	def __init__(self):
10
		IPlugIn.__init__(self)
11
		self._path = ""
12

  
13
	def init(self):
14
		self.addGoal("delete", "deletes a file or directory")
15
		self.addGoalOption("delete", "--path", "Sets the file/path to be deleted")
16
		execute = False
17
		while self._arguments.read("delete"):
18
			execute = True
19
			
20
		if execute:
21
			args = [""]
22
			while self._arguments.read("--path",args):
23
				self._path = args[0]
24
			
25
			self.setExecute(True)
26
			
27
	def initFromXML(self,node):
28
		if node.localName=="delete":
29
			if node.hasAttributes():
30
				if node.attributes.has_key("path"):
31
					self._path = node.attributes.get("path").value
32
						
33
	def execute(self):
34
		print "Executing Plugin:" + str(self.__class__)
35
		if self._path == "":
36
			self.reportError("Missing required path option")
37
			
38
		self._path = os.path.abspath(self._path)
39
		util = BMUtil()
40
		if not os.path.exists(self._path):
41
			return True
42
		if os.path.isdir(self._path):
43
			print "* Removing directory " + self._path
44
			util.rmdir(self._path)
45
		else:
46
			print "* Removing file " + self._path
47
			os.remove(self._path)
48
			
49
		return True
50

  
51
PlugInManager().registerPlugIn("DeleteFilePlugIn",DeleteFilePlugIn())
52

  
53

  
trunk/extensions/ext3Dgui/buildman/bin/bmplugins/PrepareSystemPlugIn.py
1
from bmbase.IPlugIn import IPlugIn
2
from bmbase.PlugInManager import PlugInManager
3
from bmcore.BMUtil import BMUtil
4
import os
5
import sys
6
import shutil
7

  
8
class PrepareSystemPlugIn(IPlugIn):
9
	def __init__(self):
10
		IPlugIn.__init__(self)
11

  
12
	def init(self):
13
		self.addGoal("init", "Prepares the system with the buildman user directory with an example plugin")
14
		while self._arguments.read("init"):
15
			self.setExecute(True)			
16

  
17
	def execute(self):
18
		print "Executing Plugin:" + str(self.__class__) + "\n"
19
		util = BMUtil()
20
		bmpath = util.buildmanPlugInPath()
21
		try:
22
			util.mkdir(bmpath)		
23
			#shutil.copy(sys.path[0]+os.path.sep+"bmplugins"+os.path.sep+"TestPlugIn.py_",util.buildmanPlugInPath()+os.path.sep+"TestPlugIn.py")
24
		except:
25
			self.reportError("Error creating buildman directory or copying test plugin")
26
			return False
27
		return True
28

  
29
PlugInManager().registerPlugIn("PrepareSystemPlugIn",PrepareSystemPlugIn())
30

  
31

  
trunk/extensions/ext3Dgui/buildman/bin/bmplugins/DepManGetPlugIn.py
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 DepManGetPlugIn(IPlugIn):
8
	def __init__(self):
9
		IPlugIn.__init__(self)
10
		self._default_repository = ""
11
		self._url = ""
12
		self._group = ""
13
		self._artifact = ""
14
		self._version = ""
15
		self._platform = ""
16
		self._artifact = ""
17
		self._compiler = ""
18
		self._arch = ""
19
		self._ltype = ""
20
		self._forceCache = False
21
		self._isInteractive = True
22
		
23
	def setURL(self,url):
24
		self._url = url
25

  
26
	def setGroup(self,group):
27
		self._group = group
28

  
29
	def setArtifact(self,artifact):
30
		self._artifact = artifact		
31
	
32
	def setVersion(self,version):
33
		self._version = version
34
	
35
	def setPlatform(self,platform):
36
		self._platform = platform
37

  
38
	def setCompiler(self,compiler):
39
		self._compiler = compiler
40

  
41
	def setArch(self,arch):
42
		self._arch = arch
43

  
44
	def setLibraryType(self,ltype):
45
		self._ltype = ltype
46

  
47
	def setForceCache(self):
48
		self._forceCache = True
49
		self._isInteractive = False
50

  
51
	def setForceRemote(self):
52
		self._forceCache = False
53
		self._isInteractive = False
54
	
55
	def init(self):
56
		self.addGoal("get", "downloads an artifact if not in cache.")
57
		self.addGoalOption("get","--url", "URL base for the DepMan repository.")
58
		self.addGoalOption("get","--group", "Group namespace of the artifact.")
59
		self.addGoalOption("get","--artifact", "Name of the artifact to download.")
60
		self.addGoalOption("get","--version", "Version of the artifact.")
61
		self.addGoalOption("get","--platform", "Platform of the artifact.")
62
		self.addGoalOption("get","--compiler", "Selects the compiler version that was used to compile the artifact.")
63
		self.addGoalOption("get","--arch", "Selects the architecture of the artifact.")
64
		self.addGoalOption("get","--ltype", "Type of library of the artifact.")
65
		self.addGoalOption("get","--cache", "Forces the use of cache files without asking.")
66
		self.addGoalOption("get","--remote", "Forces the download of remote without the use of the cache and without asking.")
67

  
68
		self._dmplugin = PlugInManager().getPlugInInstance("DepManPlugIn")
69
		if self._dmplugin == None:
70
			self.reportError("PlugIn `depman` not found")
71
			return
72
		self._default_repository = self._dmplugin.getDepManPath()
73
	
74
		isGet = False
75
		while self._arguments.read("get"):
76
			isGet = True
77
		
78
		if not isGet:
79
			return
80

  
81
		args=[""]
82
		if self._arguments.read("--url",args):
83
			self._url = args[0]
84

  
85
		args=[""]
86
		if self._arguments.read("--group",args):
87
			self._group = args[0]
88

  
89
		args=[""]
90
		if self._arguments.read("--artifact",args):
91
			self._artifact = args[0]
92

  
93
		args=[""]
94
		if self._arguments.read("--version",args):
95
			self._version = args[0]
96

  
97
		args=[""]
98
		if self._arguments.read("--platform",args):
99
			self._platform = args[0]
100

  
101
		args=[""]
102
		if self._arguments.read("--compiler",args):
103
			self._compiler = args[0]
104

  
105
		args=[""]
106
		if self._arguments.read("--arch",args):
107
			self._arch = args[0]
108

  
109
		args=[""]
110
		if self._arguments.read("--ltype",args):
111
			self._ltype = args[0]
112

  
113
		if self._arguments.read("--cache"):
114
			self._forceCache = True
115
			self._isInteractive = False
116

  
117
		if self._arguments.read("--remote"):
118
			self._forceCache = False
119
			self._isInteractive = False
120
	
121
		self.setExecute(True)
122
	
123

  
124
	def initFromXML(self,node):
125
		pass
126
		#TODO: . . .
127

  
128
	def execute(self):
129
		print "Executing Plugin:" + str(self.__class__)
130
		if self._url == "":
131
			self.reportError("Missing url option")
132
			return
133
		if self._artifact == "":
134
			self.reportError("Missing artifact option")
135
			return
136
		if self._group == "":
137
			self.reportError("Missing group option")
138
			return
139
		if self._version == "":
140
			self.reportError("Missing version option")
141
			return
142
		if self._platform == "":
143
			self.reportError("Missing platform option")
144
			return
145
		if self._compiler == "":
146
			self.reportError("Missing compiler option")
147
			return
148
		if self._arch == "":
149
			self.reportError("Missing artifact option")
150
			return
151
		if self._ltype == "":
152
			self.reportError("Missing library type option")
153
			return
154

  
155
	
156
		if self._platform not in self._dmplugin.getSupportedPlatforms():
157
			self.reportError("* Platform not supported: " + self._platform)
158
			return
159
	
160
		if self._compiler not in self._dmplugin.getSupportedCompilers():
161
			self.reportError("* Compiler not supported: "+ self._compiler)
162
			return
163
	
164
		if self._arch not in self._dmplugin.getSupportedArchs():
165
			self.reportError("* Architecture not supported: "+ self._arch)
166
			return
167
	
168
		if self._ltype not in self._dmplugin.getSupportedLibraryTypes():
169
			self.reportError("* Library type not supported: " + self._ltype)
170
			return
171
	
172
		if self._platform!=self._dmplugin.getOSPlatform() and self._platform!="all":
173
			print "* Warning: Forced platform ",self._platform
174
		return self.get()
175

  
176
	def get(self, unPackList = None):
177
		#transform namespaces org.foo to org/foo
178
		group=self._group.replace(".","/")
179
	
180
		print "[",self._artifact,"]"
181

  
182
		file_name=self._artifact+"-"+self._version+"-"+self._platform+"-"+self._compiler+"-"+self._arch+"-"+self._ltype
183
		tarname=file_name+".tar.gz"
184
		md5name=tarname+".md5"
185
	
186
		download_path = group+os.path.sep+self._artifact+os.path.sep+self._version+os.path.sep+self._platform+os.path.sep+self._compiler+os.path.sep+self._arch+os.path.sep+self._ltype
187
		download_dir = group+"/"+self._artifact+"/"+self._version+"/"+self._platform+"/"+self._compiler+"/"+self._arch+"/"+self._ltype
188
		cache_path = self._default_repository+os.path.sep+".cache"+os.path.sep+download_path
189
	
190
	
191
		tstr=self._version.lower()
192
		if tstr.find("snapshot")!=-1:
193
			is_snapshot=True
194
		else:
195
			is_snapshot=False
196
	
197
		dmutil = BMUtil()
198

  
199
		is_tar=True
200
		is_md5=True
201
		if not dmutil.checkUrl(self._url+"/"+download_dir+"/"+md5name):
202
			#print "Error: File ",baseurl+"/"+download_dir+"/"+md5name, " not found in the repository"
203
			is_md5=False
204
	
205
		if not dmutil.checkUrl(self._url+"/"+download_dir+"/"+tarname):
206
			#print "Error: File ",baseurl+"/"+download_dir+"/"+tarname, " not found in the repository"
207
			is_tar=False
208
	
209
		dmutil.mkdir(cache_path)
210
		
211
	
212
		if not os.path.isfile(cache_path+os.path.sep+md5name):
213
			is_cache=False
214
		else:
215
			is_cache=True
216

  
217
		#Once all variables have been collected, lets decide what to do with the artifact
218
		must_download=False
219
	
220
		if (not is_md5 or not is_tar) and not is_cache:
221
			print "Error: Artifact ",tarname," not found"
222
			return False
223
	
224
		if not is_md5 and not is_tar and is_cache:
225
			print "* file not found in repository, using cache..."
226
			must_download=False
227
	
228
		if is_md5 and is_tar  and not is_cache:
229
			print "* file is not in cache, downloading..."
230
			must_download=True
231
	
232
		if is_md5 and is_tar and is_cache:
233
			if is_snapshot:
234
				if self._isInteractive:
235
					repo=raw_input("What snapshot do you want to use? (cache/remote): ")
236
				else:
237
					if self._forceCache:
238
						repo="cache"
239
					else:
240
						repo="remote"
241
					
242
				must_download=False
243
			
244
				#in case of misspeling, using cache by default
245
				if repo!="cache" and repo!="remote":
246
					repo="cache"
247
			else:
248
				repo="remote"
249
		
250
			if repo=="remote":
251
				print "* file cached, checking md5..."
252
				dmutil.download(self._url+"/"+download_dir+"/"+md5name,cache_path+os.path.sep+md5name+".new")
... This diff was truncated because it exceeds the maximum size that can be displayed.

Also available in: Unified diff