Hi,
attached patch looks at xorg.conf if no /etc/sysconfig/keyboard for the
default keyboard. This helps with distros that don't have
/etc/sysconfig/ like Debian.
Cheers,
-- Guido
# HG changeset patch
# User Guido Günther <[EMAIL PROTECTED]>
# Date 1227979760 -3600
# Node ID a292eb8430cd2d9544e89dba127323704f3963ce
# Parent 16e923676e84d81cf9bf6dc2cdd30d95bf65bbe1
parse xorg.conf for keymap
diff -r 16e923676e84 -r a292eb8430cd virtinst/util.py
--- a/virtinst/util.py Tue Nov 25 10:25:08 2008 -0500
+++ b/virtinst/util.py Sat Nov 29 18:29:20 2008 +0100
@@ -33,6 +33,7 @@
KEYBOARD_DIR = "/etc/sysconfig/keyboard"
+XORG_CONF = "/etc/X11/xorg.conf"
def default_route():
route_file = "/proc/net/route"
@@ -276,6 +277,28 @@
return -1
return 0
+def xorg_keymap():
+ """Look in /etc/X11/xorg.conf for the host machine's keymap, and attempt to
+ map it to a keymap supported by qemu"""
+
+ import keytable
+ kt = None
+ try:
+ f = open(XORG_CONF, "r")
+ except IOError, e:
+ logging.debug('Could not open "%s": %s ' % (XORG_CONF, str(e)))
+ else:
+ keymap_re = re.compile(r'\s*Option\s+"XkbLayout"\s+"(?P<kt>[a-z-]+)"')
+ for line in f:
+ m = keymap_re.match(line)
+ if m:
+ kt = m.group('kt')
+ break
+ else:
+ logging.debug("Didn't find keymap '%s' in keytable!" % kt)
+ f.close()
+ return kt
+
def default_keymap():
"""Look in /etc/sysconfig for the host machine's keymap, and attempt to
map it to a keymap supported by qemu"""
@@ -283,10 +306,12 @@
# Set keymap to same as hosts
import keytable
keymap = "en-us"
+ kt = None
try:
f = open(KEYBOARD_DIR, "r")
except IOError, e:
logging.debug('Could not open "/etc/sysconfig/keyboard" ' + str(e))
+ kt = xorg_keymap()
else:
while 1:
s = f.readline()
@@ -302,11 +327,12 @@
else:
continue
kt = s.split(delim)[1].strip()
- if keytable.keytable.has_key(kt.lower()):
- keymap = keytable.keytable[kt]
- else:
- logging.debug("Didn't find keymap '%s' in keytable!" % kt)
f.close()
+
+ if kt and keytable.keytable.has_key(kt.lower()):
+ keymap = keytable.keytable[kt]
+ else:
+ logging.debug("Didn't find keymap '%s' in keytable!" % kt)
return keymap
def pygrub_path(conn=None):
_______________________________________________
et-mgmt-tools mailing list
[email protected]
https://www.redhat.com/mailman/listinfo/et-mgmt-tools