[master/rhel7-branch] Fix error handling in cmdline mode. (#1034773)

Samantha N. Bueno sbueno+anaconda at redhat.com
Tue Mar 11 00:31:00 UTC 2014


Handle CmdlineError properly so that the installer actually reboots
itself.

Resolves: rhbz#1034773
---
 pyanaconda/exception.py            | 44 +++++++++++++++++++-------------------
 pyanaconda/packaging/yumpayload.py | 15 ++++++-------
 pyanaconda/ui/tui/__init__.py      |  2 +-
 3 files changed, 30 insertions(+), 31 deletions(-)

diff --git a/pyanaconda/exception.py b/pyanaconda/exception.py
index 9767c00..6e9710e 100644
--- a/pyanaconda/exception.py
+++ b/pyanaconda/exception.py
@@ -92,23 +92,6 @@ class AnacondaExceptionHandler(ExceptionHandler):
                              "The installer will now terminate.") % str(value)
             self.intf.messageWindow(_("Hardware error occured"), hw_error_msg)
             sys.exit(0)
-        elif (issubclass (ty, CmdlineError)):
-
-            cmdline_error_msg = _("\nThe installation was stopped due to an "
-                                  "error which occurred while running in "
-                                  "non-interactive cmdline mode. Since there can "
-                                  "not be any questions in cmdline mode, edit "
-                                  "your kickstart file and retry installation. "
-                                  "\nThe exact error message is: \n\n%s. \n\nThe "
-                                  "installer will now terminate.") % str(value)
-
-            # since there is no UI in cmdline mode and it is completely
-            # non-interactive, we can't show a message window asking the user
-            # to acknowledge the error; instead, print the error out and sleep
-            # for a few seconds before exiting the installer
-            print(cmdline_error_msg)
-            time.sleep(180)
-            sys.exit(0)
         else:
             try:
                 # pylint: disable-msg=E0611
@@ -139,11 +122,28 @@ class AnacondaExceptionHandler(ExceptionHandler):
                 # X not running (Gtk cannot be initialized)
                 if threadMgr.in_main_thread():
                     log.debug("In the main thread, running exception handler")
-                    print "An unknown error has occured, look at the "\
-                        "/tmp/anaconda-tb* file(s) for more details"
-                    # in the main thread, run exception handler
-                    super(AnacondaExceptionHandler, self).handleException(
-                                                            dump_info)
+                    if (issubclass (ty, CmdlineError)):
+                        cmdline_error_msg = _("\nThe installation was stopped due to an "
+                                              "error which occurred while running in "
+                                              "non-interactive cmdline mode. Since there can "
+                                              "not be any questions in cmdline mode, edit "
+                                              "your kickstart file and retry installation. "
+                                              "\nThe exact error message is: \n\n%s. \n\nThe "
+                                              "installer will now terminate.") % str(value)
+
+                        # since there is no UI in cmdline mode and it is completely
+                        # non-interactive, we can't show a message window asking the user
+                        # to acknowledge the error; instead, print the error out and sleep
+                        # for a few seconds before exiting the installer
+                        print(cmdline_error_msg)
+                        time.sleep(10)
+                        sys.exit()
+                    else:
+                        print "An unknown error has occured, look at the "\
+                            "/tmp/anaconda-tb* file(s) for more details"
+                        # in the main thread, run exception handler
+                        super(AnacondaExceptionHandler, self).handleException(
+                                                                dump_info)
                 else:
                     log.debug("In a non-main thread, sending a message with "
                              "exception data")
diff --git a/pyanaconda/packaging/yumpayload.py b/pyanaconda/packaging/yumpayload.py
index 824c8a4..211e5e9 100644
--- a/pyanaconda/packaging/yumpayload.py
+++ b/pyanaconda/packaging/yumpayload.py
@@ -1350,14 +1350,13 @@ reposdir=%s
         if self.data.packages.handleMissing == KS_MISSING_IGNORE:
             return
 
-        if errorHandler.cb(exn, str(exn)) == ERROR_RAISE:
-            if flags.automatedInstall and not flags.ksprompt:
-                # If we're doing non-interactive ks install, raise CmdlineError
-                # otherwise the system will just reboot automatically
-                errtxt = _("CmdlineError: Missing package: %s" % str(exn))
-                log.error(errtxt)
-                raise CmdlineError(errtxt)
-
+        # If we're doing non-interactive ks install, raise CmdlineError,
+        # otherwise the system will just reboot automatically
+        if flags.automatedInstall and not flags.ksprompt:
+            errtxt = _("CmdlineError: Missing package: %s" % str(exn))
+            log.error(errtxt)
+            raise CmdlineError(errtxt)
+        elif errorHandler.cb(exn, str(exn)) == ERROR_RAISE:
             # The progress bar polls kind of slowly, thus installation could
             # still continue for a bit before the quit message is processed.
             # Let's sleep forever to prevent any further actions and wait for
diff --git a/pyanaconda/ui/tui/__init__.py b/pyanaconda/ui/tui/__init__.py
index c3e8471..96e4ef7 100644
--- a/pyanaconda/ui/tui/__init__.py
+++ b/pyanaconda/ui/tui/__init__.py
@@ -278,7 +278,7 @@ class TextUserInterface(ui.UserInterface):
            times where anaconda cannot make a reasonable decision.  We don't
            want to overwhelm the user with choices.
 
-           When cmdline mode is active, the default will be to answer no.
+            When cmdline mode is active the default will be to answer now.
         """
 
         return self._show_message_in_main_thread(self._showYesNoQuestion, (message,))
-- 
1.8.3.1



More information about the anaconda-patches mailing list