[PATCH] Add an optional conditional to progress_report.
Chris Lumens
clumens at redhat.com
Thu Jun 25 15:10:46 UTC 2015
This is to get rid of a little of the indentation in install.py and make it look
a bit neater.
---
pyanaconda/install.py | 20 ++++++++------------
pyanaconda/progress.py | 11 +++++++----
2 files changed, 15 insertions(+), 16 deletions(-)
diff --git a/pyanaconda/install.py b/pyanaconda/install.py
index 4f83a15..087bfa8 100644
--- a/pyanaconda/install.py
+++ b/pyanaconda/install.py
@@ -89,9 +89,8 @@ def doConfiguration(storage, payload, ksdata, instClass):
ksdata.xconfig.execute(storage, ksdata, instClass)
ksdata.skipx.execute(storage, ksdata, instClass)
- if willWriteNetwork:
- with progress_report(_("Writing network configuration")):
- ksdata.network.execute(storage, ksdata, instClass)
+ with progress_report(_("Writing network configuration"), cond=lambda: willWriteNetwork):
+ ksdata.network.execute(storage, ksdata, instClass)
# Creating users and groups requires some pre-configuration.
with progress_report(_("Creating users")):
@@ -115,9 +114,8 @@ def doConfiguration(storage, payload, ksdata, instClass):
and (not ksdata.bootloader.disabled and ksdata.bootloader != "none"):
writeBootLoader(storage, payload, instClass, ksdata)
- if willRunRealmd:
- with progress_report(_("Joining realm: %s") % ksdata.realm.discovered):
- ksdata.realm.execute(storage, ksdata, instClass)
+ with progress_report(_("Joining realm: %s") % ksdata.realm.discovered, cond=lambda: willRunRealmd):
+ ksdata.realm.execute(storage, ksdata, instClass)
with progress_report(_("Running post-installation scripts")):
runPostScripts(ksdata.scripts)
@@ -209,9 +207,8 @@ def doInstall(storage, payload, ksdata, instClass):
# Discover information about realms to join,
# to determine additional packages
- if willRunRealmd:
- with progress_report(_("Discovering realm to join")):
- ksdata.realm.setup()
+ with progress_report(_("Discovering realm to join"), cond=lambda: willRunRealmd):
+ ksdata.realm.setup()
# Check for additional packages
ksdata.authconfig.setup()
@@ -243,9 +240,8 @@ def doInstall(storage, payload, ksdata, instClass):
payload.writeStorageLate()
# Do bootloader.
- if willInstallBootloader:
- with progress_report(_("Installing boot loader")):
- writeBootLoader(storage, payload, instClass, ksdata)
+ with progress_report(_("Installing boot loader"), cond=lambda: willInstallBootloader):
+ writeBootLoader(storage, payload, instClass, ksdata)
with progress_report(_("Performing post-installation setup tasks")):
payload.postInstall()
diff --git a/pyanaconda/progress.py b/pyanaconda/progress.py
index f1d20ad..4594361 100644
--- a/pyanaconda/progress.py
+++ b/pyanaconda/progress.py
@@ -43,11 +43,14 @@ progressQ.addMessage("quit", 1) # exit_code
# Surround a block of code with progress updating. Before the code runs, the
# message is updated so the user can tell what's about to take so long.
# Afterwards, the progress bar is updated to reflect that the task is done.
+# An optional conditional can be given, in which case it must pass for the
+# block to be executed.
@contextmanager
-def progress_report(message):
- progress_message(message)
- yield
- progress_step(message)
+def progress_report(message, cond=None):
+ if not cond or cond():
+ progress_message(message)
+ yield
+ progress_step(message)
def progress_message(message):
progressQ.send_message(message)
--
2.4.3
More information about the anaconda-patches
mailing list