Blob Blame History Raw
From 1a2f4f4db12bd45dd9b172be270db61f6766b589 Mon Sep 17 00:00:00 2001
From: Vratislav Podzimek <vpodzime@redhat.com>
Date: Mon, 6 Jul 2015 12:26:14 +0200
Subject: [PATCH 3/9] Better handle the case with no profile selected
 (#1235750)

We need to let user know that no profile is selected and avoid doing things that
are only needed when some profile *is* selected (like installing extra packages,
etc.).

Signed-off-by: Vratislav Podzimek <vpodzime@redhat.com>
---
 org_fedora_oscap/gui/spokes/oscap.py | 3 +++
 org_fedora_oscap/ks/oscap.py         | 9 +++++----
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/org_fedora_oscap/gui/spokes/oscap.py b/org_fedora_oscap/gui/spokes/oscap.py
index 564f0ed..6656108 100644
--- a/org_fedora_oscap/gui/spokes/oscap.py
+++ b/org_fedora_oscap/gui/spokes/oscap.py
@@ -821,6 +821,9 @@ class OSCAPSpoke(NormalSpoke):
         if not self._addon_data.content_defined:
             return _("No content found")
 
+        if not self._active_profile:
+            return _("No profile selected")
+
         # update message store, something may changed from the last update
         self._update_message_store(report_only=True)
 
diff --git a/org_fedora_oscap/ks/oscap.py b/org_fedora_oscap/ks/oscap.py
index 9e95486..f3ca15d 100644
--- a/org_fedora_oscap/ks/oscap.py
+++ b/org_fedora_oscap/ks/oscap.py
@@ -365,6 +365,11 @@ class OSCAPdata(AddonData):
 
         """
 
+        if self.dry_run or not self.profile_id:
+            # nothing more to be done in the dry-run mode or if no profile is
+            # selected
+            return
+
         # check fingerprint if given
         if self.fingerprint:
             hash_obj = utils.get_hashing_algorithm(self.fingerprint)
@@ -374,10 +379,6 @@ class OSCAPdata(AddonData):
                 msg = "Integrity check of the content failed!"
                 raise ContentCheckError(msg)
 
-        if self.dry_run:
-            # nothing more to be done in the dry-run mode
-            return
-
         # evaluate rules, do automatic fixes and stop if something that cannot
         # be fixed automatically is wrong
         messages = self.rule_data.eval_rules(ksdata, storage)
-- 
2.4.3