[PATCH 01/16] Split completed and mandatory attributes

Martin Sivak msivak at redhat.com
Thu Dec 6 15:46:24 UTC 2012


---
 pyanaconda/ui/common.py                    | 18 ++++++++++++++----
 pyanaconda/ui/gui/hubs/__init__.py         |  4 ++--
 pyanaconda/ui/gui/spokes/__init__.py       |  2 +-
 pyanaconda/ui/gui/spokes/datetime_spoke.py |  4 ++++
 pyanaconda/ui/gui/spokes/network.py        |  7 +++++--
 pyanaconda/ui/gui/spokes/password.py       |  4 ++++
 pyanaconda/ui/gui/spokes/software.py       |  4 ++++
 pyanaconda/ui/gui/spokes/source.py         |  4 ++++
 pyanaconda/ui/tui/hubs/__init__.py         |  2 +-
 pyanaconda/ui/tui/spokes/password.py       |  4 ++++
 pyanaconda/ui/tui/spokes/storage.py        |  4 ++++
 pyanaconda/ui/tui/spokes/time.py           |  4 ++++
 12 files changed, 51 insertions(+), 10 deletions(-)

diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py
index bcac8b4..3452a04 100644
--- a/pyanaconda/ui/common.py
+++ b/pyanaconda/ui/common.py
@@ -171,13 +171,23 @@ class Spoke(UIObject):
 
     @property
     def completed(self):
-        """Has this spoke been visited and completed?  If not, a special warning
-           icon will be shown on the Hub beside the spoke, and a highlighted
-           message will be shown at the bottom of the Hub.  Installation will not
-           be allowed to proceed until all spokes are complete.
+        """Has this spoke been visited and completed?  If not and the spoke is
+           mandatory, a special warning icon will be shown on the Hub beside the
+           spoke, and a highlighted message will be shown at the bottom of the
+           Hub.  Installation will not be allowed to proceed until all mandatory
+           spokes are complete.
         """
         return False
 
+    @property
+    def mandatory(self):
+        """Mark this spoke as mandatory. Installation will not be allowed
+           to proceed until all mandatory spokes are complete.
+
+           Spokes are mandatory unless marked as not being so.
+        """
+        return True
+    
     def execute(self):
         """Cause the data object to take effect on the target system.  This will
            usually be as simple as calling one or more of the execute methods on
diff --git a/pyanaconda/ui/gui/hubs/__init__.py b/pyanaconda/ui/gui/hubs/__init__.py
index c0df863..642ebb3 100644
--- a/pyanaconda/ui/gui/hubs/__init__.py
+++ b/pyanaconda/ui/gui/hubs/__init__.py
@@ -200,14 +200,14 @@ class Hub(GUIObject, common.Hub):
         spoke.selector.set_sensitive(spoke.ready)
         spoke.selector.set_property("status", spoke.status)
         spoke.selector.set_tooltip_markup(spoke.status)
-        spoke.selector.set_incomplete(not spoke.completed)
+        spoke.selector.set_incomplete(not spoke.completed and spoke.mandatory)
         self._handleCompleteness(spoke)
 
     def _handleCompleteness(self, spoke):
         # Add the spoke to the incomplete list if it's now incomplete, and make
         # sure it's not on the list if it's now complete.  Then show the box if
         # it's needed and hide it if it's not.
-        if spoke.completed:
+        if not spoke.mandatory or spoke.completed:
             if spoke in self._incompleteSpokes:
                 self._incompleteSpokes.remove(spoke)
         else:
diff --git a/pyanaconda/ui/gui/spokes/__init__.py b/pyanaconda/ui/gui/spokes/__init__.py
index 9633eb9..f25d30c 100644
--- a/pyanaconda/ui/gui/spokes/__init__.py
+++ b/pyanaconda/ui/gui/spokes/__init__.py
@@ -17,7 +17,7 @@
 # Red Hat, Inc.
 #
 # Red Hat Author(s): Chris Lumens <clumens at redhat.com>
-#
+#                    Martin Sivak <msivak at redhat.com>
 
 from pyanaconda.ui import common
 from pyanaconda.ui.common import collect
diff --git a/pyanaconda/ui/gui/spokes/datetime_spoke.py b/pyanaconda/ui/gui/spokes/datetime_spoke.py
index 5bc07d0..91af50f 100644
--- a/pyanaconda/ui/gui/spokes/datetime_spoke.py
+++ b/pyanaconda/ui/gui/spokes/datetime_spoke.py
@@ -426,6 +426,10 @@ class DatetimeSpoke(NormalSpoke):
     def completed(self):
         return timezone.is_valid_timezone(self.data.timezone.timezone)
 
