Skip to content

Commit

Permalink
Various improvements.
Browse files Browse the repository at this point in the history
Notably introduced the _terminate function that extracts
all the installation termination-related boilerplate.
  • Loading branch information
matejak committed Jun 7, 2021
1 parent 6316207 commit 8aa7866
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 23 deletions.
5 changes: 4 additions & 1 deletion org_fedora_oscap/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,10 @@ def extract_data(archive, out_dir, ensure_has_files=None):
"""

# get rid of empty file paths
ensure_has_files = [fpath for fpath in ensure_has_files if fpath]
if not ensure_has_files:
ensure_has_files = []
else:
ensure_has_files = [fpath for fpath in ensure_has_files if fpath]

if archive.endswith(".zip"):
# ZIP file
Expand Down
1 change: 1 addition & 0 deletions org_fedora_oscap/data_fetch.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,7 @@ def fetch_data(url, out_file, ca_certs=None):
else:
msg = "Cannot fetch data from '%s': unknown URL format" % url
raise UnknownURLformatError(msg)
log.info(f"Data fetch from {url} completed")


def _curl_fetch(url, out_file, ca_certs=None):
Expand Down
6 changes: 3 additions & 3 deletions org_fedora_oscap/gui/spokes/oscap.py
Original file line number Diff line number Diff line change
Expand Up @@ -716,16 +716,15 @@ def _select_profile(self, profile_id):
# no profile specified, nothing to do
return False

ds = None
xccdf = None
if self._using_ds:
ds = self._current_ds_id
xccdf = self._current_xccdf_id

if not all((ds, xccdf, profile_id)):
# something is not set -> do nothing
return False
else:
ds = None
xccdf = None

# get pre-install fix rules from the content
try:
Expand Down Expand Up @@ -1129,6 +1128,7 @@ def on_fetch_button_clicked(self, *args):
with self._fetch_flag_lock:
if self._fetching:
# some other fetching/pre-processing running, give up
log.warn("Clicked the fetch button, although the GUI is in the fetching mode.")
return

# prevent user from changing the URL in the meantime
Expand Down
43 changes: 24 additions & 19 deletions org_fedora_oscap/ks/oscap.py
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,25 @@ def _fetch_content_and_initialize(self):
common.INSTALLATION_CONTENT_DIR,
[self.content_path])

def _terminate(self, message):
if flags.flags.automatedInstall and not flags.flags.ksprompt:
# cannot have ask in a non-interactive kickstart
# installation
raise errors.CmdlineError(message)

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)



def setup(self, storage, ksdata, payload):
Expand Down Expand Up @@ -465,25 +484,11 @@ def setup(self, storage, ksdata, payload):
fatal_messages = [message for message in self.rule_data.eval_rules(ksdata, storage)
if message.type == common.MESSAGE_TYPE_FATAL]
if any(fatal_messages):
msg = "Wrong configuration detected!\n"
msg += "\n".join(message.text for message in fatal_messages)
msg += "\nThe installation should be aborted. Do you wish to continue anyway?"
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)
msg = ["Wrong configuration detected!"]
msg.extend(fatal_messages)
msg.append("The installation should be aborted. Do you wish to continue anyway?")
self._terminate("\n".join(msg))
return

# add packages needed on the target system to the list of packages
# that are requested to be installed
Expand Down

0 comments on commit 8aa7866

Please sign in to comment.