From 0d90e43ce6808c8c9f94348f9dfce5e2b2914365 Mon Sep 17 00:00:00 2001 From: dellroot Date: Fri, 18 Jan 2019 08:12:08 +0100 Subject: [PATCH] Add new functionality: Upload repository from VCS to fossology server. Signed-off-by: Michal Orzel --- fossdriver/server.py | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/fossdriver/server.py b/fossdriver/server.py index 00eb699..2206066 100644 --- a/fossdriver/server.py +++ b/fossdriver/server.py @@ -197,6 +197,41 @@ def UploadFile(self, filePath, folderNum): results = self._postFile(endpoint, values) return fossdriver.parser.parseAnchorTagsForNewUploadNumber(results.content) + def UploadFromVCS(self, urlOfRepo, vcsKind, repoUserName, repoPassword, folderNum): + """ + Initiate an upload of a repository from Git or SVN to the fossology server. + No scanning agents will be triggered. + Arguments: + - urlOfRepo: url address of remote repository (starting with http://). + - vcsKind: Git or SVN. + -repoUserName: username for given repo. + -repoPassword: password for given repo. + -folderNum: ID number of folder to receive upload. + """ + endpoint = "/repo/?mod=upload_vcs" + buildtoken = self._getUploadFormBuildToken() + + values = ( + ("uploadformbuild", buildtoken), + ("vcstype", vcsKind), + ("geturl", urlOfRepo), + ("username", repoUserName), + ("passwd", repoPassword), + ("folder", str(folderNum)), + ("public", "private"), + ("Check_agent_bucket", "0"), + ("Check_agent_copyright", "0"), + ("Check_agent_ecc", "0"), + ("Check_agent_mimetype", "0"), + ("Check_agent_nomos", "0"), + ("Check_agent_monk", "0"), + ("Check_agent_pkgagent", "0"), + ("deciderRules[]", ""), + ) + + results = self._post(endpoint, values) + return fossdriver.parser.parseAnchorTagsForNewUploadNumber(results.content) + def GetLicenses(self, uploadNum, itemNum): """ Obtain a dict of all licenses available in the Fossology server.