Advertisement
Guest User

Untitled

a guest
Dec 13th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.20 KB | None | 0 0
  1. diff --git a/fossdriver/config.py b/fossdriver/config.py
  2. index a1980a0..1b9e2a5 100644
  3. --- a/fossdriver/config.py
  4. +++ b/fossdriver/config.py
  5. @@ -24,17 +24,17 @@ class FossConfig(object):
  6. # check whether we got everything we expected
  7. isValid = True
  8. if self.serverUrl == "":
  9. - logging.error(f"serverUrl not found in config file")
  10. + logging.error("serverUrl not found in config file")
  11. isValid = False
  12. if self.username == "":
  13. - logging.error(f"username not found in config file")
  14. + logging.error("username not found in config file")
  15. isValid = False
  16. if self.password == "":
  17. - logging.error(f"password not found in config file")
  18. + logging.error("password not found in config file")
  19. isValid = False
  20.  
  21. return isValid
  22.  
  23. - except json.decoder.JSONDecodeError as e:
  24. - logging.error(f"Error loading or parsing {configFilename}: {str(e)}")
  25. + except ValueError as e:
  26. + logging.error("Error loading or parsing {}: {}".format(configFilename, str(e)))
  27. return False
  28. diff --git a/fossdriver/parser.py b/fossdriver/parser.py
  29. index 9bbbbd5..7686a9d 100644
  30. --- a/fossdriver/parser.py
  31. +++ b/fossdriver/parser.py
  32. @@ -20,7 +20,7 @@ class ParsedLicense(object):
  33. self._id = -1
  34.  
  35. def __repr__(self):
  36. - return f"ParsedLicense: {self.name} ({self._id})"
  37. + return "ParsedLicense: {} ({})".format(selfname, self._id)
  38.  
  39. class ParsedJob(object):
  40. def __init__(self):
  41. @@ -30,7 +30,7 @@ class ParsedJob(object):
  42. self.reportId = -1
  43.  
  44. def __repr__(self):
  45. - return f"Job {self._id}: {self.agent}, {self.status}"
  46. + return "Job {}: {}, {}".format(self._id, self.agent, self.status)
  47.  
  48. def parseUploadDataForFolderLineItem(lineItem):
  49. """
  50. @@ -109,7 +109,7 @@ def parseUploadFormBuildToken(content):
  51. try:
  52. return soup.find("input", {"name": "uploadformbuild"}).get("value", None)
  53. except Exception as e:
  54. - logging.warn(f"Couldn't extract uploadformbuild token: {str(e)}")
  55. + logging.warn("Couldn't extract uploadformbuild token: {}".format(str(e)))
  56. return None
  57.  
  58. def parseFolderNumber(content, folderName):
  59. diff --git a/fossdriver/server.py b/fossdriver/server.py
  60. index fc7a93b..0853142 100644
  61. --- a/fossdriver/server.py
  62. +++ b/fossdriver/server.py
  63. @@ -9,6 +9,8 @@ import requests
  64. from requests_toolbelt.multipart.encoder import MultipartEncoder
  65. import time
  66. import urllib
  67. +import io
  68. +import sys
  69.  
  70. import fossdriver.parser
  71.  
  72. @@ -20,7 +22,7 @@ class BulkTextMatchAction(object):
  73. self.action = ""
  74.  
  75. def __repr__(self):
  76. - return f"BulkTextMatchAction: [{self.action}] {self.licenseName} ({self.licenseId})"
  77. + return "BulkTextMatchAction: [{}], [{}], [{}]".format(self.action, self.licenseName, self.licenseId)
  78.  
  79. class FossServer(object):
  80.  
  81. @@ -102,7 +104,7 @@ class FossServer(object):
  82. # FIXME note that using browse-processPost means we may only get
  83. # FIXME the first 100 uploads in the folder. may be able to check
  84. # FIXME iTotalDisplayRecords and loop to get more if needed
  85. - endpoint = f"/repo/?mod=browse-processPost&folder={folderNum}&iDisplayStart=0&iDisplayLength=100"
  86. + endpoint = "/repo/?mod=browse-processPost&folder={}&iDisplayStart=0&iDisplayLength=100".format(folderNum)
  87. results = self._get(endpoint)
  88. rj = json.loads(results.content)
  89. uploadData = rj.get("aaData", None)
  90. @@ -167,7 +169,11 @@ class FossServer(object):
  91.  
  92. # determine mime type
  93. mime = MimeTypes()
  94. - murl = urllib.request.pathname2url(filePath)
  95. +# murl = urllib.request.pathname2url(filePath)
  96. + if sys.version_info > (3, 4):
  97. + murl = urllib.request.pathname2url(filePath)
  98. + else:
  99. + murl = urllib.pathname2url(filePath)
  100. mime_type = mime.guess_type(murl)
  101.  
  102. # retrieve custom token for upload
  103. @@ -200,7 +206,7 @@ class FossServer(object):
  104. - uploadNum: valid ID number for an existing upload.
  105. - topTreeItemNum: valid ID number for an item in that upload.
  106. """
  107. - endpoint = f"/repo/?mod=view-license&upload={uploadNum}&item={itemNum}"
  108. + endpoint = "/repo/?mod=view-license&upload={}&item={}".format(uploadNum, itemNum)
  109. results = self._get(endpoint)
  110. licenses = fossdriver.parser.parseAllLicenseData(results.content)
  111. return licenses
  112. @@ -254,7 +260,7 @@ class FossServer(object):
  113.  
  114. def _getJobSingleData(self, jobNum):
  115. """Helper function: Retrieve job data for a single job."""
  116. - endpoint = f"/repo/?mod=ajaxShowJobs&do=showSingleJob&jobId={jobNum}"
  117. + endpoint = "/repo/?mod=ajaxShowJobs&do=showSingleJob&jobId={}".format(jobNum)
  118. results = self._get(endpoint)
  119. job = fossdriver.parser.parseSingleJobData(results.content)
  120. return job
  121. @@ -281,7 +287,7 @@ class FossServer(object):
  122. values = {
  123. "agents[]": "agent_reuser",
  124. "upload": str(uploadNum),
  125. - "uploadToReuse": f"{reusedUploadNum},3",
  126. + "uploadToReuse": "{}, 3".format(reusedUploadNum)
  127. }
  128. self._post(endpoint, values)
  129.  
  130. @@ -317,7 +323,7 @@ class FossServer(object):
  131. Arguments:
  132. - uploadNum: ID number of upload to export as tag-value.
  133. """
  134. - endpoint = f"/repo/?mod=ui_spdx2&outputFormat=spdx2tv&upload={uploadNum}"
  135. + endpoint = "/repo/?mod=ui_spdx2&outputFormat=spdx2tv&upload={}".format(uploadNum)
  136. self._get(endpoint)
  137.  
  138. def GetSPDXTVReport(self, uploadNum, outFilePath):
  139. @@ -336,10 +342,14 @@ class FossServer(object):
  140. return False
  141.  
  142. # now, go get the actual report
  143. - endpoint = f"/repo/?mod=download&report={job.reportId}"
  144. + endpoint = "/repo/?mod=download&report={}".format(job.reportId)
  145. results = self._get(endpoint)
  146. - with open(outFilePath, "w") as f:
  147. - f.write(results.content.decode("utf-8"))
  148. + if sys.version_info > (3, 4):
  149. + with open(outFilePath, "w") as f:
  150. + f.write(results.content.decode("utf-8"))
  151. + else:
  152. + with io.open(outFilePath, "w", encoding="utf-8") as f:
  153. + f.write(results.content.decode("utf-8"))
  154. return True
  155.  
  156. def MakeBulkTextMatchAction(self, licenseId, licenseName, action):
  157. @@ -359,7 +369,7 @@ class FossServer(object):
  158. - itemNum: ID number for tree item within upload (NOT the upload number).
  159. - actions: list of BulkTextMatchActions to perform.
  160. """
  161. - endpoint = f"/repo/?mod=change-license-bulk"
  162. + endpoint = "/repo/?mod=change-license-bulk"
  163. # start building values
  164. values = {
  165. "refText": refText,
  166. @@ -371,10 +381,10 @@ class FossServer(object):
  167. row = 0
  168. for action in actions:
  169. # FIXME should this validate that the requested actions / lics are valid?
  170. - rowPrefix = f"bulkAction[{row}]"
  171. - values[f"{rowPrefix}[licenseId]"] = str(action.licenseId)
  172. - values[f"{rowPrefix}[licenseName]"] = action.licenseName
  173. - values[f"{rowPrefix}[action]"] = action.action
  174. + rowPrefix = "bulkAction[{}]".format(row)
  175. + values["{}[licenseId]".format(rowPrefix)] = str(action.licenseId)
  176. + values["{}[licenseName]".format(rowPrefix)] = action.licenseName
  177. + values["{}[action]".format(rowPrefix)] = action.action
  178. row += 1
  179. self._post(endpoint, values)
  180.  
  181. diff --git a/fossdriver/tasks.py b/fossdriver/tasks.py
  182. index 5263a1a..70b7944 100644
  183. --- a/fossdriver/tasks.py
  184. +++ b/fossdriver/tasks.py
  185. @@ -9,7 +9,7 @@ class Task(object):
  186. self._type = _type
  187.  
  188. def __repr__(self):
  189. - return f"Task: {self._type}"
  190. + return "Task: {}".format(self._type)
  191.  
  192. def run(self):
  193. """Run the specified Task and return success or failure."""
  194. @@ -22,20 +22,20 @@ class CreateFolder(Task):
  195. self.parentFolderName = parentFolderName
  196.  
  197. def __repr__(self):
  198. - return f"Task: {self._type} (new folder {self.newFolderName}, parent folder {self.parentFolderName})"
  199. + return "Task: {} (new folder {}, parent folder {})".format(self._type, self.newFolderName, self.parentFolderName)
  200.  
  201. def run(self):
  202. - logging.info(f"Running task: {self._type}")
  203. + logging.info("Running task: {}".format(self._type))
  204. """Create the folder and return success or failure."""
  205. # FIXME check whether the folder already exists
  206. # first, get the parent folder ID
  207. parentFolderNum = self.server.GetFolderNum(self.parentFolderName)
  208. if parentFolderNum is None or parentFolderNum == -1:
  209. - logging.error(f"Failed: could not retrieve folder number for parent folder {self.parentFolderName}")
  210. + logging.error("Failed: could not retrieve folder number for parent folder {}".format(self.parentFolderName))
  211. return False
  212.  
  213. # now, create the folder
  214. - logging.info(f"Creating folder {self.newFolderName} in parent folder {self.parentFolderName} ({parentFolderNum})")
  215. + logging.info("Creating folder {} in parent folder {} ({})".format(self.newFolderName, self.parentFolderName, parentFolderNum))
  216. self.server.CreateFolder(parentFolderNum, self.newFolderName, self.newFolderName)
  217. # FIXME check to see whether it was successfully created?
  218.  
  219. @@ -49,27 +49,27 @@ class Upload(Task):
  220. self.folderName = folderName
  221.  
  222. def __repr__(self):
  223. - return f"Task: {self._type} (filePath {self.filePath}, folder {self.folderName})"
  224. + return "Task: {} (filePath {}, folder {})".format(self._type, self.filePath, self.folderName)
  225.  
  226. def run(self):
  227. - logging.info(f"Running task: {self._type}")
  228. + logging.info("Running task: {}".format(self._type))
  229. """Start the upload, wait until it completes and return success or failure."""
  230. # first, get the destination folder ID
  231. folderNum = self.server.GetFolderNum(self.folderName)
  232. if folderNum is None or folderNum == -1:
  233. - logging.error(f"Failed: could not retrieve folder number for folder {self.folderName}")
  234. + logging.error("Failed: could not retrieve folder number for folder {}".format(self.folderName))
  235. return False
  236.  
  237. # now, start the upload
  238. - logging.info(f"Uploading {self.filePath} to folder {self.folderName} ({folderNum})")
  239. + logging.info("Uploading {} to folder {} ({})".format(self.filePath, self.folderName, folderNum))
  240. newUploadNum = self.server.UploadFile(self.filePath, folderNum)
  241. if newUploadNum is None or newUploadNum < 1:
  242. - logging.error(f"Failed: could not receive ID number for upload {self.filePath}")
  243. + logging.error("Failed: could not receive ID number for upload {}".format(self.filePath))
  244. return False
  245. - logging.info(f"Upload complete, {self.filePath} upload ID number is {newUploadNum}")
  246. + logging.info("Upload complete, {} upload ID number is {}".format(self.filePath, newUploadNum))
  247.  
  248. # and wait until upload finishes unpacking
  249. - logging.info(f"Waiting for upload {newUploadNum} to unpack")
  250. + logging.info("Waiting for upload {} to unpack".format(newUploadNum))
  251. self.server.WaitUntilAgentIsDone(newUploadNum, "ununpack", pollSeconds=5)
  252. self.server.WaitUntilAgentIsDone(newUploadNum, "adj2nest", pollSeconds=5)
  253.  
  254. @@ -82,29 +82,29 @@ class Scanners(Task):
  255. self.folderName = folderName
  256.  
  257. def __repr__(self):
  258. - return f"Task: {self._type} (uploadName {self.uploadName}, folder {self.folderName})"
  259. + return "Task: {} (uploadName {}, folder {})".format(self._type, self.uploadName, self.folderName)
  260.  
  261. def run(self):
  262. """Start the monk and nomos agents, wait until they complete and return success or failure."""
  263. - logging.info(f"Running task: {self._type}")
  264. + logging.info("Running task: {}".format(self._type))
  265. # first, get the folder and then upload ID
  266. folderNum = self.server.GetFolderNum(self.folderName)
  267. if folderNum is None or folderNum == -1:
  268. - logging.error(f"Failed: could not retrieve folder number for folder {self.folderName}")
  269. + logging.error("Failed: could not retrieve folder number for folder {}".format(self.folderName))
  270. return False
  271. uploadNum = self.server.GetUploadNum(folderNum, self.uploadName)
  272. if uploadNum is None or uploadNum == -1:
  273. - logging.error(f"Failed: could not retrieve upload number for upload {self.uploadName} in folder {self.folderName} ({folderNum})")
  274. + logging.error("Failed: could not retrieve upload number for upload {} in folder {} ({})".format(self.uploadName, self.folderName, folderNum))
  275. return False
  276.  
  277. # now, start the scanners
  278. - logging.info(f"Running monk and nomos scanners on upload {self.uploadName} ({uploadNum})")
  279. + logging.info("Running monk and nomos scanners on upload {} ({})".format(self.uploadName, uploadNum))
  280. self.server.StartMonkAndNomosAgents(uploadNum)
  281.  
  282. # and wait until both scanners finish
  283. - logging.info(f"Waiting for monk and nomos to finish for upload {self.uploadName} ({uploadNum})")
  284. - self.server.WaitUntilAgentIsDone(uploadNum, "monk", pollSeconds=5)
  285. - self.server.WaitUntilAgentIsDone(uploadNum, "nomos", pollSeconds=5)
  286. + logging.info("Waiting for monk and nomos to finish for upload {} ({})".format(self.uploadName, uploadNum))
  287. + self.server.WaitUntilAgentIsDone(uploadNum, "monk", pollSeconds=10)
  288. + self.server.WaitUntilAgentIsDone(uploadNum, "nomos", pollSeconds=10)
  289.  
  290. return True
  291.  
  292. @@ -115,27 +115,27 @@ class Copyright(Task):
  293. self.folderName = folderName
  294.  
  295. def __repr__(self):
  296. - return f"Task: {self._type} (uploadName {self.uploadName}, folder {self.folderName})"
  297. + return "Task: {} (uploadName {}, folder {})".format(self._type, self.uploadName, self.folderName)
  298.  
  299. def run(self):
  300. """Start the copyright agent, wait until it completes and return success or failure."""
  301. - logging.info(f"Running task: {self._type}")
  302. + logging.info("Running task: {}".format(self._type))
  303. # first, get the folder and then upload ID
  304. folderNum = self.server.GetFolderNum(self.folderName)
  305. if folderNum is None or folderNum == -1:
  306. - logging.error(f"Failed: could not retrieve folder number for folder {self.folderName}")
  307. + logging.error("Failed: could not retrieve folder number for folder {}".format(self.folderName))
  308. return False
  309. uploadNum = self.server.GetUploadNum(folderNum, self.uploadName)
  310. if uploadNum is None or uploadNum == -1:
  311. - logging.error(f"Failed: could not retrieve upload number for upload {self.uploadName} in folder {self.folderName} ({folderNum})")
  312. + logging.error("Failed: could not retrieve upload number for upload {} in folder {} ({})".format(self.uploadName, self.folderName, folderNum))
  313. return False
  314.  
  315. # now, start the scanners
  316. - logging.info(f"Running copyright agent on upload {self.uploadName} ({uploadNum})")
  317. + logging.info("Running copyright agent on upload {} ({})".format(self.uploadName, uploadNum))
  318. self.server.StartCopyrightAgent(uploadNum)
  319.  
  320. # and wait until both scanners finish
  321. - logging.info(f"Waiting for copyright agent to finish for upload {self.uploadName} ({uploadNum})")
  322. + logging.info("Waiting for copyright agent to finish for upload {} ({})".format(self.uploadName, uploadNum))
  323. self.server.WaitUntilAgentIsDone(uploadNum, "copyright", pollSeconds=5)
  324.  
  325. return True
  326. @@ -149,37 +149,37 @@ class Reuse(Task):
  327. self.newFolderName = newFolderName
  328.  
  329. def __repr__(self):
  330. - return f"Task: {self._type} (old: uploadName {self.oldUploadName}, folder {self.oldFolderName}; new: uploadName {self.newUploadName}, folder {self.newFolderName})"
  331. + return "Task: {} (old: uploadName {}, folder {}; new: uploadName {}, folder {})".format(self._type, self.oldUploadName, self.oldFolderName, self.newUploadName, self.newFolderName)
  332.  
  333. def run(self):
  334. """Start the reuser agents, wait until it completes and return success or failure."""
  335. - logging.info(f"Running task: {self._type}")
  336. + logging.info("Running task: {}".format(self._type))
  337. # first, get the old scan's folder and upload ID
  338. oldFolderNum = self.server.GetFolderNum(self.oldFolderName)
  339. if oldFolderNum is None or oldFolderNum == -1:
  340. - logging.error(f"Failed: could not retrieve folder number for old folder {self.oldFolderName}")
  341. + logging.error("Failed: could not retrieve folder number for old folder {}".format(self.oldFolderName))
  342. return False
  343. oldUploadNum = self.server.GetUploadNum(oldFolderNum, self.oldUploadName)
  344. if oldUploadNum is None or oldUploadNum == -1:
  345. - logging.error(f"Failed: could not retrieve upload number for old upload {self.oldUploadName} in folder {self.oldFolderName} ({oldFolderNum})")
  346. + logging.error("Failed: could not retrieve upload number for old upload {} in folder {} ({})".format(self.oldUploadName, self.oldFolderName, oldFolderNum))
  347. return False
  348.  
  349. # next, get the new scan's folder and upload ID
  350. newFolderNum = self.server.GetFolderNum(self.newFolderName)
  351. if newFolderNum is None or newFolderNum == -1:
  352. - logging.error(f"Failed: could not retrieve folder number for new folder {self.newFolderName}")
  353. + logging.error("Failed: could not retrieve folder number for new folder {}".format(self.newFolderName))
  354. return False
  355. newUploadNum = self.server.GetUploadNum(newFolderNum, self.newUploadName)
  356. if newUploadNum is None or newUploadNum == -1:
  357. - logging.error(f"Failed: could not retrieve upload number for new upload {self.newUploadName} in folder {self.newFolderName} ({newFolderNum})")
  358. + logging.error("Failed: could not retrieve upload number for new upload {} in folder {} ({})".format(self.newUploadName, self.newFolderName, newFolderNum))
  359. return False
  360.  
  361. # now, start the reuser agent
  362. - logging.info(f"Running reuser agent on upload {self.newUploadName} ({newUploadNum}) reusing old upload {self.oldUploadName} ({oldUploadNum})")
  363. + logging.info("Running reuser agent on upload {} ({}) reusing old upload {} ({})".format(self.newUploadName, newUploadNum, self.oldUploadName, oldUploadNum))
  364. self.server.StartReuserAgent(newUploadNum, oldUploadNum)
  365.  
  366. # and wait until reuser finishes
  367. - logging.info(f"Waiting for reuser to finish for upload {self.newUploadName} ({newUploadNum}) reusing old upload {self.oldUploadName} ({oldUploadNum})")
  368. + logging.info("Waiting for reuser to finish for upload {} ({}) reusing old upload {} ({})".format(self.newUploadName, newUploadNum, self.oldUploadName, oldUploadNum))
  369. self.server.WaitUntilAgentIsDone(newUploadNum, "reuser", pollSeconds=5)
  370.  
  371. return True
  372. @@ -215,15 +215,15 @@ class BulkTextMatch(Task):
  373. # need to get upload ID + upload item ID so we can get licenses
  374. folderNum = self.server.GetFolderNum(self.folderName)
  375. if folderNum is None or folderNum == -1:
  376. - logging.error(f"Failed: could not retrieve folder number for folder {self.folderName} when getting licenses")
  377. + logging.error("Failed: could not retrieve folder number for folder {} when getting licenses".format(self.folderName))
  378. return -1
  379. u = self.server._getUploadData(folderNum, self.uploadName, False)
  380. if u is None:
  381. - logging.error(f"Failed: could not retrieve upload data for upload {self.uploadName} when getting licenses")
  382. + logging.error("Failed: could not retrieve upload data for upload {} when getting licenses".format(self.uploadName))
  383. return -1
  384. self.parsedLicenses = self.server.GetLicenses(u._id, u.topTreeItemId)
  385. if self.parsedLicenses is None or self.parsedLicenses == []:
  386. - logging.error(f"Failed: could not retrieve licenses for upload {self.uploadName}")
  387. + logging.error("Failed: could not retrieve licenses for upload {}".format(self.uploadName))
  388. return -1
  389.  
  390. lic = self.server.FindLicenseInParsedList(self.parsedLicenses, licenseName)
  391. @@ -233,25 +233,24 @@ class BulkTextMatch(Task):
  392. """Helper function: make an action entry at the time the Task is being run."""
  393. licenseId = self._findLicenseID(licenseName)
  394. if licenseId == -1:
  395. - logging.error(f"Failed: could not get license ID for license {licenseName}")
  396. + logging.error("Failed: could not get license ID for license {}".format(licenseName))
  397. return None
  398. return self.server.MakeBulkTextMatchAction(licenseId, licenseName, actionType)
  399.  
  400. def run(self):
  401. """Start the monkbulk agent, wait until it completes and return success or failure."""
  402. - logging.info(f"Running task: {self._type}")
  403. - # first, get the folder and then upload ID, and full upload data
  404. + logging.info("Running task: {}".format(self._type))
  405. folderNum = self.server.GetFolderNum(self.folderName)
  406. if folderNum is None or folderNum == -1:
  407. - logging.error(f"Failed: could not retrieve folder number for folder {self.folderName}")
  408. + logging.error("Failed: could not retrieve folder number for folder {}".format(self.folderName))
  409. return False
  410. uploadNum = self.server.GetUploadNum(folderNum, self.uploadName)
  411. if uploadNum is None or uploadNum == -1:
  412. - logging.error(f"Failed: could not retrieve upload number for upload {self.uploadName} in folder {self.folderName} ({folderNum})")
  413. + logging.error("Failed: could not retrieve upload number for upload {} in folder {} ({})".format(self.uploadName, self.folderName, folderNum))
  414. return False
  415. u = self.server._getUploadData(folderNum, self.uploadName, False)
  416. if u is None:
  417. - logging.error(f"Failed: could not retrieve upload data for upload {self.uploadName} when getting licenses")
  418. + logging.error("Failed: could not retrieve upload data for upload {} when getting licenses".format(self.uploadName))
  419. return -1
  420.  
  421. # next, create the real actions list from the action tuples
  422. @@ -259,16 +258,16 @@ class BulkTextMatch(Task):
  423. for (licenseName, actionType) in self.actionTuples:
  424. a = self._makeRealAction(licenseName, actionType)
  425. if a is None:
  426. - logging.error(f"Failed: could not create action for ({licenseName}, {actionType}) for upload {self.uploadName}")
  427. + logging.error("Failed: could not create action for ({}, {}) for upload {}".format(licenseName, actionType, self.uploadName))
  428. return False
  429. actionList.append(a)
  430.  
  431. # now, start the bulk text match agent
  432. - logging.info(f"Running monkbulk agent on upload {self.uploadName} ({uploadNum})")
  433. + logging.info("Running monkbulk agent on upload {}( {})".format(self.uploadName, uploadNum))
  434. self.server.StartBulkTextMatch(self.refText, u.topTreeItemId, actionList)
  435.  
  436. # and wait until agent finishes
  437. - logging.info(f"Waiting for monkbulk to finish for upload {self.uploadName} ({uploadNum})")
  438. + logging.info("Waiting for monkbulk to finish for upload {} ({})".format(self.uploadName, uploadNum))
  439. self.server.WaitUntilAgentIsDone(uploadNum, "monkbulk", pollSeconds=5)
  440.  
  441. return True
  442. @@ -281,27 +280,27 @@ class SPDXTV(Task):
  443. self.outFilePath = outFilePath
  444.  
  445. def __repr__(self):
  446. - return f"Task: {self._type} (uploadName {self.uploadName}, folder {self.folderName}) to file {self.outFileName}"
  447. + return "Task: {} (uploadName {}, folder {}) to file {}".format(self._type, self.uploadName, self.folderName, self.outFileName)
  448.  
  449. def run(self):
  450. """Start the spdx2tv agents, wait until it completes and return success or failure."""
  451. - logging.info(f"Running task: {self._type}")
  452. + logging.info("Running task: {}".format(self._type))
  453. # first, get the folder and then upload ID
  454. folderNum = self.server.GetFolderNum(self.folderName)
  455. if folderNum is None or folderNum == -1:
  456. - logging.error(f"Failed: could not retrieve folder number for folder {self.folderName}")
  457. + logging.error("Failed: could not retrieve folder number for folder {}".format(self.folderName))
  458. return False
  459. uploadNum = self.server.GetUploadNum(folderNum, self.uploadName)
  460. if uploadNum is None or uploadNum == -1:
  461. - logging.error(f"Failed: could not retrieve upload number for upload {self.uploadName} in folder {self.folderName} ({folderNum})")
  462. - return False
  463. + logging.error("Failed: could not retrieve upload number for upload {} in folder {} ({})".format(self.uploadName, self.folderName, folderNum))
  464. + return False
  465.  
  466. # now, start the export agent
  467. - logging.info(f"Running spdx2tv agent on upload {self.uploadName} ({uploadNum})")
  468. + logging.info("Running spdx2tv agent on upload {} ({})".format(self.uploadName, uploadNum))
  469. self.server.StartSPDXTVReportGeneratorAgent(uploadNum)
  470.  
  471. # wait until the export agent finishes
  472. - logging.info(f"Waiting for spdx2tv to finish for upload {self.uploadName} ({uploadNum})")
  473. + logging.info("Waiting for spdx2tv to finish for upload {} ({}".format(self.uploadName, uploadNum))
  474. self.server.WaitUntilAgentIsDone(uploadNum, "spdx2tv", pollSeconds=5)
  475.  
  476. # finally, get and save the SPDX file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement