[master] [PATCH] Move communication module to pyanaconda/ui

Martin Sivak msivak at redhat.com
Thu Jan 24 12:50:18 UTC 2013


Ack. Makes sense and if everything works properly, we need this
to workaround Gtk bug #902401 in TUI.

Martin

----- Original Message -----
> It is not a GUI specific code, so it should live under pyanaconda/ui
> instead of pyanaconda/ui/gui. Moreover from pyanaconda/ui/gui it
> cannot
> be imported without X server running.
> 
> Signed-off-by: Vratislav Podzimek <vpodzime at redhat.com>
> ---
>  pyanaconda/ui/common.py              |  4 +--
>  pyanaconda/ui/communication.py       | 58
>  ++++++++++++++++++++++++++++++++++++
>  pyanaconda/ui/gui/communication.py   | 58
>  ------------------------------------
>  pyanaconda/ui/gui/hubs/__init__.py   |  2 +-
>  pyanaconda/ui/gui/spokes/custom.py   |  2 +-
>  pyanaconda/ui/gui/spokes/network.py  |  3 +-
>  pyanaconda/ui/gui/spokes/software.py |  2 +-
>  pyanaconda/ui/gui/spokes/source.py   |  3 +-
>  pyanaconda/ui/gui/spokes/storage.py  |  3 +-
>  9 files changed, 69 insertions(+), 66 deletions(-)
>  create mode 100644 pyanaconda/ui/communication.py
>  delete mode 100644 pyanaconda/ui/gui/communication.py
> 
> diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py
> index 902bc9c..b783f5e 100644
> --- a/pyanaconda/ui/common.py
> +++ b/pyanaconda/ui/common.py
> @@ -279,7 +279,7 @@ class Spoke(UIObject):
>             A spoke's status line on the Hub can also be overloaded
>             to provide
>             information about why a Spoke is not yet ready, or if an
>             error has
>             occurred when setting it up.  This can be done by calling
> -           send_message from pyanaconda.ui.gui.communication with
> the target
> +           send_message from pyanaconda.ui.communication with the
> target
>             Spoke's class name and the message to be displayed.
>  
>             If the Spoke was not yet ready when send_message was
>             called, the
> @@ -330,7 +330,7 @@ class NormalSpoke(Spoke):
>             long-lived process (like storage probing) before it's
>             ready.
>  
>             A Spoke may be marked as ready or not by calling
>             send_ready or
> -           send_not_ready from pyanaconda.ui.gui.communication with
> the
> +           send_not_ready from pyanaconda.ui.communication with the
>             target Spoke's class name.
>  
>             While a Spoke is not ready, a progress message may be
>             shown to
> diff --git a/pyanaconda/ui/communication.py
> b/pyanaconda/ui/communication.py
> new file mode 100644
> index 0000000..19e3a24
> --- /dev/null
> +++ b/pyanaconda/ui/communication.py
> @@ -0,0 +1,58 @@
> +#
> +# communication.py: spoke-to-hub communication code
> +#
> +# Copyright (C) 2012  Red Hat, Inc.  All rights reserved.
> +#
> +# This program is free software; you can redistribute it and/or
> modify
> +# it under the terms of the GNU General Public License as published
> by
> +# the Free Software Foundation; either version 2 of the License, or
> +# (at your option) any later version.
> +#
> +# This program is distributed in the hope that it will be useful,
> +# but WITHOUT ANY WARRANTY; without even the implied warranty of
> +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> +# GNU General Public License for more details.
> +#
> +# You should have received a copy of the GNU General Public License
> +# along with this program.  If not, see
> <http://www.gnu.org/licenses/>.
> +#
> +# Author(s): Chris Lumens <clumens at redhat.com>
> +
> +import Queue
> +
> +# A queue to be used for communicating information from a spoke back
> to its
> +# hub.  This information includes things like marking spokes as
> ready and
> +# updating the status line to tell the user why a spoke is not yet
> available.
> +# This queue should have elements of the following format pushed
> into it:
> +#
> +# (HUB_CODE_*, [arguments])
> +#
> +# Arguments vary based on the code given, but the first argument
> must always
> +# be the name of the class of the spoke to be acted upon.  See below
> for more
> +# details.
> +hubQ = Queue.Queue()
> +
> +# Arguments:
> +#
> +# _READY - [spoke_name, justUpdate]
> +# _NOT_READY - [spoke_name]
> +# _MESSAGE - [spoke_name, string]
> +HUB_CODE_READY = 0
> +HUB_CODE_NOT_READY = 1
> +HUB_CODE_MESSAGE = 2
> +
> +# Convenience methods to put things into the queue without the user
> having to
> +# know the details of the queue.
> +def send_ready(spoke, justUpdate=False):
> +    """Tell the hub that a spoke given by the name "spoke" has
> become ready,
> +       and that it should be made sensitive on the hub.  Some
> processing may
> +       also occur after a spoke has become ready.  However, if the
> justUpdate
> +       parameter is True, no processing will occur.
> +    """
> +    hubQ.put((HUB_CODE_READY, [spoke, justUpdate]))
> +
> +def send_not_ready(spoke):
> +    hubQ.put((HUB_CODE_NOT_READY, [spoke]))
> +
> +def send_message(spoke, msg):
> +    hubQ.put((HUB_CODE_MESSAGE, [spoke, msg]))
> diff --git a/pyanaconda/ui/gui/communication.py
> b/pyanaconda/ui/gui/communication.py
> deleted file mode 100644
> index 19e3a24..0000000
> --- a/pyanaconda/ui/gui/communication.py
> +++ /dev/null
> @@ -1,58 +0,0 @@
> -#
> -# communication.py: spoke-to-hub communication code
> -#
> -# Copyright (C) 2012  Red Hat, Inc.  All rights reserved.
> -#
> -# This program is free software; you can redistribute it and/or
> modify
> -# it under the terms of the GNU General Public License as published
> by
> -# the Free Software Foundation; either version 2 of the License, or
> -# (at your option) any later version.
> -#
> -# This program is distributed in the hope that it will be useful,
> -# but WITHOUT ANY WARRANTY; without even the implied warranty of
> -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> -# GNU General Public License for more details.
> -#
> -# You should have received a copy of the GNU General Public License
> -# along with this program.  If not, see
> <http://www.gnu.org/licenses/>.
> -#
> -# Author(s): Chris Lumens <clumens at redhat.com>
> -
> -import Queue
> -
> -# A queue to be used for communicating information from a spoke back
> to its
> -# hub.  This information includes things like marking spokes as
> ready and
> -# updating the status line to tell the user why a spoke is not yet
> available.
> -# This queue should have elements of the following format pushed
> into it:
> -#
> -# (HUB_CODE_*, [arguments])
> -#
> -# Arguments vary based on the code given, but the first argument
> must always
> -# be the name of the class of the spoke to be acted upon.  See below
> for more
> -# details.
> -hubQ = Queue.Queue()
> -
> -# Arguments:
> -#
> -# _READY - [spoke_name, justUpdate]
> -# _NOT_READY - [spoke_name]
> -# _MESSAGE - [spoke_name, string]
> -HUB_CODE_READY = 0
> -HUB_CODE_NOT_READY = 1
> -HUB_CODE_MESSAGE = 2
> -
> -# Convenience methods to put things into the queue without the user
> having to
> -# know the details of the queue.
> -def send_ready(spoke, justUpdate=False):
> -    """Tell the hub that a spoke given by the name "spoke" has
> become ready,
> -       and that it should be made sensitive on the hub.  Some
> processing may
> -       also occur after a spoke has become ready.  However, if the
> justUpdate
> -       parameter is True, no processing will occur.
> -    """
> -    hubQ.put((HUB_CODE_READY, [spoke, justUpdate]))
> -
> -def send_not_ready(spoke):
> -    hubQ.put((HUB_CODE_NOT_READY, [spoke]))
> -
> -def send_message(spoke, msg):
> -    hubQ.put((HUB_CODE_MESSAGE, [spoke, msg]))
> diff --git a/pyanaconda/ui/gui/hubs/__init__.py
> b/pyanaconda/ui/gui/hubs/__init__.py
> index 1f5141a..b704fa8 100644
> --- a/pyanaconda/ui/gui/hubs/__init__.py
> +++ b/pyanaconda/ui/gui/hubs/__init__.py
> @@ -262,7 +262,7 @@ class Hub(GUIObject, common.Hub):
>          self.continueButton.set_sensitive(self.continuePossible)
>  
>      def _update_spokes(self):
> -        from pyanaconda.ui.gui import communication
> +        from pyanaconda.ui import communication
>          import Queue
>  
>          q = communication.hubQ
> diff --git a/pyanaconda/ui/gui/spokes/custom.py
> b/pyanaconda/ui/gui/spokes/custom.py
> index 8f38eb4..7099ac4 100644
> --- a/pyanaconda/ui/gui/spokes/custom.py
> +++ b/pyanaconda/ui/gui/spokes/custom.py
> @@ -73,8 +73,8 @@ from pyanaconda.storage.errors import MDRaidError
>  from pyanaconda.storage.devicelibs import mdraid
>  from pyanaconda.storage.devices import LUKSDevice
>  
> +from pyanaconda.ui import communication
>  from pyanaconda.ui.gui import GUIObject
> -from pyanaconda.ui.gui import communication
>  from pyanaconda.ui.gui.spokes import NormalSpoke
>  from pyanaconda.ui.gui.spokes.storage import StorageChecker
>  from pyanaconda.ui.gui.spokes.lib.cart import SelectedDisksDialog
> diff --git a/pyanaconda/ui/gui/spokes/network.py
> b/pyanaconda/ui/gui/spokes/network.py
> index e8f2b94..161e6ad 100644
> --- a/pyanaconda/ui/gui/spokes/network.py
> +++ b/pyanaconda/ui/gui/spokes/network.py
> @@ -35,7 +35,8 @@
>  from gi.repository import Gtk, AnacondaWidgets
>  
>  from pyanaconda.flags import flags
> -from pyanaconda.ui.gui import GUIObject, communication
> +from pyanaconda.ui import communication
> +from pyanaconda.ui.gui import GUIObject
>  from pyanaconda.ui.gui.spokes import NormalSpoke, StandaloneSpoke
>  from pyanaconda.ui.gui.categories.software import SoftwareCategory
>  from pyanaconda.ui.gui.hubs.summary import SummaryHub
> diff --git a/pyanaconda/ui/gui/spokes/software.py
> b/pyanaconda/ui/gui/spokes/software.py
> index 8ab93d3..cbaf8f0 100644
> --- a/pyanaconda/ui/gui/spokes/software.py
> +++ b/pyanaconda/ui/gui/spokes/software.py
> @@ -27,7 +27,7 @@ from pyanaconda.flags import flags
>  from pyanaconda.kickstart import packagesSeen
>  from pyanaconda.threads import threadMgr, AnacondaThread
>  
> -from pyanaconda.ui.gui import communication
> +from pyanaconda.ui import communication
>  from pyanaconda.ui.gui.spokes import NormalSpoke
>  from pyanaconda.ui.gui.spokes.lib.detailederror import
>  DetailedErrorDialog
>  from pyanaconda.ui.gui.utils import enlightbox, gtk_thread_wait
> diff --git a/pyanaconda/ui/gui/spokes/source.py
> b/pyanaconda/ui/gui/spokes/source.py
> index c7149da..7faf0bc 100644
> --- a/pyanaconda/ui/gui/spokes/source.py
> +++ b/pyanaconda/ui/gui/spokes/source.py
> @@ -34,7 +34,8 @@ from gi.repository import AnacondaWidgets, GLib,
> Gtk
>  
>  from pyanaconda.flags import flags
>  from pyanaconda.image import opticalInstallMedia,
>  potentialHdisoSources
> -from pyanaconda.ui.gui import GUIObject, communication
> +from pyanaconda.ui import communication
> +from pyanaconda.ui.gui import GUIObject
>  from pyanaconda.ui.gui.spokes import NormalSpoke
>  from pyanaconda.ui.gui.categories.software import SoftwareCategory
>  from pyanaconda.ui.gui.utils import enlightbox, gtk_thread_wait
> diff --git a/pyanaconda/ui/gui/spokes/storage.py
> b/pyanaconda/ui/gui/spokes/storage.py
> index 6efd00d..d7951d2 100644
> --- a/pyanaconda/ui/gui/spokes/storage.py
> +++ b/pyanaconda/ui/gui/spokes/storage.py
> @@ -40,7 +40,8 @@
>  
>  from gi.repository import Gdk, GLib, Gtk
>  from gi.repository import AnacondaWidgets
> -from pyanaconda.ui.gui import GUIObject, communication
> +from pyanaconda.ui import communication
> +from pyanaconda.ui.gui import GUIObject
>  from pyanaconda.ui.gui.spokes import NormalSpoke
>  from pyanaconda.ui.gui.spokes.lib.cart import SelectedDisksDialog
>  from pyanaconda.ui.gui.spokes.lib.passphrase import PassphraseDialog
> --
> 1.7.11.7
> 
> _______________________________________________
> anaconda-patches mailing list
> anaconda-patches at lists.fedorahosted.org
> https://lists.fedorahosted.org/mailman/listinfo/anaconda-patches
> 


More information about the anaconda-patches mailing list