[PATCH 1/2] Replace system-config-keyboard with our methods using ksdata.keyboard
Chris Lumens
clumens at redhat.com
Wed Jul 25 16:24:15 UTC 2012
> @@ -901,8 +902,9 @@ if __name__ == "__main__":
> if opts.keymap:
> if not ksdata.keyboard.keyboard:
> ksdata.keyboard.keyboard = opts.keymap
> - anaconda.keyboard.set(opts.keymap)
> - anaconda.keyboard.activate()
> +
> + if ksdata.keyboard.keyboard:
> + keyboard.activate_console_keymap(ksdata.keyboard.keyboard)
>
> # now start the interface
> setupDisplay(anaconda, opts)
Could this be moved up to right under the following comment in anaconda:
# Some kickstart commands must be executed immediately, as they
# affect how anaconda operates.
Also I guess at some point, we're going to need to have ksdata and
command line opts play well with each other.
> +def activate_console_keymap(keymap):
> + """
> + Try to setup a given keymap as a console keymap. If there is no such
> + keymap, try to setup a basic variant (e.g. 'cz' instead of 'cz (qwerty)').
> +
> + @param keymap: a keymap
> + @type keymap: string
> + @raise KeyboardConfigError: if loadkeys command is not available
> + @return: False if failed to activate both the given keymap and its basic
> + variant, True otherwise
> +
> + """
> +
> + try:
> + #TODO: replace with calling systemd-localed methods once it can load
> + # X layouts
> + ret = iutil.execWithRedirect("loadkeys", [keymap], stdout="/dev/tty5",
> + stderr="/dev/tty5")
> + except OSError as oserr:
> + msg = "'loadkeys' command not available (%s)" % oserr.strerror
> + raise KeyboardConfigError(msg)
> +
> + if ret != 0:
> + log.error("Failed to activate keymap %s" % keymap)
> +
> + #failed to activate the given keymap, extract and try
> + #the basic keymap -- e.g. 'cz-cp1250' -> 'cz'
> + parts = re.split(r'[- _(]', keymap, 1)
> + keymap = parts[0]
You should protect against parts being empty here.
- Chris
More information about the anaconda-patches
mailing list