Advertisement
Guest User

Untitled

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