[PATCH 2/2] Change how we test if the GUI is available in the anaconda script.

Vratislav Podzimek vpodzime at redhat.com
Fri Sep 19 07:23:35 UTC 2014

From: Chris Lumens <clumens at redhat.com>

Simply trying to import early on means we get the "Unable to init server" and
XDG_RUNTIME_DIR errors.  Instead, test to see if the GUI is available to be
imported (which it will if it's included in the tree).  We can still fall back
to text mode if there are X problems, though.

Related: rhbz#1078868
Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
 anaconda | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/anaconda b/anaconda
index f4aa8c3..5ab5c8c 100755
--- a/anaconda
+++ b/anaconda
@@ -526,10 +526,11 @@ def setupDisplay(anaconda, opts, addon_paths=None):
             vncS.vncconnectport = anaconda.ksdata.vnc.port
     if anaconda.displayMode == "g":
-        try:
-            # pylint: disable-msg=W0612
-            from pyanaconda.ui.gui import GraphicalUserInterface
-        except ImportError:
+        import pkgutil
+        import pyanaconda.ui
+        mods = (tup[1] for tup in pkgutil.iter_modules(pyanaconda.ui.__path__, "pyanaconda.ui."))
+        if "pyanaconda.ui.gui" not in mods:
             stdoutLog.warning("Graphical user interface not available, falling back to text mode")
             anaconda.displayMode = "t"
             flags.usevnc = 0

More information about the anaconda-patches mailing list