class DepManCreatePlugIn(IPlugIn): def __init__(self): IPlugIn.__init__(self) self._path="." self._group="" self._artifact="" self._version="" self._platform="default" self._arch="default" self._compiler="default" self._ltype="" self._upload=False self._is_Interactive=True self._xmlfile = "" self._packageNode = None self._default_ssh="murray.ai2.upv.es" self._default_login="******" self._default_destdir = "/projects/AI2/www-aliases/depman/" def init(self): self.addGoal("create", "Create an artifact") self.addGoalOption("create","--path", "Specifies source directory") self.addGoalOption("create","--group", "Specifies artifact group name") self.addGoalOption("create","--artifact", "Specifies artifact name") self.addGoalOption("create","--version", "Specifies artifact version") self.addGoalOption("create","--platform", "Specifies artifact OS platform") self.addGoalOption("create","--arch", "Specifies artifact hardware architecture") self.addGoalOption("create","--compiler", "Specifies artifact compiler version") self.addGoalOption("create","--ltype", "Specifies library type if needed") self.addGoalOption("create","--upload", "Whenever the artifact must be uploaded or not") self.addGoalOption("create","--from-xml", "Uses the given depman.xml file to create the package") isCreate = False if self._arguments.read("create"): self.setExecute(True) isCreate = True if not isCreate: return args=[""] use_xml=False if self._arguments.read("--from-xml",args): self._xmlfile=args[0] use_xml=True if use_xml: self.loadXMLFile(self._xmlfile) args=[""] if self._arguments.read("--path",args): self._path=args[0] args=[""] if self._arguments.read("--group",args): self._group=args[0] self._is_Interactive=False args=[""] if self._arguments.read("--artifact",args): self._artifact=args[0] self._is_Interactive=False args=[""] if self._arguments.read("--version",args): self._version=args[0] self._is_Interactive=False args=[""] if self._arguments.read("--platform",args): self._platform=args[0] self._is_Interactive=False args=[""] if self._arguments.read("--arch",args): self._arch=args[0] self._is_Interactive=False args=[""] if self._arguments.read("--compiler",args): self._compiler=args[0] self._is_Interactive=False args=[""] if self._arguments.read("--ltype",args): self._ltype=args[0] self._is_Interactive=False if self._arguments.read("--upload"): self._upload=True def initFromXML(self,node): if node.localName == "create": if node.hasAttributes(): if node.attributes.has_key("from-xml"): self._xmlfile=node.attributes.get("from-xml").value self.loadXMLFile(self._xmlfile) if node.attributes.has_key("path"): self._path = node.attributes.get("path").value if node.attributes.has_key("upload"): value = node.attributes.get("upload").value if value =="True" or value =="true": self._upload = True else: if node.localName == "depman": self._packageNode = node self._is_Interactive=False def execute(self): print "Executing Plugin:" + str(self.__class__) return self.create() def create(self): self._dmplugin = PlugInManager().getPlugInInstance("DepManPlugIn") if self._dmplugin == None: self.reportError("PlugIn `depman` not found") return False #user questions if self._is_Interactive: self._group=raw_input("Group: ") self._artifact=raw_input("Artifact: ") self._version=raw_input("Version: ") tmpstr="" for p in self._dmplugin.getSupportedPlatforms(): tmpstr=tmpstr+p+" " print "( ",tmpstr,")" tmstr="Platform [*]:" self._platform=raw_input(string.replace(tmstr,"*",self._dmplugin.getOSPlatform())) if len(self._platform)==0: self._platform=self._dmplugin.getOSPlatform() tmpstr="" for p in self._dmplugin.getSupportedCompilers(): tmpstr=tmpstr+p+" " print "( ",tmpstr,")" tmstr="Compiler [*]:" self._compiler=raw_input(string.replace(tmstr,"*",self._dmplugin.getOSCompiler())) if len(self._compiler)==0: self._compiler=self._dmplugin.getOSCompiler() tmpstr="" for p in self._dmplugin.getSupportedArchs(): tmpstr=tmpstr+p+" " print "( ",tmpstr,")" tmstr="Architecture [*]:" self._arch=raw_input(string.replace(tmstr,"*",self._dmplugin.getOSArch())) if len(self._arch)==0: self._arch=self._dmplugin.getOSArch() tmpstr="" for p in self._dmplugin.getSupportedLibraryTypes(): tmpstr=tmpstr+p+" " print "( ",tmpstr,")" self._ltype=raw_input("Library Type: ") upload_response = raw_input("Upload to server? (y/n): ") if upload_response == "y" or upload_response == "yes": self._upload=True if self._packageNode != None: for n in self._packageNode.childNodes: if n.localName=="package": processPackage = True if n.hasAttributes(): if n.attributes.has_key("platform"): values = n.attributes.get("platform").value.split(",") if self._dmplugin.getOSPlatform() in values: processPackage = True else: processPackage = False if processPackage: print "Processing for platform..." for p in n.childNodes: if p.localName=="group": self._group=p.childNodes[0].nodeValue if p.localName=="artifact": self._artifact=p.childNodes[0].nodeValue if p.localName=="version": self._version=p.childNodes[0].nodeValue if p.localName=="platform": self._platform=p.childNodes[0].nodeValue if p.localName=="compiler": self._compiler=p.childNodes[0].nodeValue if p.localName=="arch": self._arch=p.childNodes[0].nodeValue if p.localName=="libraryType": self._ltype=p.childNodes[0].nodeValue if p.localName =="upload": #TODO: Maybe upload should be an external plugin for k in p.childNodes: if k.localName == "sshserver": self._default_ssh = k.childNodes[0].nodeValue if k.localName == "destdir": self._default_destdir = k.childNodes[0].nodeValue if k.localName == "username": self._default_login = k.childNodes[0].nodeValue if self._group == "": self.reportError("Group cannot be empty") return False if self._artifact == "": self.reportError("Artifact cannot be empty") return False if self._version == "": self.reportError("Version cannog be empty") return self._group=self._group.replace(".","/") if self._platform=="default": self._platform=self._dmplugin.getOSPlatform() if self._compiler=="default": self._compiler=self._dmplugin.getOSCompiler() if self._arch=="default": self._arch=self._dmplugin.getOSArch() #let's check user input consistency if self._platform not in self._dmplugin.getSupportedPlatforms(): self.reportError("Platform not supported: " + self._platform + ". Supported platforms:" + str(self._dmplugin.getSupportedPlatforms())) return False if self._compiler not in self._dmplugin.getSupportedCompilers(): self.reportError("Compiler not supported: " + self._compiler + ". Supported compilers:" +str(self._dmplugin.getSupportedCompilers())) return False if self._arch not in self._dmplugin.getSupportedArchs(): self.reportError("Architecture not supported: " + self._arch + ". Supported archs:" +str(self._dmplugin.getSupportedArchs())) return False if self._ltype not in self._dmplugin.getSupportedLibraryTypes(): self.reportError("Library type not supported: " + self._ltype + ". Supported libraries:" +str(self._dmplugin.getSupportedLibraryTypes())) return False #artifact and md5 generation file_name=self._artifact+"-"+self._version+"-"+self._platform+"-"+self._compiler+"-"+self._arch+"-"+self._ltype tarname=file_name+".tar.gz" md5name=tarname+".md5" dmfile=file_name+".xml" dmutil = BMUtil() 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 dmutil.mkdir(tmpdir) print tmpdir+os.path.sep+tarname,self._path dmutil.targz(os.path.join(tmpdir,tarname),self._path) #print "targz ",tmpdir+os.path.sep+tarname dmutil.createMD5(tmpdir+os.path.sep+tarname,tmpdir+os.path.sep+md5name) if self._xmlfile != "": shutil.copyfile(self._xmlfile,tmpdir+os.path.sep+dmfile) print "Artifact " + tarname + " created in:\n" + tmpdir if self._upload: dmutil.rmdir(".dmn_tmp") # Prevent for uploading bad previous compilations! 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 dmutil.mkdir(sshtmpdir) shutil.copyfile(tmpdir+os.path.sep+tarname,sshtmpdir+os.path.sep+tarname) shutil.copyfile(tmpdir+os.path.sep+md5name,sshtmpdir+os.path.sep+md5name) if self._xmlfile != "": shutil.copyfile(tmpdir+os.path.sep+dmfile,sshtmpdir+os.path.sep+dmfile) url = self._default_ssh; destdir = self._default_destdir login = self._default_login if self._is_Interactive: tmstr="SSH Server [*]:" url=raw_input(string.replace(tmstr,"*",self._default_ssh)) if len(url)==0: url=self._default_ssh tmstr="Destination Directory [*]:" destdir=raw_input(string.replace(tmstr,"*",self._default_destdir)) if len(destdir)==0: destdir=self._default_destdir tmstr="Login [*]:" login=raw_input(string.replace(tmstr,"*",self._default_login)) if len(login)==0: login=self._default_login download_dir = self._group+"/"+self._artifact+"/"+self._version+"/"+self._platform+"/"+self._compiler+"/"+self._arch+"/"+self._ltype print "* Uploading ",tarname print "* Uploading ",md5name #scp base_ssh=destdir url_ssh=url scpcommand = "scp" pscppath = "" if sys.platform == "win32": scpcommand=self._dmplugin.getDepManDataPath()+os.path.sep+"win32"+os.path.sep+"pscp.exe" scpcommand = '"'+os.path.normpath(scpcommand)+'"' cmdstr=scpcommand +" -r "+".dmn_tmp"+os.path.sep+"*"+" "+login+"@"+url_ssh+":"+base_ssh print cmdstr os.system(cmdstr) #scp dmutil.rmdir(".dmn_tmp")
class DepManDeployPlugIn(IPlugIn): def __init__(self): IPlugIn.__init__(self) self._is_Interactive = False self._dependency = None self._server = Server() self._servers = [] self._xmlConfigFile = "settings.xml" def setDependency(self, dependency): self._dependency = dependency def init(self): self.addGoal("deploy", "deploys an artifact") self.addGoalOption("deploy", "--interactive", "ask for server or artifact deployment configuration") self.addPreGoal("deploy", "create") self._dmplugin = PlugInManager().getPlugInInstance("DepManPlugIn") self._dmcreateplugin = PlugInManager().getPlugInInstance("DepManCreatePlugIn") if self._dmplugin == None: self.reportError("PlugIn `depman` not found") return False if self._arguments.read("deploy"): self.setExecute(True) if self._arguments.read("--interactive"): self._is_Interactive = True def initFromXML(self, node): distrNodes = node.getElementsByTagName("distributionManagement") if distrNodes != None: for n in distrNodes: if n.localName == "distributionManagement": for p in n.childNodes: if p.localName == "repository": repoName = None repoUrl = None for k in p.childNodes: if k.localName == "id": self.server._repository_id = k.childNodes[0].nodeValue if k.localName == "name": repoName = k.childNodes[0].nodeValue if k.localName == "url": repoUrl = urlparse(k.childNodes[0].nodeValue) self.server._repository_url = repo.netloc self.server._repository_path = repoUrl.path self.server._repository_proto = repoUrl.scheme print self.server._repository_proto + "://" + self.server._repository_url + "/" + self.server._repository_path settingsNodes = node.getElementsByTagName("servers") if settingsNodes != None: for n in settingsNodes: if n.localName == "servers": self._servers = [] for p in n.childNodes: if p.localName == "server": server = Server() for k in p.childNodes: if k.localName == "id": server._repository_id = k.childNodes[0].nodeValue if k.localName == "username": server._repository_login = k.childNodes[0].nodeValue if k.localName == "password": server._repository_passwd = k.childNodes[0].nodeValue self._servers.append(server) print self._servers def uploadFTPFile(self, url, user, pwd, destdir, path, orig_file, filename): #print url, user, pwd, destdir, path, orig_file, filename ftp = FTP_TLS(url) #ftp.set_debuglevel( 1 ) ftp.auth_tls(); ftp.prot_p() ftp.login(user, pwd) ftp.set_pasv(1) #ftp.retrlines('LIST') ftp.cwd(destdir) dirs = string.split(path, os.path.sep) for dir in dirs: #print dir try: ftp.mkd(dir) except: pass try: ftp.cwd(dir) except: pass f = open(orig_file, "rb") ftp.storbinary("STOR " + filename, f) f.close() ftp.quit() def execute(self): self.initFromXML(self._dmplugin.getNode()) print self._dmplugin.getMavenPath() + os.path.sep + self._xmlConfigFile self.loadXMLFile(self._dmplugin.getMavenPath() + os.path.sep + self._xmlConfigFile) file_name = self._dependency.getDepManFileName() file_path = self._dependency.getDepManUrlPath() tarname = file_name + ".tar.gz" md5name = tarname + ".md5" dmfile = file_name + ".xml" dmutil = BMUtil() surl = self._server._repository_proto + "://" + self._server._repository_url + "/" + self._server._repository_path; url = self._server._repository_url destdir = self._server._repository_path login = self._server._repository_login pwd = self._server._repository_passwd if self._is_Interactive: tmstr = "URL [*]:" surl = raw_input(string.replace(tmstr, "*", url)) if len(surl) == 0: surl = self._server._repository_url repoURL = urlparse(surl) self._server._repository_url = repo.netloc self._server._repository_path = repoUrl.path self._server._repository_proto = repoUrl.scheme url = self._server._repository_url tmstr = "Login [*]:" login = raw_input(string.replace(tmstr, "*", login)) if len(login) == 0: login = self._server._repository_login import getpass pwd = getpass.getpass() else: for s in self._servers: if s._repository_id == self._server._repository_id: login = self._server._repository_login = s._repository_login pwd = self._server._repository_passwd = s._repository_passwd #tmpdir = self._dmplugin.getDepManPath() + os.path.sep + ".cache" + os.path.sep + file_path tmpdir = self._dmplugin.getMavenPath()+os.path.sep+"repository"+os.path.sep+file_path if self._server._repository_proto == "ssh": dmutil.rmdir(".dmn_tmp") # Prevent for uploading bad previous compilations! sshtmpdir = ".dmn_tmp" + os.path.sep + file_path dmutil.mkdir(sshtmpdir) shutil.copyfile(tmpdir + os.path.sep + tarname, sshtmpdir + os.path.sep + tarname) shutil.copyfile(tmpdir + os.path.sep + md5name, sshtmpdir + os.path.sep + md5name) if self._xmlfile != "": shutil.copyfile(tmpdir + os.path.sep + dmfile, sshtmpdir + os.path.sep + dmfile) #scp base_ssh = destdir url_ssh = url scpcommand = "scp" pscppath = "" if sys.platform == "win32": scpcommand = self._dmplugin.getDepManDataPath() + os.path.sep + "win32" + os.path.sep + "pscp.exe" scpcommand = '"' + os.path.normpath(scpcommand) + '"' cmdstr = scpcommand + " -r " + ".dmn_tmp" + os.path.sep + "*" + " " + login + "@" + url_ssh + ":" + base_ssh print cmdstr os.system(cmdstr) dmutil.rmdir(".dmn_tmp") elif self._server._repository_proto == "ftp": #ftp print "* Uploading ", tarname self.uploadFTPFile(url, login, pwd, destdir, os.path.sep + file_path, tmpdir + os.path.sep + tarname, tarname) print "* Uploading ", md5name self.uploadFTPFile(url, login, pwd, destdir, os.path.sep + file_path, tmpdir + os.path.sep + md5name, md5name) if not self._is_Interactive: print "* Uploading ", dmfile self.uploadFTPFile(url, login, pwd, destdir, os.path.sep + file_path, tmpdir + os.path.sep + dmfile, dmfile) return True
class DepManDeployPlugIn(IPlugIn): def __init__(self): IPlugIn.__init__(self) self._is_Interactive = False self._dependency = None self._server = Server() self._servers = [] self._xmlConfigFile = "settings.xml" def setDependency(self, dependency): self._dependency = dependency def init(self): self.addGoal("deploy", "deploys an artifact") self.addGoalOption( "deploy", "--interactive", "ask for server or artifact deployment configuration") self.addPreGoal("deploy", "create") self._dmplugin = PlugInManager().getPlugInInstance("DepManPlugIn") self._dmcreateplugin = PlugInManager().getPlugInInstance( "DepManCreatePlugIn") if self._dmplugin == None: self.reportError("PlugIn `depman` not found") return False if self._arguments.read("deploy"): self.setExecute(True) if self._arguments.read("--interactive"): self._is_Interactive = True def initFromXML(self, node): distrNodes = node.getElementsByTagName("distributionManagement") if distrNodes != None: for n in distrNodes: if n.localName == "distributionManagement": for p in n.childNodes: if p.localName == "repository": repoName = None repoUrl = None for k in p.childNodes: if k.localName == "id": self.server._repository_id = k.childNodes[ 0].nodeValue if k.localName == "name": repoName = k.childNodes[0].nodeValue if k.localName == "url": repoUrl = urlparse( k.childNodes[0].nodeValue) self.server._repository_url = repo.netloc self.server._repository_path = repoUrl.path self.server._repository_proto = repoUrl.scheme print self.server._repository_proto + "://" + self.server._repository_url + "/" + self.server._repository_path settingsNodes = node.getElementsByTagName("servers") if settingsNodes != None: for n in settingsNodes: if n.localName == "servers": self._servers = [] for p in n.childNodes: if p.localName == "server": server = Server() for k in p.childNodes: if k.localName == "id": server._repository_id = k.childNodes[ 0].nodeValue if k.localName == "username": server._repository_login = k.childNodes[ 0].nodeValue if k.localName == "password": server._repository_passwd = k.childNodes[ 0].nodeValue self._servers.append(server) print self._servers def uploadFTPFile(self, url, user, pwd, destdir, path, orig_file, filename): #print url, user, pwd, destdir, path, orig_file, filename ftp = FTP_TLS(url) #ftp.set_debuglevel( 1 ) ftp.auth_tls() ftp.prot_p() ftp.login(user, pwd) ftp.set_pasv(1) #ftp.retrlines('LIST') ftp.cwd(destdir) dirs = string.split(path, os.path.sep) for dir in dirs: #print dir try: ftp.mkd(dir) except: pass try: ftp.cwd(dir) except: pass f = open(orig_file, "rb") ftp.storbinary("STOR " + filename, f) f.close() ftp.quit() def execute(self): self.initFromXML(self._dmplugin.getNode()) print self._dmplugin.getMavenPath() + os.path.sep + self._xmlConfigFile self.loadXMLFile(self._dmplugin.getMavenPath() + os.path.sep + self._xmlConfigFile) file_name = self._dependency.getDepManFileName() file_path = self._dependency.getDepManUrlPath() tarname = file_name + ".tar.gz" md5name = tarname + ".md5" dmfile = file_name + ".xml" dmutil = BMUtil() surl = self._server._repository_proto + "://" + self._server._repository_url + "/" + self._server._repository_path url = self._server._repository_url destdir = self._server._repository_path login = self._server._repository_login pwd = self._server._repository_passwd if self._is_Interactive: tmstr = "URL [*]:" surl = raw_input(string.replace(tmstr, "*", url)) if len(surl) == 0: surl = self._server._repository_url repoURL = urlparse(surl) self._server._repository_url = repo.netloc self._server._repository_path = repoUrl.path self._server._repository_proto = repoUrl.scheme url = self._server._repository_url tmstr = "Login [*]:" login = raw_input(string.replace(tmstr, "*", login)) if len(login) == 0: login = self._server._repository_login import getpass pwd = getpass.getpass() else: for s in self._servers: if s._repository_id == self._server._repository_id: login = self._server._repository_login = s._repository_login pwd = self._server._repository_passwd = s._repository_passwd #tmpdir = self._dmplugin.getDepManPath() + os.path.sep + ".cache" + os.path.sep + file_path tmpdir = self._dmplugin.getMavenPath( ) + os.path.sep + "repository" + os.path.sep + file_path if self._server._repository_proto == "ssh": dmutil.rmdir( ".dmn_tmp") # Prevent for uploading bad previous compilations! sshtmpdir = ".dmn_tmp" + os.path.sep + file_path dmutil.mkdir(sshtmpdir) shutil.copyfile(tmpdir + os.path.sep + tarname, sshtmpdir + os.path.sep + tarname) shutil.copyfile(tmpdir + os.path.sep + md5name, sshtmpdir + os.path.sep + md5name) if self._xmlfile != "": shutil.copyfile(tmpdir + os.path.sep + dmfile, sshtmpdir + os.path.sep + dmfile) #scp base_ssh = destdir url_ssh = url scpcommand = "scp" pscppath = "" if sys.platform == "win32": scpcommand = self._dmplugin.getDepManDataPath( ) + os.path.sep + "win32" + os.path.sep + "pscp.exe" scpcommand = '"' + os.path.normpath(scpcommand) + '"' cmdstr = scpcommand + " -r " + ".dmn_tmp" + os.path.sep + "*" + " " + login + "@" + url_ssh + ":" + base_ssh print cmdstr os.system(cmdstr) dmutil.rmdir(".dmn_tmp") elif self._server._repository_proto == "ftp": #ftp print "* Uploading ", tarname self.uploadFTPFile(url, login, pwd, destdir, os.path.sep + file_path, tmpdir + os.path.sep + tarname, tarname) print "* Uploading ", md5name self.uploadFTPFile(url, login, pwd, destdir, os.path.sep + file_path, tmpdir + os.path.sep + md5name, md5name) if not self._is_Interactive: print "* Uploading ", dmfile self.uploadFTPFile(url, login, pwd, destdir, os.path.sep + file_path, tmpdir + os.path.sep + dmfile, dmfile) return True
class DepManCreatePlugIn(IPlugIn): def __init__(self): IPlugIn.__init__(self) self._path = "." self._group = "" self._artifact = "" self._version = "" self._platform = "default" self._arch = "default" self._compiler = "default" self._ltype = "" self._upload = False self._is_Interactive = True self._xmlfile = "" self._packageNode = None self._default_ssh = "murray.ai2.upv.es" self._default_login = "******" self._default_destdir = "/projects/AI2/www-aliases/depman/" def init(self): self.addGoal("create", "Create an artifact") self.addGoalOption("create", "--path", "Specifies source directory") self.addGoalOption("create", "--group", "Specifies artifact group name") self.addGoalOption("create", "--artifact", "Specifies artifact name") self.addGoalOption("create", "--version", "Specifies artifact version") self.addGoalOption("create", "--platform", "Specifies artifact OS platform") self.addGoalOption("create", "--arch", "Specifies artifact hardware architecture") self.addGoalOption("create", "--compiler", "Specifies artifact compiler version") self.addGoalOption("create", "--ltype", "Specifies library type if needed") self.addGoalOption("create", "--upload", "Whenever the artifact must be uploaded or not") self.addGoalOption( "create", "--from-xml", "Uses the given depman.xml file to create the package") isCreate = False if self._arguments.read("create"): self.setExecute(True) isCreate = True if not isCreate: return args = [""] use_xml = False if self._arguments.read("--from-xml", args): self._xmlfile = args[0] use_xml = True if use_xml: self.loadXMLFile(self._xmlfile) args = [""] if self._arguments.read("--path", args): self._path = args[0] args = [""] if self._arguments.read("--group", args): self._group = args[0] self._is_Interactive = False args = [""] if self._arguments.read("--artifact", args): self._artifact = args[0] self._is_Interactive = False args = [""] if self._arguments.read("--version", args): self._version = args[0] self._is_Interactive = False args = [""] if self._arguments.read("--platform", args): self._platform = args[0] self._is_Interactive = False args = [""] if self._arguments.read("--arch", args): self._arch = args[0] self._is_Interactive = False args = [""] if self._arguments.read("--compiler", args): self._compiler = args[0] self._is_Interactive = False args = [""] if self._arguments.read("--ltype", args): self._ltype = args[0] self._is_Interactive = False if self._arguments.read("--upload"): self._upload = True def initFromXML(self, node): if node.localName == "create": if node.hasAttributes(): if node.attributes.has_key("from-xml"): self._xmlfile = node.attributes.get("from-xml").value self.loadXMLFile(self._xmlfile) if node.attributes.has_key("path"): self._path = node.attributes.get("path").value if node.attributes.has_key("upload"): value = node.attributes.get("upload").value if value == "True" or value == "true": self._upload = True else: if node.localName == "depman": self._packageNode = node self._is_Interactive = False def execute(self): print "Executing Plugin:" + str(self.__class__) return self.create() def create(self): self._dmplugin = PlugInManager().getPlugInInstance("DepManPlugIn") if self._dmplugin == None: self.reportError("PlugIn `depman` not found") return False #user questions if self._is_Interactive: self._group = raw_input("Group: ") self._artifact = raw_input("Artifact: ") self._version = raw_input("Version: ") tmpstr = "" for p in self._dmplugin.getSupportedPlatforms(): tmpstr = tmpstr + p + " " print "( ", tmpstr, ")" tmstr = "Platform [*]:" self._platform = raw_input( string.replace(tmstr, "*", self._dmplugin.getOSPlatform())) if len(self._platform) == 0: self._platform = self._dmplugin.getOSPlatform() tmpstr = "" for p in self._dmplugin.getSupportedCompilers(): tmpstr = tmpstr + p + " " print "( ", tmpstr, ")" tmstr = "Compiler [*]:" self._compiler = raw_input( string.replace(tmstr, "*", self._dmplugin.getOSCompiler())) if len(self._compiler) == 0: self._compiler = self._dmplugin.getOSCompiler() tmpstr = "" for p in self._dmplugin.getSupportedArchs(): tmpstr = tmpstr + p + " " print "( ", tmpstr, ")" tmstr = "Architecture [*]:" self._arch = raw_input( string.replace(tmstr, "*", self._dmplugin.getOSArch())) if len(self._arch) == 0: self._arch = self._dmplugin.getOSArch() tmpstr = "" for p in self._dmplugin.getSupportedLibraryTypes(): tmpstr = tmpstr + p + " " print "( ", tmpstr, ")" self._ltype = raw_input("Library Type: ") upload_response = raw_input("Upload to server? (y/n): ") if upload_response == "y" or upload_response == "yes": self._upload = True if self._packageNode != None: for n in self._packageNode.childNodes: if n.localName == "package": processPackage = True if n.hasAttributes(): if n.attributes.has_key("platform"): values = n.attributes.get("platform").value.split( ",") if self._dmplugin.getOSPlatform() in values: processPackage = True else: processPackage = False if processPackage: print "Processing for platform..." for p in n.childNodes: if p.localName == "group": self._group = p.childNodes[0].nodeValue if p.localName == "artifact": self._artifact = p.childNodes[0].nodeValue if p.localName == "version": self._version = p.childNodes[0].nodeValue if p.localName == "platform": self._platform = p.childNodes[0].nodeValue if p.localName == "compiler": self._compiler = p.childNodes[0].nodeValue if p.localName == "arch": self._arch = p.childNodes[0].nodeValue if p.localName == "libraryType": self._ltype = p.childNodes[0].nodeValue if p.localName == "upload": #TODO: Maybe upload should be an external plugin for k in p.childNodes: if k.localName == "sshserver": self._default_ssh = k.childNodes[ 0].nodeValue if k.localName == "destdir": self._default_destdir = k.childNodes[ 0].nodeValue if k.localName == "username": self._default_login = k.childNodes[ 0].nodeValue if self._group == "": self.reportError("Group cannot be empty") return False if self._artifact == "": self.reportError("Artifact cannot be empty") return False if self._version == "": self.reportError("Version cannog be empty") return self._group = self._group.replace(".", "/") if self._platform == "default": self._platform = self._dmplugin.getOSPlatform() if self._compiler == "default": self._compiler = self._dmplugin.getOSCompiler() if self._arch == "default": self._arch = self._dmplugin.getOSArch() #let's check user input consistency if self._platform not in self._dmplugin.getSupportedPlatforms(): self.reportError("Platform not supported: " + self._platform + ". Supported platforms:" + str(self._dmplugin.getSupportedPlatforms())) return False if self._compiler not in self._dmplugin.getSupportedCompilers(): self.reportError("Compiler not supported: " + self._compiler + ". Supported compilers:" + str(self._dmplugin.getSupportedCompilers())) return False if self._arch not in self._dmplugin.getSupportedArchs(): self.reportError("Architecture not supported: " + self._arch + ". Supported archs:" + str(self._dmplugin.getSupportedArchs())) return False if self._ltype not in self._dmplugin.getSupportedLibraryTypes(): self.reportError("Library type not supported: " + self._ltype + ". Supported libraries:" + str(self._dmplugin.getSupportedLibraryTypes())) return False #artifact and md5 generation file_name = self._artifact + "-" + self._version + "-" + self._platform + "-" + self._compiler + "-" + self._arch + "-" + self._ltype tarname = file_name + ".tar.gz" md5name = tarname + ".md5" dmfile = file_name + ".xml" dmutil = BMUtil() 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 dmutil.mkdir(tmpdir) print tmpdir + os.path.sep + tarname, self._path dmutil.targz(os.path.join(tmpdir, tarname), self._path) #print "targz ",tmpdir+os.path.sep+tarname dmutil.createMD5(tmpdir + os.path.sep + tarname, tmpdir + os.path.sep + md5name) if self._xmlfile != "": shutil.copyfile(self._xmlfile, tmpdir + os.path.sep + dmfile) print "Artifact " + tarname + " created in:\n" + tmpdir if self._upload: dmutil.rmdir( ".dmn_tmp") # Prevent for uploading bad previous compilations! 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 dmutil.mkdir(sshtmpdir) shutil.copyfile(tmpdir + os.path.sep + tarname, sshtmpdir + os.path.sep + tarname) shutil.copyfile(tmpdir + os.path.sep + md5name, sshtmpdir + os.path.sep + md5name) if self._xmlfile != "": shutil.copyfile(tmpdir + os.path.sep + dmfile, sshtmpdir + os.path.sep + dmfile) url = self._default_ssh destdir = self._default_destdir login = self._default_login if self._is_Interactive: tmstr = "SSH Server [*]:" url = raw_input(string.replace(tmstr, "*", self._default_ssh)) if len(url) == 0: url = self._default_ssh tmstr = "Destination Directory [*]:" destdir = raw_input( string.replace(tmstr, "*", self._default_destdir)) if len(destdir) == 0: destdir = self._default_destdir tmstr = "Login [*]:" login = raw_input( string.replace(tmstr, "*", self._default_login)) if len(login) == 0: login = self._default_login download_dir = self._group + "/" + self._artifact + "/" + self._version + "/" + self._platform + "/" + self._compiler + "/" + self._arch + "/" + self._ltype print "* Uploading ", tarname print "* Uploading ", md5name #scp base_ssh = destdir url_ssh = url scpcommand = "scp" pscppath = "" if sys.platform == "win32": scpcommand = self._dmplugin.getDepManDataPath( ) + os.path.sep + "win32" + os.path.sep + "pscp.exe" scpcommand = '"' + os.path.normpath(scpcommand) + '"' cmdstr = scpcommand + " -r " + ".dmn_tmp" + os.path.sep + "*" + " " + login + "@" + url_ssh + ":" + base_ssh print cmdstr os.system(cmdstr) #scp dmutil.rmdir(".dmn_tmp")