On Mon, Dec 01, 2008 at 10:28:15AM -0500, Cole Robinson wrote: > > + import keytable > > This is unused ('python setup.py check' will warn about this :) Fixed. > > > + 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) > > This logging isn't really accurate here. Maybe 'Didn't find keymap in > xorg.conf' Yes, that's bogus. Fixed version attached. -- Guido
# HG changeset patch # User Guido Günther <agx@xxxxxxxxxxx> # Date 1228157088 -3600 # Node ID 2a7f515d27d46f2b313114d5e8f53f8340990391 # Parent 68c036763c41caebafd3c759325c84f7453fccc3 parse xorg.conf for keymap diff -r 68c036763c41 -r 2a7f515d27d4 virtinst/util.py --- a/virtinst/util.py Mon Dec 01 19:41:59 2008 +0100 +++ b/virtinst/util.py Mon Dec 01 19:44:48 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,27 @@ 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""" + + 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 in '%s'!" % XORG_CONF) + 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 +305,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 +326,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 et-mgmt-tools@xxxxxxxxxx https://www.redhat.com/mailman/listinfo/et-mgmt-tools