Skip to content

Commit

Permalink
Merge pull request #88 from sw360/feat/make-findsources-more-resilient
Browse files Browse the repository at this point in the history
feat: make findsources more resilient against SW360 issues
  • Loading branch information
tngraf authored Oct 22, 2024
2 parents ef27461 + 8a34045 commit be689f8
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 4 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@

# CaPyCli - Clearing Automation Python Command Line Tool for SW360

## NEXT

* make `findsources` more resilient against SW360 issues.

## 2.5.1 (2024-10-16)

* fix: urls coming from granularity file are repository urls and not source code
Expand Down
19 changes: 17 additions & 2 deletions capycli/bom/findsources.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,22 @@ def find_sources(self, bom: Bom) -> Tuple[int, int]:
if self.verbose:
print(" No Source code URL available",
"try to find from sw360 component or releases")
source_url = self.find_source_url_on_release(component)
try:
source_url = self.find_source_url_on_release(component)
except SW360Error as swex:
if swex.response is None:
print_red(" Unknown error: " + swex.message)
elif swex.response.status_code == requests.codes['not_found']:
print(
Fore.LIGHTYELLOW_EX + " Release not found " + component.name +
", " + component.version + Style.RESET_ALL)
else:
print(Fore.LIGHTRED_EX + " Error retrieving release data: ")
print(" " + component.name + ", " + component.version)
print(" Status Code: " + str(swex.response.status_code))
if swex.message:
print(" Message: " + swex.message)
print(Style.RESET_ALL)

# then consider the package managers
if not source_url and language.lower() == "javascript":
Expand Down Expand Up @@ -619,7 +634,7 @@ def run(self, args: Any) -> None:
self.verbose = args.verbose
self.github_name = args.name
self.github_token = args.github_token
if not self.sw360_url:
if args.sw360_url:
self.sw360_url = args.sw360_url

if self.sw360_url:
Expand Down

0 comments on commit be689f8

Please sign in to comment.