[node-patches] Change in ovirt-node[master]: utils: Use localectl introduced in F18

fabiand at fedoraproject.org fabiand at fedoraproject.org
Tue Feb 5 15:26:54 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: utils: Use localectl introduced in F18
......................................................................

utils: Use localectl introduced in F18

… to set they keymap.

Change-Id: Ic298b855654950c0fcadae04c5dcda375723f370
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/config/defaults.py
M scripts/tui/src/ovirt/node/setup/keyboard_page.py
M scripts/tui/src/ovirt/node/utils/__init__.py
M scripts/tui/src/ovirt/node/utils/process.py
M scripts/tui/src/ovirt/node/utils/system.py
5 files changed, 30 insertions(+), 23 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/54/11754/1

diff --git a/scripts/tui/src/ovirt/node/config/defaults.py b/scripts/tui/src/ovirt/node/config/defaults.py
index 5f82091..1e403ad 100644
--- a/scripts/tui/src/ovirt/node/config/defaults.py
+++ b/scripts/tui/src/ovirt/node/config/defaults.py
@@ -1052,7 +1052,7 @@
 
             def commit(self):
                 from ovirtnode.ovirtfunctions import ovirt_store_config
-                kbd = utils.Keyboard()
+                kbd = utils.system.Keyboard()
                 kbd.set_layout(layout)
                 ovirt_store_config(["/etc/sysconfig/keyboard",
                                     "/etc/vconsole.conf"])
diff --git a/scripts/tui/src/ovirt/node/setup/keyboard_page.py b/scripts/tui/src/ovirt/node/setup/keyboard_page.py
index 3e6e0a1..e40e93c 100644
--- a/scripts/tui/src/ovirt/node/setup/keyboard_page.py
+++ b/scripts/tui/src/ovirt/node/setup/keyboard_page.py
@@ -49,7 +49,7 @@
         """Describes the UI this plugin requires
         This is an ordered list of (path, widget) tuples.
         """
-        kbd = utils.Keyboard()
+        kbd = utils.system.Keyboard()
         ws = [ui.Header("header", "Keyboard Layout Selection"),
               ui.Table("keyboard.layout", "Available Keyboard Layouts", "",
                        kbd.available_layouts()),
diff --git a/scripts/tui/src/ovirt/node/utils/__init__.py b/scripts/tui/src/ovirt/node/utils/__init__.py
index 06c7375..af51a02 100644
--- a/scripts/tui/src/ovirt/node/utils/__init__.py
+++ b/scripts/tui/src/ovirt/node/utils/__init__.py
@@ -21,7 +21,6 @@
 from ovirt.node import base, exceptions
 import augeas as _augeas
 import hashlib
-import system_config_keyboard.keyboard
 import time
 import traceback
 
@@ -138,26 +137,6 @@
             return True
     return False
 
-
-class Keyboard(base.Base):
-    def __init__(self):
-        super(Keyboard, self).__init__()
-        self.kbd = system_config_keyboard.keyboard.Keyboard()
-
-    def available_layouts(self):
-        self.kbd.read()
-        layoutgen = ((details[0], kid)
-                     for kid, details in self.kbd.modelDict.items())
-        layouts = [(kid, name) for name, kid in sorted(layoutgen)]
-        return layouts
-
-    def set_layout(self, layout):
-        self.kbd.set(layout)
-        self.kbd.write()
-        self.kbd.activate()
-
-    def get_current(self):
-        return self.kbd.get()
 
 class Transaction(list, base.Base):
     """A very simple transaction mechanism.
diff --git a/scripts/tui/src/ovirt/node/utils/process.py b/scripts/tui/src/ovirt/node/utils/process.py
index 3eb9c50..3c642f6 100644
--- a/scripts/tui/src/ovirt/node/utils/process.py
+++ b/scripts/tui/src/ovirt/node/utils/process.py
@@ -41,6 +41,7 @@
     kwargs.update({
         "close_fds": True
     })
+    LOGGER.debug("forking: %s %s" % (args, kwargs))
     return subprocess.Popen(*args, **kwargs)
 
 
diff --git a/scripts/tui/src/ovirt/node/utils/system.py b/scripts/tui/src/ovirt/node/utils/system.py
index d8b2cb1..84fa6a7 100644
--- a/scripts/tui/src/ovirt/node/utils/system.py
+++ b/scripts/tui/src/ovirt/node/utils/system.py
@@ -22,6 +22,7 @@
 from ovirt.node.utils import process
 import os.path
 import rpm
+import system_config_keyboard.keyboard
 
 """
 A module to access system wide stuff
@@ -128,3 +129,29 @@
     def load(self):
             from ovirtnode.ovirtfunctions import get_installed_version_number
             self.version, self.release = get_installed_version_number()
+
+
+class Keyboard(base.Base):
+    """Configure the system wide keyboard layout
+    FIXME what is the recommended way to do this on F18+ with localectl
+    localectl also stores the changes, so is kbd still needed?
+    """
+    def __init__(self):
+        super(Keyboard, self).__init__()
+        self.kbd = system_config_keyboard.keyboard.Keyboard()
+
+    def available_layouts(self):
+        self.kbd.read()
+        layoutgen = ((details[0], kid)
+                     for kid, details in self.kbd.modelDict.items())
+        layouts = [(kid, name) for name, kid in sorted(layoutgen)]
+        return layouts
+
+    def set_layout(self, layout):
+        self.kbd.set(layout)
+        self.kbd.write()
+        self.kbd.activate()
+        utils.process.system("localectl set-keymap %s" % layout)
+
+    def get_current(self):
+        return self.kbd.get()


--
To view, visit http://gerrit.ovirt.org/11754
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Ic298b855654950c0fcadae04c5dcda375723f370
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Fabian Deutsch <fabiand at fedoraproject.org>



More information about the node-patches mailing list