Beispiel #1
0
	def unpack(self,unPackList):
		sep=os.path.sep
		dmutil = BMUtil()
		for file in unPackList:
			tmpstr=file[file.rfind(sep)+1:]
			print "* unpacking ",tmpstr
			dmutil.untargz(file,self._dmplugin.getDepManPath())
Beispiel #2
0
 def unpack(self, unPackList):
     sep = os.path.sep
     dmutil = BMUtil()
     for file in unPackList:
         tmpstr = file[file.rfind(sep) + 1:]
         print "* unpacking ", tmpstr
         dmutil.untargz(file, self._dmplugin.getDepManPath())
Beispiel #3
0
    def create(self):
        self.initFromXML(self._dmplugin.getNode())
        #user questions
        if self._dependency == None:
            self._dependency = DepManDependency(self._dmplugin)
            self._is_Interactive = True
            self._dependency.raw_input()

            upload_response = raw_input("Upload to server? (y/n): ")
            if upload_response == "y" or upload_response == "yes":
                self._upload = True

        if not self._dmplugin.validateDependency(self._dependency):
            return False

    #artifact and md5 generation
        file_name = self._dependency.getDepManFileName()
        file_path = self._dependency.getDepManFilePath()

        tarname = file_name + ".tar.gz"
        md5name = tarname + ".md5"
        dmfile = file_name + ".xml"

        dmutil = BMUtil()

        tmpdir = self._dmplugin.getMavenPath(
        ) + os.path.sep + "repository" + os.path.sep + file_path
        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 not self._is_Interactive:
            shutil.copyfile(self._dmplugin.getXMLFile(),
                            tmpdir + os.path.sep + dmfile)

        self._dmdeployplugin.setDependency(self._dependency)
        print "Artifact " + tarname + " created in:\n" + tmpdir
Beispiel #4
0
	def create(self):
	   	self.initFromXML(self._dmplugin.getNode())	
		#user questions
		if self._dependency==None:
			self._dependency = DepManDependency(self._dmplugin)
			self._is_Interactive = True
			self._dependency.raw_input()
					
			upload_response = raw_input("Upload to server? (y/n): ")
			if upload_response == "y" or upload_response == "yes":
				self._upload=True
	
		if not self._dmplugin.validateDependency(self._dependency):
			return False
				

		#artifact and md5 generation
		file_name=self._dependency.getDepManFileName()
		file_path=self._dependency.getDepManFilePath()

		tarname=file_name+".tar.gz"
		md5name=tarname+".md5"
		dmfile=file_name+".xml"
		
		dmutil = BMUtil()
		
		tmpdir=self._dmplugin.getMavenPath()+os.path.sep+"repository"+os.path.sep+file_path
		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 not self._is_Interactive:
			shutil.copyfile(self._dmplugin.getXMLFile(),tmpdir+os.path.sep+dmfile)	
		
		self._dmdeployplugin.setDependency(self._dependency)
		print "Artifact " + tarname + " created in:\n" + tmpdir
Beispiel #5
0
    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
Beispiel #6
0
    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
Beispiel #7
0
    def get(self, unPackList=None):

        print "[", self._dependency.artifact, "]"
        file_name = self._dependency.getDepManFileName()
        tarname = file_name + ".tar.gz"
        md5name = tarname + ".md5"
        download_path = self._dependency.getDepManFilePath()
        download_dir = self._dependency.getDepManUrlPath()
        cache_path = self._default_repository + os.path.sep + ".cache" + os.path.sep + download_path

        is_snapshot = self._dependency.isSnapshot()

        dmutil = BMUtil()

        is_tar = True
        is_md5 = True
        if not dmutil.checkUrl(self._dependency.url + "/" + download_dir +
                               "/" + md5name):
            #print "Error: File ",baseurl+"/"+download_dir+"/"+md5name, " not found in the repository"
            is_md5 = False

        if not dmutil.checkUrl(self._dependency.url + "/" + download_dir +
                               "/" + tarname):
            #print "Error: File ",baseurl+"/"+download_dir+"/"+tarname, " not found in the repository"
            is_tar = False

        dmutil.mkdir(cache_path)

        if not os.path.isfile(cache_path + os.path.sep + md5name):
            is_cache = False
        else:
            is_cache = True

        #Once all variables have been collected, lets decide what to do with the artifact
        must_download = False

        if (not is_md5 or not is_tar) and not is_cache:
            print "Error: Artifact ", tarname, " not found"
            return False

        if not is_md5 and not is_tar and is_cache:
            print "* file not found in repository, using cache..."
            must_download = False

        if is_md5 and is_tar and not is_cache:
            print "* file is not in cache, downloading..."
            must_download = True

        if is_md5 and is_tar and is_cache:
            if is_snapshot:
                if self._isInteractive:
                    repo = raw_input(
                        "What snapshot do you want to use? (cache/remote): ")
                else:
                    if self._forceCache:
                        repo = "cache"
                    else:
                        repo = "remote"

                must_download = False

                #in case of misspeling, using cache by default
                if repo != "cache" and repo != "remote":
                    repo = "cache"
            else:
                repo = "remote"

            if repo == "remote":
                print "* file cached, checking md5..."
                dmutil.download(self._url + "/" + download_dir + "/" + md5name,
                                cache_path + os.path.sep + md5name + ".new")

                if dmutil.diff(cache_path + os.path.sep + md5name,
                               cache_path + os.path.sep + md5name + ".new"):
                    print "* no md5 matching, re-downloading..."
                    must_download = True
                else:
                    print "* md5 matching succesful"
                    must_download = False
                os.remove(cache_path + os.path.sep + md5name + ".new")

        if must_download == True:
            print "URL :", self._dependency.url
            dmutil.download(
                self._dependency.url + "/" + download_dir + "/" + md5name,
                cache_path + os.path.sep + md5name)
            #print "* downloaded [",md5name,"]"
            dmutil.download(
                self._dependency.url + "/" + download_dir + "/" + tarname,
                cache_path + os.path.sep + tarname)
            #print "* downloaded[",tarname,"]"
        if unPackList != None:
            if (cache_path + os.path.sep + tarname) not in unPackList:
                unPackList.append(cache_path + os.path.sep + tarname)

        return True
