[PATCH 2/2] Import GUI-specific stuff only when running GUI in entropy handling

Anne Mulhern amulhern at redhat.com
Wed Oct 8 19:14:51 UTC 2014





----- Original Message -----
> From: "Vratislav Podzimek" <vpodzime at redhat.com>
> To: anaconda-patches at lists.fedorahosted.org
> Sent: Wednesday, October 8, 2014 4:55:40 AM
> Subject: [PATCH 2/2] Import GUI-specific stuff only when running GUI in	entropy handling
> 
> Otherwise crashes happen if only the anaconda-tui package is installed.
> 
> Related: rhbz#1073679
> Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> ---
>  pyanaconda/ui/gui/spokes/lib/entropy_dialog.py | 10 +++++++++-
>  pyanaconda/ui/lib/entropy.py                   | 20 ++++++--------------
>  2 files changed, 15 insertions(+), 15 deletions(-)
> 
> diff --git a/pyanaconda/ui/gui/spokes/lib/entropy_dialog.py
> b/pyanaconda/ui/gui/spokes/lib/entropy_dialog.py
> index 833e579..d04b08d 100644
> --- a/pyanaconda/ui/gui/spokes/lib/entropy_dialog.py
> +++ b/pyanaconda/ui/gui/spokes/lib/entropy_dialog.py
> @@ -24,9 +24,17 @@ import time
>  from gi.repository import Gtk, GLib
>  
>  from pyanaconda.ui.gui import GUIObject
> +from pyanaconda.ui.gui.utils import gtk_action_wait
>  from blivet.util import get_current_entropy
>  
> -__all__ = ["EntropyDialog"]
> +__all__ = ["run_entropy_dialog"]
> +
> + at gtk_action_wait
> +def run_entropy_dialog(ksdata, desired_entropy):
> +    """Show dialog with waiting for entropy"""
> +
> +    dialog = EntropyDialog(ksdata, desired_entropy)
> +    dialog.run()
>  
>  class EntropyDialog(GUIObject):
>      builderObjects = ["entropyDialog"]
> diff --git a/pyanaconda/ui/lib/entropy.py b/pyanaconda/ui/lib/entropy.py
> index 9e7d441..1fe5634 100644
> --- a/pyanaconda/ui/lib/entropy.py
> +++ b/pyanaconda/ui/lib/entropy.py
> @@ -29,10 +29,8 @@ import select
>  import sys
>  import termios
>  
> -from gi.repository import Gtk
> -from pyanaconda.ui.gui.spokes.lib.entropy_dialog import EntropyDialog
> -from pyanaconda.ui.gui.utils import gtk_action_wait
>  from pyanaconda.progress import progress_message
> +from pykickstart.constants import DISPLAY_MODE_GRAPHICAL
>  from blivet.util import get_current_entropy
>  
>  from pyanaconda.i18n import _
> @@ -48,21 +46,15 @@ def wait_for_entropy(msg, desired_entropy, ksdata):
>  
>      """
>  
> -    (succ, _args) = Gtk.init_check(None)
> -    if succ:
> -        # Gtk initialized, set progress message and run the GUI dialog
> +    if ksdata.displaymode.displayMode == DISPLAY_MODE_GRAPHICAL:
> +        # cannot import globally because GUI code may be missing for text
> mode
> +        # in some cases
> +        from pyanaconda.ui.gui.spokes.lib.entropy_dialog import
> run_entropy_dialog
>          progress_message(_("The system needs more random data entropy"))
> -        _gui_wait(ksdata, desired_entropy)
> +        run_entropy_dialog(ksdata, desired_entropy)
>      else:
>          _tui_wait(msg, desired_entropy)
>  
> - at gtk_action_wait
> -def _gui_wait(ksdata, desired_entropy):
> -    """Show dialog with waiting for entropy"""
> -
> -    dialog = EntropyDialog(ksdata, desired_entropy)
> -    dialog.run()
> -
>  def _tui_wait(msg, desired_entropy):
>      """Tell user we are waiting for entropy"""
>  
> --
> 1.9.3
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 

If the gui_wait() function is migrating to a GUI-specific location,
the tui_wait() function probably ought to migrate to a TUI-specific location,
also.

- mulhern


More information about the anaconda-patches mailing list