[PATCH] Exit on exception in the askVNC spoke (#962804)
Vratislav Podzimek
vpodzime at redhat.com
Mon Oct 7 08:42:14 UTC 2013
On Fri, 2013-10-04 at 16:38 -0400, David Shea wrote:
> Install a handler for exception messages from the TUI in askvnc. A
> handler would normally be installed by TextUserInterface.setup(), but
> askvnc runs before that. There's not a lot we can do about exceptions
> at this point, so display it and exit.
>
> The previous failure mode was to loop forever attempting to reprint the
> spoke.
> ---
> pyanaconda/ui/tui/spokes/askvnc.py | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/pyanaconda/ui/tui/spokes/askvnc.py b/pyanaconda/ui/tui/spokes/askvnc.py
> index f6e9528..5734365 100644
> --- a/pyanaconda/ui/tui/spokes/askvnc.py
> +++ b/pyanaconda/ui/tui/spokes/askvnc.py
> @@ -24,7 +24,15 @@ from pyanaconda.ui.tui.simpleline import TextWidget, ColumnWidget
> from pyanaconda.constants import USEVNC, USETEXT
> from pyanaconda.constants_text import INPUT_PROCESSED
> from pyanaconda.i18n import _
> +from pyanaconda.ui.communication import hubQ
> +from pyanaconda.ui.tui import exception_msg_handler
> import getpass
> +import sys
> +
> +def exception_msg_handler_and_exit(event, data):
> + """Display an exception and exit so that we don't end up in a loop."""
> + exception_msg_handler(event, data)
> + sys.exit(1)
>
> class AskVNCSpoke(NormalTUISpoke):
> title = _("VNC")
> @@ -35,6 +43,12 @@ class AskVNCSpoke(NormalTUISpoke):
> def __init__(self, app, data, storage=None, payload=None,
> instclass=None, message=None):
> NormalTUISpoke.__init__(self, app, data, storage, payload, instclass)
> +
> + # The TUI hasn't been initialized with the message handlers yet. Add an
> + # exception message handler so that the TUI exits if anything goes wrong
> + # at this stage.
> + self._app.register_event_handler(hubQ.HUB_CODE_EXCEPTION, exception_msg_handler_and_exit)
> +
> if message:
> self._message = message
> else:
I feel like we could do proper TUI exception handling even in this
phase, but looking at the code I see it would mean a lot of hacks and
intrusive changes. So ACK.
--
Vratislav Podzimek
Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic
More information about the anaconda-patches
mailing list