Beispiel #8
0
	def get(self, unPackList = None):
		
		print "[",self._dependency.artifact,"]"
		file_name = self._dependency.getDepManFileName()
		tarname=file_name+".tar.gz"
		md5name=tarname+".md5"
		download_path = self._dependency.getDepManFilePath()
		download_dir = self._dependency.getDepManUrlPath() 
		cache_path = self._default_repository+os.path.sep+".cache"+os.path.sep+download_path

		is_snapshot = self._dependency.isSnapshot()
	
		dmutil = BMUtil()

		is_tar=True
		is_md5=True
		if not dmutil.checkUrl(self._dependency.url+"/"+download_dir+"/"+md5name):
			#print "Error: File ",baseurl+"/"+download_dir+"/"+md5name, " not found in the repository"
			is_md5=False
	
		if not dmutil.checkUrl(self._dependency.url+"/"+download_dir+"/"+tarname):
			#print "Error: File ",baseurl+"/"+download_dir+"/"+tarname, " not found in the repository"
			is_tar=False
	
		dmutil.mkdir(cache_path)
		
	
		if not os.path.isfile(cache_path+os.path.sep+md5name):
			is_cache=False
		else:
			is_cache=True

		#Once all variables have been collected, lets decide what to do with the artifact
		must_download=False
	
		if (not is_md5 or not is_tar) and not is_cache:
			print "Error: Artifact ",tarname," not found"
			return False
	
		if not is_md5 and not is_tar and is_cache:
			print "* file not found in repository, using cache..."
			must_download=False
	
		if is_md5 and is_tar  and not is_cache:
			print "* file is not in cache, downloading..."
			must_download=True
	
		if is_md5 and is_tar and is_cache:
			if is_snapshot:
				if self._isInteractive:
					repo=raw_input("What snapshot do you want to use? (cache/remote): ")
				else:
					if self._forceCache:
						repo="cache"
					else:
						repo="remote"
					
				must_download=False
			
				#in case of misspeling, using cache by default
				if repo!="cache" and repo!="remote":
					repo="cache"
			else:
				repo="remote"
		
			if repo=="remote":
				print "* file cached, checking md5..."
				dmutil.download(self._url+"/"+download_dir+"/"+md5name,cache_path+os.path.sep+md5name+".new")
			
				if dmutil.diff(cache_path+os.path.sep+md5name,cache_path+os.path.sep+md5name+".new"):
					print "* no md5 matching, re-downloading..."
					must_download=True
				else:
					print "* md5 matching succesful"
					must_download=False
				os.remove(cache_path+os.path.sep+md5name+".new")
	
		if must_download==True:
			print "URL :", self._dependency.url
			dmutil.download(self._dependency.url+"/"+download_dir+"/"+md5name,cache_path+os.path.sep+md5name)
			#print "* downloaded [",md5name,"]"
			dmutil.download(self._dependency.url+"/"+download_dir+"/"+tarname,cache_path+os.path.sep+tarname)
			#print "* downloaded[",tarname,"]"
		if unPackList != None:
			if (cache_path+os.path.sep+tarname) not in unPackList:
				unPackList.append(cache_path+os.path.sep+tarname)
		
		return True