示例#1
0
 def _fetchProject(self, targetdir, clone_url, name, commits, skip_dirs):
     self.logger.info('Fetching project "{}"'.format(name))
     try:
         workdir = tempfile.mkdtemp()
     except IOError:
         self.logger.error("Cannot create temporary working directory")
         return
     try:
         try:
             repo = git.Repo.clone_from(clone_url, workdir)
         except git.exc.GitCommandError:
             self.logger.error('Cannot clone git repository "{}" to "{}"'.format(clone_url, workdir))
             return
         for commit in commits:
             self.logger.info('Processing commit "{}"'.format(commit))
             pid = ProjectID.get(name, commit)
             archive = os.path.join(targetdir, pid) + ".tar.gz"
             prefix = os.path.join(commit, "")
             try:
                 with open(archive, "wb") as f:
                     repo.archive(f, commit, prefix, format="tar.gz")
             except (IOError, git.exc.GitCommandError):
                 self.logger.warn('Cannot create archive "{}"'.format(archive))
                 continue
             try:
                 repo.git.checkout(commit)
             except git.exc.GitCommandError:
                 self.logger.warn('Cannot checkout to commit "{}"'.format(commit))
                 continue
             input_data = {
                 "resource": workdir,
                 "directories_to_skip": skip_dirs,
                 "project": name,
                 "commit": commit,
                 "ipprefix": name,
             }
             try:
                 plugin = GoSymbolsExtractor()
                 if not plugin.setData(input_data):
                     self.logger.warn("Failed to set input data to " + "GoSymbolsExtractor plugin")
                     continue
                 if not plugin.execute():
                     self.logger.warn("Failed to execute " + "GoSymbolsExtractor plugin")
                     continue
                 output_data = plugin.getData()
                 if not output_data:
                     self.logger.warn("Failed to get output data from " + "GoSymbolsExtractor plugin")
                     continue
             except:
                 self.logger.warn("Unhandled exception occured during " + "execution of GoSymbolsExtractor plugin")
                 continue
             api = os.path.join(targetdir, pid) + "-api.json"
             try:
                 with open(api, "wb") as f:
                     json.dump(output_data[1], f)
             except IOError:
                 self.logger.error('Cannot save exported API to file "{}"'.format(api))
                 continue
     finally:
         shutil.rmtree(workdir, ignore_errors=True)
示例#2
0
 def test_valid_output(self, project):
     plugin = GoSymbolsExtractor()
     assert plugin.setData(self.input_data)
     assert plugin.execute()
     output_data = plugin.getData()
     assert output_data
     for data in output_data:
         validator = ArtefactSchemaValidator(data["artefact"])
         assert validator.validate(data)
示例#3
0
文件: extractor.py 项目: nforro/infra
	def __init__(self):
		GoSymbolsExtractor.__init__(
			self,
			"%s/input_schema.json" % getScriptDir(__file__)
		)

		self.product = ""
		self.distribution = ""
		self.rpm = ""
		self.build = ""
示例#4
0
文件: extractor.py 项目: nforro/infra
	def setData(self, data):
		if not GoSymbolsExtractor.setData(self, data):
			return False

		self.product = data["product"]
		self.distribution = data["distribution"]
		self.build = data["build"]
		self.rpm = data["rpm"]
		self.commit = data["commit"]

		return True
示例#5
0
	def _generateGolangProjectDistributionExportedAPI(self):
		artefact = GoSymbolsExtractor._generateGolangProjectExportedAPI(self)

		artefact["artefact"] = ARTEFACT_GOLANG_PROJECT_DISTRIBUTION_EXPORTED_API
		artefact["product"] = self.product
		artefact["distribution"] = self.distribution
		artefact["rpm"] = self.rpm
		artefact["build"] = self.build
		artefact["commit"] = self.commit

		return artefact
示例#6
0
	def _generateGolangProjectDistributionPackagesArtefact(self):
		artefact = GoSymbolsExtractor._generateGolangProjectPackagesArtefact(self)

		artefact["artefact"] = ARTEFACT_GOLANG_PROJECT_DISTRIBUTION_PACKAGES
		artefact["product"] = self.product
		artefact["distribution"] = self.distribution
		artefact["rpm"] = self.rpm
		artefact["build"] = self.build
		artefact["commit"] = self.commit

		return artefact
示例#7
0
文件: extractor.py 项目: nforro/infra
	def _generateGolangProjectDistributionExportedAPI(self):
		artefact = GoSymbolsExtractor._generateGolangProjectExportedAPI(self)

		artefact["artefact"] = ARTEFACT_GOLANG_PROJECT_DISTRIBUTION_EXPORTED_API
		artefact["product"] = self.product
		artefact["distribution"] = self.distribution
		artefact["rpm"] = self.rpm
		artefact["build"] = self.build
		artefact["commit"] = self.commit

		ad = ArtefactDecomposer(ImportPathParserBuilder().buildWithLocalMappingForIPPrefixDecomposer())
		return ad.decomposeArtefact(artefact)
示例#8
0
	def __init__(self):
		GoSymbolsExtractor.__init__(self)
示例#9
0
	def getData(self):
		return GoSymbolsExtractor.getData(self)
示例#10
0
文件: extractor.py 项目: nforro/infra
	def execute(self):
		return GoSymbolsExtractor.execute(self)