[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[master] Allow answering the uninitialized disk question more than once.



With kickstart, if the user only had a single disk, said 'no' to
reinitialization and then pressed 'back' when informed no usable disks
were found, he ended up in the timezone screen.

Resolves: rhbz#730959
---
 pyanaconda/dispatch.py                 |    2 ++
 pyanaconda/storage/__init__.py         |   15 ++++++++++-----
 tests/pyanaconda_test/dispatch_test.py |   13 +++++++++++++
 3 files changed, 25 insertions(+), 5 deletions(-)

diff --git a/pyanaconda/dispatch.py b/pyanaconda/dispatch.py
index 5d47828..6aeae38 100644
--- a/pyanaconda/dispatch.py
+++ b/pyanaconda/dispatch.py
@@ -204,6 +204,8 @@ class Dispatcher(object):
     def can_go_back(self):
         # Begin with the step before this one. If all steps are skipped,
         # we can not go backwards from this one.
+        if self.step == None:
+            return False
         i = self._step_index() - 1
         while i >= 0:
             sname = self.steps[i].name
diff --git a/pyanaconda/storage/__init__.py b/pyanaconda/storage/__init__.py
index abfdb55..ada53a6 100644
--- a/pyanaconda/storage/__init__.py
+++ b/pyanaconda/storage/__init__.py
@@ -116,13 +116,18 @@ def storageInitialize(anaconda):
         storage.reset()
 
     if not storage.disks:
+        custom_buttons=[_("_Try again"), _("_Exit installer")]
+        if anaconda.dispatch.can_go_back():
+            custom_buttons = [_("_Back"), _("_Exit installer")]
         rc = anaconda.intf.messageWindow(_("No disks found"),
-                _("No usable disks have been found."),
-                type="custom",
-                custom_buttons = [_("Back"), _("_Exit installer")],
-                default=0)
+                                         _("No usable disks have been found."),
+                                         type="custom",
+                                         custom_buttons=custom_buttons, default=0)
         if rc == 0:
-            return DISPATCH_BACK
+            if anaconda.dispatch.can_go_back():
+                return DISPATCH_BACK
+            else:
+                return storageInitialize(anaconda)
         sys.exit(1)
 
 # dispatch.py helper function
diff --git a/tests/pyanaconda_test/dispatch_test.py b/tests/pyanaconda_test/dispatch_test.py
index be10267..b9243f6 100644
--- a/tests/pyanaconda_test/dispatch_test.py
+++ b/tests/pyanaconda_test/dispatch_test.py
@@ -146,6 +146,19 @@ class DispatchTest(mock.TestCase):
         self.anaconda_obj = mock.Mock()
         return Dispatcher(self.anaconda_obj)
 
+    def can_go_back_test(self):
+        d = self._getDispatcher()
+        d.schedule_steps("rescue", "kickstart", "language", "keyboard")
+        # can not go back if dispatcher hasn't moved out of the initial state
+        self.assertFalse(d.can_go_back())
+        # can not go back if all preceding steps are direct
+        d.step = "language"
+        self.assertFalse(d.can_go_back())
+        d.done_steps("language")
+        # but in "keyboard" we can go back to "language"
+        d.step = "keyboard"
+        self.assertTrue(d.can_go_back())
+
     def done_test(self):
         from pyanaconda.dispatch import Dispatcher
         from pyanaconda.dispatch import Step
-- 
1.7.6


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]