diff --git a/ChangeLog.md b/ChangeLog.md index ba242af..004f9b1 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -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 diff --git a/capycli/bom/findsources.py b/capycli/bom/findsources.py index 71825f9..ae03e18 100644 --- a/capycli/bom/findsources.py +++ b/capycli/bom/findsources.py @@ -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": @@ -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: