[PATCH 1/2] Add standalone spoke to prompt for VNC

Brian C. Lane bcl at redhat.com
Fri Sep 28 00:46:38 UTC 2012


On Thu, Sep 27, 2012 at 05:14:06PM -0700, Jesse Keating wrote:
> This gets used if text mode is requested or if X startup fails.  We
> don't (yet) prompt the user for advanced VNC configuration such as port
> number or to connect to an existing system.
> ---
>  po/POTFILES.in                     |   1 +
>  pyanaconda/constants.py            |   4 ++
>  pyanaconda/ui/tui/spokes/askvnc.py | 135 +++++++++++++++++++++++++++++++++++++
>  3 files changed, 140 insertions(+)
>  create mode 100644 pyanaconda/ui/tui/spokes/askvnc.py
> 
> diff --git a/po/POTFILES.in b/po/POTFILES.in
> index fa96535..021e6de 100644
> --- a/po/POTFILES.in
> +++ b/po/POTFILES.in
> @@ -66,6 +66,7 @@ pyanaconda/ui/tui/tuiobject.py
>  pyanaconda/ui/tui/simpleline/widgets.py
>  pyanaconda/ui/tui/simpleline/base.py
>  pyanaconda/ui/tui/simpleline/__init__.py
> +pyanaconda/ui/tui/spokes/askvnc.py
>  pyanaconda/ui/tui/spokes/password.py
>  pyanaconda/ui/tui/spokes/storage.py
>  pyanaconda/ui/tui/spokes/time.py
> diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py
> index c2a4b2b..e945bca 100644
> --- a/pyanaconda/constants.py
> +++ b/pyanaconda/constants.py
> @@ -88,3 +88,7 @@ DRACUT_SHUTDOWN_EJECT = "/run/initramfs/usr/lib/dracut/hooks/shutdown/99anaconda
>  
>  # DMI information paths
>  DMI_CHASSIS_VENDOR = "/sys/class/dmi/id/chassis_vendor"
> +
> +# VNC questions
> +USEVNC = _("Start VNC")
> +USETEXT = _("Use text mode")
> \ No newline at end of file
> diff --git a/pyanaconda/ui/tui/spokes/askvnc.py b/pyanaconda/ui/tui/spokes/askvnc.py
> new file mode 100644
> index 0000000..3bc2f95
> --- /dev/null
> +++ b/pyanaconda/ui/tui/spokes/askvnc.py
> @@ -0,0 +1,135 @@
> +# Ask vnc text spoke
> +#
> +# Copyright (C) 2012  Red Hat, Inc.
> +#
> +# This copyrighted material is made available to anyone wishing to use,
> +# modify, copy, or redistribute it subject to the terms and conditions of
> +# the GNU General Public License v.2, or (at your option) any later version.
> +# This program is distributed in the hope that it will be useful, but WITHOUT
> +# ANY WARRANTY expressed or implied, including the implied warranties 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, write to the
> +# Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
> +# 02110-1301, USA.  Any Red Hat trademarks that are incorporated in the
> +# source code or documentation are not subject to the GNU General Public
> +# License and may only be used or replicated with the express permission of
> +# Red Hat, Inc.
> +#
> +# Red Hat Author(s): Jesse Keating <jkeating at redhat.com>
> +#
> +
> +from pyanaconda.ui.tui.spokes import NormalTUISpoke
> +from pyanaconda.ui.tui.simpleline import TextWidget, ColumnWidget
> +from pyanaconda.constants import USEVNC, USETEXT
> +
> +import gettext
> +_ = lambda x: gettext.ldgettext("anaconda", x)
> +
> +
> +class AskVNCSpoke(NormalTUISpoke):
> +    title = _("VNC")
> +    category = "vnc"
> +
> +    # This spoke is kinda standalone, not meant to be used with a hub
> +    # We pass in some fake data just to make our parents happy
> +    def __init__(self, app, data, storage=None, payload=None,
> +                 instclass=None, message=None):
> +        NormalTUISpoke.__init__(self, app, data, storage, payload, instclass)
> +        if message:
> +            self._message = message
> +        else:
> +            self._message = _("X was unable to start on your "
> +                              "machine.  Would you like to "
> +                              "start VNC to connect to "
> +                              "this computer from another "
> +                              "computer and perform a "
> +                              "graphical install or continue "
> +                              "with a text mode install?")
> +
> +        self._choices = (USEVNC, USETEXT)
> +        self._usevnc = False
> +
> +    @property
> +    def indirect(self):
> +        return True
> +
> +    def refresh(self, args = None):
> +        NormalTUISpoke.refresh(self, args)
> +
> +        self._window += [TextWidget(self._message), ""]
> +
> +        for choice in self._choices:
> +            number = TextWidget("%2d)" % (self._choices.index(choice) + 1))
> +            c = ColumnWidget([(3, [number]), (None, [TextWidget(choice)])], 1)
> +            self._window += [c, ""]

Another way to do this would be to use enumerate() on the
tuple:

for idx, choice in enumerate(self._choices):

then you don't need that big .index() lookup in there.

Not really a complaint, just an alternative way, so ack.

-- 
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 482 bytes
Desc: not available
URL: <https://lists.fedorahosted.org/pipermail/anaconda-patches/attachments/20120927/084445f5/attachment.sig>


More information about the anaconda-patches mailing list