From f679cafc5541b30b31bd5039004b6ccdcae3b54c Mon Sep 17 00:00:00 2001 From: Martin Sivak Date: Thu, 14 Mar 2013 14:19:50 +0100 Subject: Improve generic FirstbootMixIns - disable already configured spokes in I-S --- pyanaconda/ui/common.py | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py index 8248bd56a..66d814ac8 100644 --- a/pyanaconda/ui/common.py +++ b/pyanaconda/ui/common.py @@ -26,7 +26,7 @@ import inspect import copy import sys import types - +import collections import logging log = logging.getLogger("anaconda") @@ -119,37 +119,51 @@ class UIObject(object): def data(self): return self._data -class FirstbootSpokeMixIn(object): - """This MixIn class marks Spokes as usable for Firstboot - and Anaconda. - """ +class FirstbootOnlySpokeMixIn(object): + """This MixIn class marks Spokes as usable for Firstboot.""" @classmethod def should_run(cls, environment, data): """This method is responsible for beginning Spoke initialization in the firstboot environment (even before __init__). - It should return True if the spoke is to be shown - and False if it should be skipped. + It should return True if the spoke is to be shown and False + if it should be skipped. It might be called multiple times, with or without (None) the data argument. """ - return environment in ("anaconda", "firstboot") + # Firstboot / initital-setup does not support instClass, storage + # and payload so it should be possible to use a bit dirty trick + # with the completed property on unitialized Spoke. + # Completed in shared spokes should mostly use only information + # passed from self.data anyway.. + self = collections.namedtuple(cls.__name__, ["data"])(data) + + # you can call property as a method using it's fget method + return (environment in ("firstboot")) and \ + (self.data is None or not cls.completed.fget(self)) -class FirstbootOnlySpokeMixIn(object): - """This MixIn class marks Spokes as usable for Firstboot.""" +class FirstbootSpokeMixIn(FirstbootOnlySpokeMixIn): + """This MixIn class marks Spokes as usable for Firstboot + and Anaconda. + """ @classmethod def should_run(cls, environment, data): """This method is responsible for beginning Spoke initialization in the firstboot environment (even before __init__). - It should return True if the spoke is to be shown and False - if it should be skipped. + It should return True if the spoke is to be shown + and False if it should be skipped. It might be called multiple times, with or without (None) the data argument. """ - return environment in ("firstboot") + + # calling parent's class func is a bit tricky, super(parent, cls) + # is one possible way, but using the im_func attribute will + # work even with old style classes + return (environment in ("anaconda")) or \ + FirstbootOnlySpokeMixIn.should_run.im_func(cls, environment, data) class Spoke(UIObject): """A Spoke is a single configuration screen. There are several different -- cgit