[master/rhel7-branch] Fix traceback on tz spoke in text mode (#1252025)

Vratislav Podzimek vpodzime at redhat.com
Fri Aug 14 05:13:45 UTC 2015


On Thu, 2015-08-13 at 13:57 -0400, Samantha N. Bueno wrote:
> There were no means in place to handle what happens if a user enters a
> number greater or less than the presented values on the screen. Just
> return the key.
> 
> Resolves: rhbz#1252025
> 
> ---
>  pyanaconda/ui/tui/spokes/time_spoke.py | 23 +++++++++++++----------
>  1 file changed, 13 insertions(+), 10 deletions(-)
> 
> diff --git a/pyanaconda/ui/tui/spokes/time_spoke.py b/pyanaconda/ui/tui/spokes/time_spoke.py
> index 431ae23..400c1dc 100644
> --- a/pyanaconda/ui/tui/spokes/time_spoke.py
> +++ b/pyanaconda/ui/tui/spokes/time_spoke.py
> @@ -117,19 +117,22 @@ class TimeZoneSpoke(FirstbootSpokeMixIn, NormalTUISpoke):
>              else:
>                  return key
>  
> -        if args:
> -            self._selection = "%s/%s" % (args, self._timezones[args][keyid])
> -            self.apply()
> -            self.close()
> -        else:
> -            if len(self._timezones[self._regions[keyid]]) == 1:
> -                self._selection = "%s/%s" % (self._regions[keyid],
> -                                             self._timezones[self._regions[keyid]][0])
> +        try:
> +            if args:
> +                self._selection = "%s/%s" % (args, self._timezones[args][keyid])
>                  self.apply()
>                  self.close()
>              else:
> -                self.app.switch_screen(self, self._regions[keyid])
> -            return INPUT_PROCESSED
> +                if len(self._timezones[self._regions[keyid]]) == 1:
> +                    self._selection = "%s/%s" % (self._regions[keyid],
> +                                                 self._timezones[self._regions[keyid]][0])
> +                    self.apply()
> +                    self.close()
> +                else:
> +                    self.app.switch_screen(self, self._regions[keyid])
> +                return INPUT_PROCESSED
> +        except IndexError:
> +            return key
>  
>      def prompt(self, args = None):
>          return _("Please select the timezone.\nUse numbers or type names directly [%(back)s to region list, %(quit)s to quit]: ") % {
Looks good to me.

-- 
Vratislav Podzimek

Anaconda Rider | Red Hat, Inc. | Brno - Czech Republic



More information about the anaconda-patches mailing list