[PATCH] Log entering/exiting spokes and hubs in the GUI.
Vratislav Podzimek
vpodzime at redhat.com
Thu Oct 17 07:33:01 UTC 2013
On Wed, 2013-10-16 at 13:08 -0400, Chris Lumens wrote:
> ---
> pyanaconda/ui/common.py | 43 +++++++++++++++++++++++++++++++++++++-
> pyanaconda/ui/gui/__init__.py | 5 +++++
> pyanaconda/ui/gui/hubs/__init__.py | 4 ++++
> 3 files changed, 51 insertions(+), 1 deletion(-)
>
> diff --git a/pyanaconda/ui/common.py b/pyanaconda/ui/common.py
> index 1e6e2e7..dfff1f6 100644
> --- a/pyanaconda/ui/common.py
> +++ b/pyanaconda/ui/common.py
> @@ -329,6 +329,22 @@ class Spoke(UIObject):
> """
> raise NotImplementedError
>
> + def entry_logger(self):
> + """Log immediately before this spoke is about to be displayed on the
> + screen. Subclasses may override this method if they want to log
> + more specific information, but an overridden method should finish
> + by calling this method so the entry will be logged.
> + """
> + log.debug("Entered spoke: %s", self.__class__.__name__)
> +
> + def exit_logger(self):
> + """Log when a user leaves the spoke. Subclasses may override this
> + method if they want to log more specific information, but an
> + overridden method should finish by calling this method so the
> + exit will be logged.
> + """
> + log.debug("Left spoke: %s", self.__class__.__name__)
> +
> class NormalSpoke(Spoke):
> """A NormalSpoke is a Spoke subclass that is displayed when the user
> selects something on a Hub. This is what most Spokes in anaconda will
> @@ -493,7 +509,32 @@ class Hub(UIObject):
> """Update the paths attribute with list of tuples in the form (module
> name format string, directory name)"""
> self.paths[path_id] = paths
> -
> +
> + def entry_logger(self):
> + """Log immediately before this hub is about to be displayed on the
> + screen. Subclasses may override this method if they want to log
> + more specific information, but an overridden method should finish
> + by calling this method so the entry will be logged.
> +
> + Note that due to how the GUI flows, hubs are only entered once -
> + when they are initially displayed. Going to a spoke from a hub
> + and then coming back to the hub does not count as exiting and
> + entering.
> + """
> + log.debug("Entered hub: %s", self.__class__.__name__)
> +
> + def exit_logger(self):
> + """Log when a user leaves the hub. Subclasses may override this
> + method if they want to log more specific information, but an
> + overridden method should finish by calling this method so the
> + exit will be logged.
> +
> + Note that due to how the GUI flows, hubs are not exited when the
> + user selects a spoke from the hub. They are only exited when the
> + continue or quit button is clicked on the hub.
> + """
> + log.debug("Left hub: %s", self.__class__.__name__)
> +
> def collect(module_pattern, path, pred):
> """Traverse the directory (given by path), import all files as a module
> module_pattern % filename and find all classes within that match
> diff --git a/pyanaconda/ui/gui/__init__.py b/pyanaconda/ui/gui/__init__.py
> index 44d7d90..52161ff 100644
> --- a/pyanaconda/ui/gui/__init__.py
> +++ b/pyanaconda/ui/gui/__init__.py
> @@ -621,6 +621,7 @@ class GraphicalUserInterface(UserInterface):
> return
>
> self._currentAction.initialize()
> + self._currentAction.entry_logger()
> self._currentAction.refresh()
>
> self._currentAction.window.set_beta(not self._isFinal)
> @@ -737,6 +738,9 @@ class GraphicalUserInterface(UserInterface):
> self._on_continue_clicked()
> return
>
> + self._currentAction.exit_logger()
> + nextAction.entry_logger()
> +
> nextAction.refresh()
>
> # Do this last. Setting up curAction could take a while, and we want
> @@ -753,6 +757,7 @@ class GraphicalUserInterface(UserInterface):
> dialog.window.destroy()
>
> if rc == 1:
> + self._currentAction.exit_logger()
> sys.exit(0)
>
> class GraphicalExceptionHandlingIface(meh.ui.gui.GraphicalIntf):
> diff --git a/pyanaconda/ui/gui/hubs/__init__.py b/pyanaconda/ui/gui/hubs/__init__.py
> index f142a18..e084d6d 100644
> --- a/pyanaconda/ui/gui/hubs/__init__.py
> +++ b/pyanaconda/ui/gui/hubs/__init__.py
> @@ -105,6 +105,8 @@ class Hub(GUIObject, common.Hub):
> action.window.maximize()
> action.window.set_property("expand", True)
>
> + action.entry_logger()
> +
> action.refresh()
>
> action.window.set_beta(self.window.get_beta())
> @@ -129,6 +131,8 @@ class Hub(GUIObject, common.Hub):
> action.execute()
> action._visitedSinceApplied = False
>
> + action.exit_logger()
> +
> def _collectCategoriesAndSpokes(self):
> """collects categories and spokes to be displayed on this Hub
>
Good idea, ACK.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list