[Patch] [virtinst] Fix check keymap option in virt-install

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,

I made the patch that corrected the following problem.
It is that virt-install hangs up, when I set keymap which doesn't
exist in keytable.
ex)
virt-install ... --keymap=abc

If you have any comments, please suggest me.

Signed-off-by: Tomohiro Takahashi <takatom@xxxxxxxxxxxxxx>

Thanks,
Tomohiro Takahashi
diff -r 143cad71a2a6 virtinst/_util.py
--- a/virtinst/_util.py	Mon Mar 09 23:31:51 2009 -0400
+++ b/virtinst/_util.py	Wed Mar 11 09:26:50 2009 +0900
@@ -206,3 +206,4 @@ is_storage_capable = util.is_storage_cap
 is_storage_capable = util.is_storage_capable
 get_xml_path = util.get_xml_path
 lookup_pool_by_path = util.lookup_pool_by_path
+check_keytable = util.check_keytable
diff -r 143cad71a2a6 virtinst/cli.py
--- a/virtinst/cli.py	Mon Mar 09 23:31:51 2009 -0400
+++ b/virtinst/cli.py	Wed Mar 11 09:21:54 2009 +0900
@@ -351,7 +351,11 @@ def get_graphics(vnc, vncport, nographic
     if vncport:
         guest.graphics_dev.port = vncport
     if keymap:
-        guest.graphics_dev.keymap = keymap
+        checked_keymap = _util.check_keytable(keymap)
+        if checked_keymap:
+            guest.graphics_dev.keymap = checked_keymap
+        else:
+            raise ValueError, _("Didn't match keymap '%s' in keytable!" % keymap)
 
 def get_sound(sound, guest):
 
diff -r 143cad71a2a6 virtinst/util.py
--- a/virtinst/util.py	Mon Mar 09 23:31:51 2009 -0400
+++ b/virtinst/util.py	Wed Mar 11 09:25:38 2009 +0900
@@ -392,26 +392,7 @@ def default_keymap():
 
     kt = kt.lower()
 
-    # Try a simple lookup in the keytable
-    if keytable.keytable.has_key(kt.lower()):
-        keymap = keytable.keytable[kt]
-    else:
-        # Try a more intelligent lookup: strip out all '-' and '_', sort
-        # the keytable keys putting the longest first, then compare
-        # by string prefix
-        def len_cmp(a, b):
-            return len(b) - len(a)
-
-        clean_kt = kt.replace("-", "").replace("_", "")
-        sorted_keys = sorted(keytable.keytable.keys(), len_cmp)
-
-        for key in sorted_keys:
-            origkey = key
-            key = key.replace("-", "").replace("_","")
-
-            if clean_kt.startswith(key):
-                keymap = keytable.keytable[origkey]
-                break
+    keymap = check_keytable(kt)
 
     if not keymap:
         logging.debug("Didn't match keymap '%s' in keytable!" % kt)
@@ -599,6 +580,31 @@ def lookup_pool_by_path(conn, path):
                 return p
     return None
 
+def check_keytable(kt):
+    import keytable
+    keymap = None
+    # Try a simple lookup in the keytable
+    if keytable.keytable.has_key(kt.lower()):
+        return keytable.keytable[kt]
+    else:
+        # Try a more intelligent lookup: strip out all '-' and '_', sort
+        # the keytable keys putting the longest first, then compare
+        # by string prefix
+        def len_cmp(a, b):
+            return len(b) - len(a)
+
+        clean_kt = kt.replace("-", "").replace("_", "")
+        sorted_keys = sorted(keytable.keytable.keys(), len_cmp)
+
+        for key in sorted_keys:
+            origkey = key
+            key = key.replace("-", "").replace("_","")
+
+            if clean_kt.startswith(key):
+                return keytable.keytable[origkey]
+
+    return keymap
+
 def _test():
     import doctest
     doctest.testmod()
_______________________________________________
et-mgmt-tools mailing list
et-mgmt-tools@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/et-mgmt-tools

[Index of Archives]     [Fedora Users]     [Fedora Legacy List]     [Fedora Maintainers]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux