Also make use of the all() method to clean up some code, and fix storage spoke some more.
Tested on branched with a local compose and updates.img.
-jlk
This is necessary for doing installs via kickstart where we've got the data even though we haven't gone through the spoke.
Also handle the case where the account could be locked. --- pyanaconda/ui/tui/spokes/password.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/pyanaconda/ui/tui/spokes/password.py b/pyanaconda/ui/tui/spokes/password.py index 98da8ac..b556af2 100644 --- a/pyanaconda/ui/tui/spokes/password.py +++ b/pyanaconda/ui/tui/spokes/password.py @@ -21,6 +21,7 @@
from pyanaconda.ui.tui.spokes import NormalTUISpoke from pyanaconda.ui.tui.simpleline import TextWidget +from pyanaconda.flags import flags import getpass
import gettext @@ -37,14 +38,16 @@ class PasswordSpoke(NormalTUISpoke):
@property def completed(self): - return True + return bool(self.data.rootpw.password or self.data.rootpw.lock)
@property def status(self): - if not self.data.rootpw.password: - return _("Root account disabled.") - else: + if self.data.rootpw.password: return _("Password is set.") + elif self.data.rootpw.lock: + return _("Root account is disabled.") + else: + return _("Password is not set.")
def refresh(self, args = None): NormalTUISpoke.refresh(self, args)
On 09/19/2012 04:54 PM, Jesse Keating wrote:
+from pyanaconda.flags import flags
Eh, this import isn't used in this version of the patch, but a later update to this spoke to bring up it's features should use it.
The gui spoke changed it's completeness method after this spoke was written. This change syncs it back up and makes things work for kickstart installs. --- pyanaconda/ui/tui/spokes/storage.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py index d1b85c3..b74096f 100644 --- a/pyanaconda/ui/tui/spokes/storage.py +++ b/pyanaconda/ui/tui/spokes/storage.py @@ -101,7 +101,10 @@ class StorageSpoke(NormalTUISpoke):
@property def completed(self): - return bool(self.selected_disks and not self.errors) + from pyanaconda.threads import threadMgr + return (threadMgr.get("AnaCheckStorageThread") is None and + self.storage.rootDevice is not None and + not self.errors)
@property def status(self):
The gui spoke changed it's completeness method after this spoke was written. This change syncs it back up and makes things work for kickstart installs.
I bet this will happen again, too. Can we have both interfaces use the same completed method without making a bigger mess of code somehow?
- Chris
On 09/24/2012 11:43 AM, Chris Lumens wrote:
The gui spoke changed it's completeness method after this spoke was written. This change syncs it back up and makes things work for kickstart installs.
I bet this will happen again, too. Can we have both interfaces use the same completed method without making a bigger mess of code somehow?
There are a number of things the two spokes could share, it's on my to do list of abstracting some of that up to a common/ level.
I bet this will happen again, too. Can we have both interfaces use the same completed method without making a bigger mess of code somehow?
There are a number of things the two spokes could share, it's on my to do list of abstracting some of that up to a common/ level.
If you need someone else thinking about it, let me know. That's the sort of thing I'm supposed to be doing anyway.
- Chris
We weren't setting the ready state correctly, just depending upon waiting on the storage thread when entering the spoke. This doesn't work so well with kickstarts where the spoke isn't entered.
Also do the threads import once and only once. --- pyanaconda/ui/tui/spokes/storage.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py index b74096f..ba5e667 100644 --- a/pyanaconda/ui/tui/spokes/storage.py +++ b/pyanaconda/ui/tui/spokes/storage.py @@ -28,6 +28,7 @@ from pyanaconda.ui.tui.simpleline import TextWidget, CheckboxWidget from pyanaconda.storage.size import Size from pyanaconda.flags import flags from pyanaconda.kickstart import doKickstartStorage +from pyanaconda.threads import threadMgr, AnacondaThread
from pykickstart.constants import *
@@ -93,6 +94,8 @@ class StorageSpoke(NormalTUISpoke): NormalTUISpoke.__init__(self, app, data, storage, payload, instclass) self.selected_disks = self.data.ignoredisk.onlyuse[:]
+ self._ready = False + # This list gets set up once in initialize and should not be modified # except perhaps to add advanced devices. It will remain the full list # of disks that can be included in the install. @@ -101,12 +104,17 @@ class StorageSpoke(NormalTUISpoke):
@property def completed(self): - from pyanaconda.threads import threadMgr return (threadMgr.get("AnaCheckStorageThread") is None and self.storage.rootDevice is not None and not self.errors)
@property + def ready(self): + # By default, the storage spoke is not ready. We have to wait until + # storageInitialize is done. + return self._ready and not threadMgr.get("AnaExecuteStorageThread") + + @property def status(self): """ A short string describing the current status of storage setup. """ msg = _("No disks selected") @@ -165,8 +173,6 @@ class StorageSpoke(NormalTUISpoke): NormalTUISpoke.refresh(self, args)
# Join the initialization thread to block on it - from pyanaconda.threads import threadMgr - initThread = threadMgr.get("AnaStorageWatcher") if initThread: # This print is foul. Need a better message display @@ -265,8 +271,6 @@ class StorageSpoke(NormalTUISpoke): log.warn(w)
def initialize(self): - from pyanaconda.threads import threadMgr, AnacondaThread - NormalTUISpoke.initialize(self)
threadMgr.add(AnacondaThread(name="AnaStorageWatcher", @@ -279,8 +283,6 @@ class StorageSpoke(NormalTUISpoke): # Secondary initialize so wait for the storage thread # to complete before populating our disk list
- from pyanaconda.threads import threadMgr - storageThread = threadMgr.get("AnaStorageThread") if storageThread: storageThread.join()
On Wed, 2012-09-19 at 16:54 -0700, Jesse Keating wrote:
We weren't setting the ready state correctly, just depending upon waiting on the storage thread when entering the spoke. This doesn't work so well with kickstarts where the spoke isn't entered.
Also do the threads import once and only once.
pyanaconda/ui/tui/spokes/storage.py | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py index b74096f..ba5e667 100644 --- a/pyanaconda/ui/tui/spokes/storage.py +++ b/pyanaconda/ui/tui/spokes/storage.py @@ -28,6 +28,7 @@ from pyanaconda.ui.tui.simpleline import TextWidget, CheckboxWidget from pyanaconda.storage.size import Size from pyanaconda.flags import flags from pyanaconda.kickstart import doKickstartStorage +from pyanaconda.threads import threadMgr, AnacondaThread
from pykickstart.constants import *
@@ -93,6 +94,8 @@ class StorageSpoke(NormalTUISpoke): NormalTUISpoke.__init__(self, app, data, storage, payload, instclass) self.selected_disks = self.data.ignoredisk.onlyuse[:]
self._ready = False# This list gets set up once in initialize and should not be modified # except perhaps to add advanced devices. It will remain the full list # of disks that can be included in the install.@@ -101,12 +104,17 @@ class StorageSpoke(NormalTUISpoke):
@property def completed(self):
from pyanaconda.threads import threadMgr return (threadMgr.get("AnaCheckStorageThread") is None and self.storage.rootDevice is not None and not self.errors)@property
- def ready(self):
# By default, the storage spoke is not ready. We have to wait until# storageInitialize is done.return self._ready and not threadMgr.get("AnaExecuteStorageThread")
Two points here: 1) it would be better to use "threadMgr.get("...") is None"
2) the comment mentions the storageInitialize, which is a target of "AnaStorageThread", but you are checking the "AnaExecuteStorageThread" (which doesn't make sense for the "ready" property)
Also one thing that applies to both TUI and GUI -- could we please use constants for the names of threads, that are started in one module and joined in another one? E.g. having "AnaStorageThread" as a STORAGE_INIT_THREAD_NAME constant in the storage module and use it in anaconda and GUI/TUI spokes.
On 09/20/2012 01:15 AM, Vratislav Podzimek wrote:
@property
- def ready(self):
# By default, the storage spoke is not ready. We have to wait until# storageInitialize is done.return self._ready and not threadMgr.get("AnaExecuteStorageThread")Two points here:
- it would be better to use "threadMgr.get("...") is None"
Why explicitly check against None? Is there a problem with booling the value of it?
- the comment mentions the storageInitialize, which is a target of
"AnaStorageThread", but you are checking the "AnaExecuteStorageThread" (which doesn't make sense for the "ready" property)
Good catch, I had wrong thread names everywhere :/
Also one thing that applies to both TUI and GUI -- could we please use constants for the names of threads, that are started in one module and joined in another one? E.g. having "AnaStorageThread" as a STORAGE_INIT_THREAD_NAME constant in the storage module and use it in anaconda and GUI/TUI spokes.
This is a also a good point and something I'll look through as part of this patch set.
On Thu, 2012-09-20 at 16:23 -0700, Jesse Keating wrote:
On 09/20/2012 01:15 AM, Vratislav Podzimek wrote:
@property
- def ready(self):
# By default, the storage spoke is not ready. We have to wait until# storageInitialize is done.return self._ready and not threadMgr.get("AnaExecuteStorageThread")Two points here:
- it would be better to use "threadMgr.get("...") is None"
Why explicitly check against None? Is there a problem with booling the value of it?
The only reason is that we do it like that in various places, but I'm okay with both.
This follows the same design as GUI. If the install is automated, and all the spokes are complete, proceed into the installation phase. However if there are incomplete spokes, let the user finish those spokes. As soon as all spokes are complete jump straight to the install phase.
Note that any new spoke that has a background process that could make it not be "ready" immediately is going to have to be accounted for here, which is ugly. Perhaps a object attribute that is a list of potential threads to join would work? --- pyanaconda/ui/tui/hubs/summary.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
diff --git a/pyanaconda/ui/tui/hubs/summary.py b/pyanaconda/ui/tui/hubs/summary.py index 8c2f4cc..7a74eca 100644 --- a/pyanaconda/ui/tui/hubs/summary.py +++ b/pyanaconda/ui/tui/hubs/summary.py @@ -17,9 +17,13 @@ # Red Hat, Inc. # # Red Hat Author(s): Martin Sivak msivak@redhat.com +# Jesse Keating jkeating@redhat.com #
from pyanaconda.ui.tui.hubs import TUIHub +from pyanaconda.flags import flags +import sys +import time
import gettext _ = lambda x: gettext.ldgettext("anaconda", x) @@ -27,3 +31,29 @@ _ = lambda x: gettext.ldgettext("anaconda", x) class SummaryHub(TUIHub): title = _("Install hub") categories = ["source", "localization", "destination", "password"] + + def __init__(self, app, data, storage, payload, instclass): + TUIHub.__init__(self, app, data, storage, payload, instclass) + if flags.automatedInstall: + sys.stdout.write(_("Starting automated install")) + sys.stdout.flush() + spokes = self._keys.values() + while True: + if all(spoke.ready for spoke in spokes): + print('') + break + sys.stdout.write('.') + sys.stdout.flush() + time.sleep(1) + + for spoke in spokes: + spoke.execute() + + # override the prompt so that we can skip user input on kickstarts + # where all the data is in hand. If not in hand, do the actual prompt. + def prompt(self, args=None): + if flags.automatedInstall and \ + all(spoke.completed for spoke in self._keys.values()): + self.close() + return None + return TUIHub.prompt(self, args) \ No newline at end of file
On Wed, 2012-09-19 at 16:54 -0700, Jesse Keating wrote:
This follows the same design as GUI. If the install is automated, and all the spokes are complete, proceed into the installation phase. However if there are incomplete spokes, let the user finish those spokes. As soon as all spokes are complete jump straight to the install phase.
Note that any new spoke that has a background process that could make it not be "ready" immediately is going to have to be accounted for here, which is ugly. Perhaps a object attribute that is a list of potential threads to join would work?
pyanaconda/ui/tui/hubs/summary.py | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)
diff --git a/pyanaconda/ui/tui/hubs/summary.py b/pyanaconda/ui/tui/hubs/summary.py index 8c2f4cc..7a74eca 100644 --- a/pyanaconda/ui/tui/hubs/summary.py +++ b/pyanaconda/ui/tui/hubs/summary.py @@ -17,9 +17,13 @@ # Red Hat, Inc. # # Red Hat Author(s): Martin Sivak msivak@redhat.com +# Jesse Keating jkeating@redhat.com #
from pyanaconda.ui.tui.hubs import TUIHub +from pyanaconda.flags import flags +import sys +import time
import gettext _ = lambda x: gettext.ldgettext("anaconda", x) @@ -27,3 +31,29 @@ _ = lambda x: gettext.ldgettext("anaconda", x) class SummaryHub(TUIHub): title = _("Install hub") categories = ["source", "localization", "destination", "password"]
- def __init__(self, app, data, storage, payload, instclass):
TUIHub.__init__(self, app, data, storage, payload, instclass)if flags.automatedInstall:sys.stdout.write(_("Starting automated install"))sys.stdout.flush()spokes = self._keys.values()while True:if all(spoke.ready for spoke in spokes):print('')breaksys.stdout.write('.')sys.stdout.flush()time.sleep(1)
I believe there's no reason for a while-True-cycle that starts with "if something, then break". You can rewrite it as:
while not all(spoke.ready for spoke in spokes): sys.stdout.write('.') sys.stdout.flush() time.sleep(1)
anaconda-patches@lists.fedorahosted.org