From 24340554d23e55f049587cb18497ca5a26ff43d7 Mon Sep 17 00:00:00 2001 From: Matej Tyc Date: Wed, 18 Jan 2023 16:36:36 +0100 Subject: [PATCH 1/2] Handle the URL with missing :// --- org_fedora_oscap/content_discovery.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/org_fedora_oscap/content_discovery.py b/org_fedora_oscap/content_discovery.py index ccfe6c80..b05ded7f 100644 --- a/org_fedora_oscap/content_discovery.py +++ b/org_fedora_oscap/content_discovery.py @@ -74,9 +74,14 @@ def content_uri(self): @content_uri.setter def content_uri(self, uri): - scheme, path = uri.split("://", 1) - self.content_uri_path = path - self.content_uri_scheme = scheme + scheme_and_maybe_path = uri.split("://") + if len(scheme_and_maybe_path) == 1: + msg = ( + f"Invalid supplied content URL '{uri}', " + "use the 'scheme://path' form.") + raise KickstartValueError(msg) + self.content_uri_path = scheme_and_maybe_path[1] + self.content_uri_scheme = scheme_and_maybe_path[0] def fetch_content(self, what_if_fail, ca_certs_path=""): """ @@ -87,7 +92,10 @@ def fetch_content(self, what_if_fail, ca_certs_path=""): should handle them in the calling layer. ca_certs_path: Path to the HTTPS certificate file """ - self.content_uri = self._addon_data.content_url + try: + self.content_uri = self._addon_data.content_url + except Exception as exc: + what_if_fail(exc) shutil.rmtree(self.CONTENT_DOWNLOAD_LOCATION, ignore_errors=True) self.CONTENT_DOWNLOAD_LOCATION.mkdir(parents=True, exist_ok=True) fetching_thread_name = self._fetch_files( From 3a8a03be5b0e576f7d62bb39309e65ce16a937b2 Mon Sep 17 00:00:00 2001 From: Matej Tyc Date: Wed, 18 Jan 2023 16:36:53 +0100 Subject: [PATCH 2/2] Stop fetching when there is an invalid profile --- org_fedora_oscap/gui/spokes/oscap.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/org_fedora_oscap/gui/spokes/oscap.py b/org_fedora_oscap/gui/spokes/oscap.py index 6d0aa5c1..209f3c98 100644 --- a/org_fedora_oscap/gui/spokes/oscap.py +++ b/org_fedora_oscap/gui/spokes/oscap.py @@ -503,6 +503,8 @@ def update_progress_label(msg): if self._policy_data.profile_id and not selected: # profile ID given, but it was impossible to select it -> invalid # profile ID given + with self._fetch_flag_lock: + self._fetching = False self._invalid_profile_id() return