From fb692babdef37bb03b9962258d47d6f23384142f Mon Sep 17 00:00:00 2001 From: Mike Sul Date: Fri, 22 Mar 2024 16:13:05 +0100 Subject: [PATCH 1/2] apps: Convert shortlist string to list - Convert the comma-separated list of apps represented as a string and provided as an input parameter to a list of string. Signed-off-by: Mike Sul --- apps/fetch.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/apps/fetch.py b/apps/fetch.py index 5b24c9ab..4168a95f 100755 --- a/apps/fetch.py +++ b/apps/fetch.py @@ -19,7 +19,8 @@ def fetch_target_apps(targets: dict, apps_shortlist: str, token: str, dst_dir: s apps_fetcher = SkopeAppFetcher(token, dst_dir) for target_name, target_json in targets.items(): apps_fetcher.fetch_target(FactoryClient.Target(target_name, target_json), - apps_shortlist, force=True) + [x.strip() for x in apps_shortlist.split(',') if x] + if apps_shortlist else None, force=True) def tar_fetched_apps(src_dir: str, out_file: str): From be2167a3903219dc3e8295e26243e2c4a39df711 Mon Sep 17 00:00:00 2001 From: Mike Sul Date: Mon, 25 Mar 2024 11:15:49 +0100 Subject: [PATCH 2/2] assemble: Ignore exception yielded by fetched apps checking If there is an error or exception occurs during checking whether apps were fetched before then ignore it and let the assemble do its own app fetching. Signed-off-by: Mike Sul --- assemble.py | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/assemble.py b/assemble.py index 6f43c08a..0ed07c29 100755 --- a/assemble.py +++ b/assemble.py @@ -276,21 +276,24 @@ def fetch_restorable_apps(target: FactoryClient.Target, dst_dir: str, shortlist: def check_and_get_fetched_apps_uri(target: FactoryClient.Target, shortlist: [str] = None): fetched_apps = None fetched_apps_uri = None - if "fetched-apps" in target.json.get("custom", {}): - fetched_apps_str = target.json["custom"]["fetched-apps"].get("shortlist") - if fetched_apps_str: - fetched_apps = set( - x.strip() for x in fetched_apps_str.split(',') if x) - else: - # if `shortlist` is not defined or empty then all target apps were fetched - fetched_apps = set(app[0] for app in target.apps()) - - apps_to_fetch = set(shortlist) if shortlist else set(app[0] for app in target.apps()) - - if fetched_apps.issubset(apps_to_fetch): - # if the previously fetched apps is a sub-set of the apps to be fetched then - # enable getting and reusing the previously fetched apps - fetched_apps_uri = target.json["custom"]["fetched-apps"]["uri"] + try: + if "fetched-apps" in target.json.get("custom", {}): + fetched_apps_str = target.json["custom"]["fetched-apps"].get("shortlist") + if fetched_apps_str: + fetched_apps = set( + x.strip() for x in fetched_apps_str.split(',') if x) + else: + # if `shortlist` is not defined or empty then all target apps were fetched + fetched_apps = set(app[0] for app in target.apps()) + + apps_to_fetch = set(shortlist) if shortlist else set(app[0] for app in target.apps()) + + if fetched_apps.issubset(apps_to_fetch): + # if the previously fetched apps is a sub-set of the apps to be fetched then + # enable getting and reusing the previously fetched apps + fetched_apps_uri = target.json["custom"]["fetched-apps"]["uri"] + except Exception as err: + logger.error(f"Failed to get info about fetched apps: {err}") return fetched_apps_uri, fetched_apps