From eb5c75eb590ff2eeac6b8c4e93d4589920cc3a9a Mon Sep 17 00:00:00 2001 From: Vratislav Podzimek Date: Tue, 7 Jul 2015 15:28:09 +0200 Subject: [PATCH 2/7] Properly react on download/loading issues in text+kickstart mode Instead of raising an exception in case of content download or loading issues we should let users know and give them a chance to continue anyway (if possible). Related: rhbz#1240710 Signed-off-by: Vratislav Podzimek --- org_fedora_oscap/ks/oscap.py | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/org_fedora_oscap/ks/oscap.py b/org_fedora_oscap/ks/oscap.py index fd57b14..ed0e54d 100644 --- a/org_fedora_oscap/ks/oscap.py +++ b/org_fedora_oscap/ks/oscap.py @@ -23,10 +23,14 @@ import shutil import re import os +import time from pyanaconda.addons import AddonData from pyanaconda.iutil import getSysroot +from pyanaconda.progress import progressQ +from pyanaconda import errors from pyanaconda import iutil +from pyanaconda import flags from pykickstart.errors import KickstartParseError, KickstartValueError from org_fedora_oscap import utils, common, rule_handling, data_fetch from org_fedora_oscap.common import SUPPORTED_ARCHIVES @@ -35,6 +39,9 @@ from org_fedora_oscap.content_handling import ContentCheckError import logging log = logging.getLogger("anaconda") +import gettext +_ = lambda x: gettext.ldgettext("oscap-anaconda-addon", x) + # export OSCAPdata class to prevent Anaconda's collect method from taking # AddonData class instead of the OSCAPdata class # @see: pyanaconda.kickstart.AnacondaKSHandler.__init__ @@ -406,9 +413,29 @@ class OSCAPdata(AddonData): # content not available/fetched yet try: self._fetch_content_and_initialize() - except common.OSCAPaddonError: + except common.OSCAPaddonError as e: log.error("Failed to fetch and initialize SCAP content!") - return + msg = _("There was an error fetching and loading the security content:\n" + + "%s\n" + + "The installation should be aborted. Do you wish to continue anyway?") % e + + if flags.flags.automatedInstall and not flags.flags.ksprompt: + # cannot have ask in a non-interactive kickstart installation + raise errors.CmdlineError(msg) + + answ = errors.errorHandler.ui.showYesNoQuestion(msg) + if answ == errors.ERROR_CONTINUE: + # prevent any futher actions here by switching to the dry + # run mode and let things go on + self.dry_run = True + return + else: + # Let's sleep forever to prevent any further actions and wait for + # the main thread to quit the process. + progressQ.send_quit(1) + while True: + time.sleep(100000) + # check fingerprint if given if self.fingerprint: -- 2.4.3