summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMartin Sivak <msivak@redhat.com>2013-03-14 14:19:50 +0100
committerMartin Sivak <msivak@redhat.com>2013-03-28 18:25:11 +0100
commitf679cafc5541b30b31bd5039004b6ccdcae3b54c (patch)
tree97af07f31e32fdf3e8859172f6fe5a966cee54f2
parent8a63240f00bf9abcc966b8cba98fe3730e8c6529 (diff)
downloadanaconda-msivak.tar.gz
anaconda-msivak.tar.xz
anaconda-msivak.zip
Improve generic FirstbootMixIns - disable already configured spokes in I-Smsivak
-rw-r--r--pyanaconda/ui/common.py40
1 files 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