Example #1
0
    def getTarball(self, importpath, commit):
        """
		Search for a tarball in tarball directory.
		If it does not exist, download the tarball.

		TODO: Create a DirectoryStorage on top of TarballStorage?
		1) extract the archive to 
		2) rename its directory to TARBALLSIGNATURE_DIR
		3) return TARBALLSIGNATURE_DIR
		"""
        # tarball directory must exist
        if not os.path.exists(self.tarball_directory):
            self.err = "Tarball directory %s does not exist" % self.tarball_directory
            return ""

        ri = RepositoryInfo(importpath, commit)
        if not ri.retrieve():
            self.err = ri.getError()
            return ""

        # tarball exists?
        tarball_path = "%s/%s" % (self.tarball_directory, ri.getSignature())
        if not os.path.exists(tarball_path):
            ai = ri.getArchiveInfo()
            if self.verbose:
                print "Downloading %s ..." % ai.archive_url
            # download tarball
            so, se, rc = runCommand(
                "wget -nv %s --no-check-certificate -O %s" %
                (ai.archive_url, tarball_path))
            if rc != 0:
                print "Unable to download tarball:\n%s" % (se)
                return ""

        return tarball_path
Example #2
0
	def getTarball(self, importpath, commit):
		"""
		Search for a tarball in tarball directory.
		If it does not exist, download the tarball.

		TODO: Create a DirectoryStorage on top of TarballStorage?
		1) extract the archive to 
		2) rename its directory to TARBALLSIGNATURE_DIR
		3) return TARBALLSIGNATURE_DIR
		"""
		# tarball directory must exist
		if not os.path.exists(self.tarball_directory):
			self.err = "Tarball directory %s does not exist" % self.tarball_directory
			return ""

		ri = RepositoryInfo(importpath, commit)
		if not ri.retrieve():
			self.err = ri.getError()
			return ""

		# tarball exists?
		tarball_path = "%s/%s" % (self.tarball_directory, ri.getSignature())
		if not os.path.exists(tarball_path):
			ai = ri.getArchiveInfo()
			if self.verbose:
				print "Downloading %s ..." % ai.archive_url
			# download tarball
			so, se, rc = runCommand("wget -nv %s --no-check-certificate -O %s" % (ai.archive_url, tarball_path))
			if rc != 0:
				print "Unable to download tarball:\n%s" % (se)
				return ""

		return tarball_path
Example #3
0
class PackageInfo:
    """
	Get basic information about project:
		imported packages
		provided packages
		tests
	"""
    def __init__(self, import_path, commit="", noGodeps=[]):
        self.import_path = import_path
        self.commit = commit
        self.noGodeps = noGodeps
        self.err = ""
        self.repository_info = None
        self.project_info = None
        self.archive_dir = ""
        self.repository_decoded = False
        self.name = ""

    def getError(self):
        return self.err

    def getName(self):
        return self.name

    def getRepositoryInfo(self):
        return self.repository_info

    def getProjectInfo(self):
        return self.project_info

    def decodeRepository(self):
        # get repository info
        self.repository_info = RepositoryInfo(self.import_path, self.commit)
        if not self.repository_info.retrieve():
            self.err = self.repository_info.getError()
            return False

        # package name
        ip_info = self.repository_info.getImportPathInfo()

        r_info = self.repository_info.getArchiveInfo()

        self.repository_decoded = True
        self.archive_dir = r_info.archive_dir
        self.name = ip_info.getPackageName()
        return True

    def decodeProject(self, working_directory="."):
        if not self.repository_decoded:
            self.err = "RepositoryInfo not decoded"
            return False

        # get package info
        self.project_info = ProjectInfo(self.noGodeps)
        source_code_directory = "%s/%s" % (working_directory, self.archive_dir)
        if not os.path.exists(source_code_directory):
            self.err = "Source code directory %s does not exist." % source_code_directory
            self.err += "CWD: %s" % os.getcwd()
            return False

        if not self.project_info.retrieve(source_code_directory):
            self.err = self.project_info.getError()
            return False

        return True
Example #4
0
class PackageInfo:
	"""
	Get basic information about project:
		imported packages
		provided packages
		tests
	"""
	def __init__(self, import_path, commit = "", noGodeps = [], skip_errors=False):
		self.import_path = import_path
		self.commit = commit
		self.noGodeps = noGodeps
		self.err = ""
		self.repository_info = None
		self.project_info = None
		self.archive_dir = ""
		self.repository_decoded = False
		self.name = ""
		self.skip_errors = skip_errors

	def getError(self):
		return self.err

	def getName(self):
		return self.name

	def getRepositoryInfo(self):
		return self.repository_info

	def getProjectInfo(self):
		return self.project_info

	def decodeRepository(self):
		# get repository info
		self.repository_info = RepositoryInfo(self.import_path, self.commit)
		if not self.repository_info.retrieve():
			self.err = self.repository_info.getError()
			return False

		# package name
		ip_info = self.repository_info.getImportPathInfo()

		r_info = self.repository_info.getArchiveInfo()

		self.repository_decoded = True
		self.archive_dir = r_info.archive_dir
		self.name = ip_info.getPackageName()
		return True

	def decodeProject(self, working_directory = "."):
		if not self.repository_decoded:
			self.err = "RepositoryInfo not decoded"
			return False

		# get package info
		self.project_info = ProjectInfo(self.noGodeps)
		source_code_directory = "%s/%s" % (working_directory, self.archive_dir)
		if not os.path.exists(source_code_directory):
			self.err = "Source code directory %s does not exist." % source_code_directory
			self.err += "CWD: %s" % os.getcwd()
			return False

		if not self.project_info.retrieve(source_code_directory, self.skip_errors):
			self.err = self.project_info.getError()
			return False

	
		return True