+    @property
+    def mandatory(self):
+        return True        
+    
     def refresh(self):
         #update the displayed time
         self._update_datetime_timer_id = GLib.timeout_add_seconds(1,
diff --git a/pyanaconda/ui/gui/spokes/network.py b/pyanaconda/ui/gui/spokes/network.py
index e5b91d5..b953f61 100644
--- a/pyanaconda/ui/gui/spokes/network.py
+++ b/pyanaconda/ui/gui/spokes/network.py
@@ -980,10 +980,13 @@ class NetworkSpoke(NormalSpoke):
     @property
     def completed(self):
         # TODO: check also if source requires updates when implemented
-        return (self.data.method.method not in ("url", "nfs") or
-                len(self.network_control_box.activated_connections()) > 0)
+        return len(self.network_control_box.activated_connections()) > 0
 
     @property
+    def mandatory(self):
+        return self.data.method.method in ("url", "nfs")
+    
+    @property
     def status(self):
         """ A short string describing which devices are connected. """
         msg = _("Unknown")
diff --git a/pyanaconda/ui/gui/spokes/password.py b/pyanaconda/ui/gui/spokes/password.py
index ac113af..c273846 100644
--- a/pyanaconda/ui/gui/spokes/password.py
+++ b/pyanaconda/ui/gui/spokes/password.py
@@ -82,6 +82,10 @@ class PasswordSpoke(NormalSpoke):
         else:
             return _("Root password is not set")
 
+    @property
+    def mandatory(self):
+        return False
+        
     def apply(self):
         self.data.rootpw.password = cryptPassword(self._password)
         self.data.rootpw.isCrypted = True
diff --git a/pyanaconda/ui/gui/spokes/software.py b/pyanaconda/ui/gui/spokes/software.py
index 8fd4c59..5ad9028 100644
--- a/pyanaconda/ui/gui/spokes/software.py
+++ b/pyanaconda/ui/gui/spokes/software.py
@@ -131,6 +131,10 @@ class SoftwareSelectionSpoke(NormalSpoke):
             return self._get_selected_environment() is not None and processingDone
 
     @property
+    def mandatory(self):
+        return True
+        
+    @property
     def ready(self):
         # By default, the software selection spoke is not ready.  We have to
         # wait until the installation source spoke is completed.  This could be
diff --git a/pyanaconda/ui/gui/spokes/source.py b/pyanaconda/ui/gui/spokes/source.py
index fc1aacc..ac39ce6 100644
--- a/pyanaconda/ui/gui/spokes/source.py
+++ b/pyanaconda/ui/gui/spokes/source.py
@@ -581,6 +581,10 @@ class SourceSpoke(NormalSpoke):
         return not self._error and self.status and self.status != _("Nothing selected")
 
     @property
+    def mandatory(self):
+        return True
+        
+    @property
     def ready(self):
         from pyanaconda.threads import threadMgr
         # By default, the source spoke is not ready.  We have to wait until
diff --git a/pyanaconda/ui/tui/hubs/__init__.py b/pyanaconda/ui/tui/hubs/__init__.py
index ae5b0b8..b7dade1 100644
--- a/pyanaconda/ui/tui/hubs/__init__.py
+++ b/pyanaconda/ui/tui/hubs/__init__.py
@@ -103,7 +103,7 @@ class TUIHub(TUIObject, common.Hub):
             # don't continue
             if key == _('c'):
                 for spoke in self._spokes.values():
-                    if not spoke.completed:
+                    if not spoke.completed and spoke.mandatory:
                         print(_("Please complete all spokes before continuing"))
                         return False
             return key
diff --git a/pyanaconda/ui/tui/spokes/password.py b/pyanaconda/ui/tui/spokes/password.py
index 8942e17..f812678 100644
--- a/pyanaconda/ui/tui/spokes/password.py
+++ b/pyanaconda/ui/tui/spokes/password.py
@@ -44,6 +44,10 @@ class PasswordSpoke(NormalTUISpoke):
         return bool(self.data.rootpw.password or self.data.rootpw.lock)
 
     @property
+    def mandatory(self):
+        return True
+
+    @property
     def status(self):
         if self.data.rootpw.password:
             return _("Password is set.")
diff --git a/pyanaconda/ui/tui/spokes/storage.py b/pyanaconda/ui/tui/spokes/storage.py
index 0032f2a..b5d483f 100644
--- a/pyanaconda/ui/tui/spokes/storage.py
+++ b/pyanaconda/ui/tui/spokes/storage.py
@@ -115,6 +115,10 @@ class StorageSpoke(NormalTUISpoke):
         return self._ready and not threadMgr.get("AnaStorageWatcher")
 
     @property
+    def mandatory(self):
+        return True
+
+    @property
     def status(self):
         """ A short string describing the current status of storage setup. """
         msg = _("No disks selected")
diff --git a/pyanaconda/ui/tui/spokes/time.py b/pyanaconda/ui/tui/spokes/time.py
index cc26ec3..6a47401 100644
--- a/pyanaconda/ui/tui/spokes/time.py
+++ b/pyanaconda/ui/tui/spokes/time.py
@@ -48,6 +48,10 @@ class TimeZoneSpoke(NormalTUISpoke):
         return bool(self.data.timezone.timezone or self._selection)
 
     @property
+    def mandatory(self):
+        return True
+
+    @property
     def status(self):
         if self.data.timezone.timezone:
             return _("%s timezone") % self.data.timezone.timezone
-- 
1.7.11.7



More information about the anaconda-patches mailing list