[node-patches] Change in ovirt-node[master]: Several syntax fixes

fabiand at fedoraproject.org fabiand at fedoraproject.org
Wed Feb 6 08:01:18 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: Several syntax fixes
......................................................................

Several syntax fixes

Change-Id: I03197f7daa20cabe1de8e7722f64248776121539
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/app.py
M scripts/tui/src/ovirt/node/config/defaults.py
M scripts/tui/src/ovirt/node/config/network.py
M scripts/tui/src/ovirt/node/setup/engine_page.py
M scripts/tui/src/ovirt/node/setup/kdump_page.py
M scripts/tui/src/ovirt/node/ui/__init__.py
M scripts/tui/src/ovirt/node/ui/urwid_builder.py
M scripts/tui/src/ovirt/node/ui/widgets.py
M scripts/tui/src/ovirt/node/utils/__init__.py
M scripts/tui/src/ovirt/node/utils/network.py
M scripts/tui/src/ovirt/node/utils/system.py
M scripts/tui/src/ovirt/node/utils/virt.py
M scripts/tui/src/ovirt/node/valid.py
13 files changed, 39 insertions(+), 22 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/87/11787/1

diff --git a/scripts/tui/src/ovirt/node/app.py b/scripts/tui/src/ovirt/node/app.py
index 879c809..849c449 100644
--- a/scripts/tui/src/ovirt/node/app.py
+++ b/scripts/tui/src/ovirt/node/app.py
@@ -210,7 +210,8 @@
                                           (element, cb, action))
                         cb.callback = action
             if type(element) is ui.SaveButton:
-                # http://stackoverflow.com/questions/2731111/python-lambdas-and-variable-bindings
+            # http://stackoverflow.com/questions/2731111/
+            # python-lambdas-and-variable-bindings
                 toggle_disabled = lambda t, v, e=element: e.enabled(v)
                 plugin.on_valid.connect(toggle_disabled)
 
diff --git a/scripts/tui/src/ovirt/node/config/defaults.py b/scripts/tui/src/ovirt/node/config/defaults.py
index 1e403ad..71d8984 100644
--- a/scripts/tui/src/ovirt/node/config/defaults.py
+++ b/scripts/tui/src/ovirt/node/config/defaults.py
@@ -798,9 +798,9 @@
                     self.backups.restore("/etc/kdump.conf")
                     system("service kdump restart")
 
-#                    raise RuntimeError("KDump configuration failed, " +
-#                                       "location unreachable. Previous " +
-#                                       "configuration was restored.")
+                    raise RuntimeError("KDump configuration failed, " +
+                                       "location unreachable. Previous " +
+                                       "configuration was restored.")
 
                 ovirt_store_config("/etc/kdump.conf")
                 self.backups.remove()
diff --git a/scripts/tui/src/ovirt/node/config/network.py b/scripts/tui/src/ovirt/node/config/network.py
index 7e3d668..4313ff5 100644
--- a/scripts/tui/src/ovirt/node/config/network.py
+++ b/scripts/tui/src/ovirt/node/config/network.py
@@ -29,8 +29,6 @@
 """
 
 
-
-
 LOGGER = logging.getLogger(__name__)
 
 
diff --git a/scripts/tui/src/ovirt/node/setup/engine_page.py b/scripts/tui/src/ovirt/node/setup/engine_page.py
index a3a9a62..83fb1ce 100644
--- a/scripts/tui/src/ovirt/node/setup/engine_page.py
+++ b/scripts/tui/src/ovirt/node/setup/engine_page.py
@@ -46,7 +46,8 @@
         return model
 
     def validators(self):
-        same_as_password = plugins.Validator.SameAsIn(self, "vdsm_cfg.password",
+        same_as_password = plugins.Validator.SameAsIn(self,
+                                                      "vdsm_cfg.password",
                                                       "Password")
         return {"vdsm_cfg.address": valid.FQDNOrIPAddress() | valid.Empty(),
                 "vdsm_cfg.port": valid.Port(),
@@ -195,9 +196,6 @@
         sys.path.append('/usr/share/vdsm-reg')
         import deployUtil  # @UnresolvedImport
 
-        sys.path.append('/usr/share/vdsm')
-        from vdsm import constants  # @UnresolvedImport
-
         from ovirt_config_setup.engine import \
             isHostReachable  # @UnresolvedImport
         from ovirt_config_setup.engine import \
@@ -259,7 +257,7 @@
             if deployUtil.getRhevmCert(self.engineServer,
                                        self.enginePort):
                 _, _, path = deployUtil.certPaths('')
-                fp = deployUtil.generateFingerPrint(path)
+                #fp = deployUtil.generateFingerPrint(path)
                 #
                 # FIXME
                 #
diff --git a/scripts/tui/src/ovirt/node/setup/kdump_page.py b/scripts/tui/src/ovirt/node/setup/kdump_page.py
index b00ed59..e7df914 100644
--- a/scripts/tui/src/ovirt/node/setup/kdump_page.py
+++ b/scripts/tui/src/ovirt/node/setup/kdump_page.py
@@ -136,6 +136,7 @@
             txs += model.transaction()
 
         with self.application.ui.suspended():
+            utils.process.system("reset")
             progress_dialog = console.TransactionProgress(txs, self)
             progress_dialog.run()
             console.writeln("\nPlease press any key to continue")
diff --git a/scripts/tui/src/ovirt/node/ui/__init__.py b/scripts/tui/src/ovirt/node/ui/__init__.py
index 1dece8d..43823d5 100644
--- a/scripts/tui/src/ovirt/node/ui/__init__.py
+++ b/scripts/tui/src/ovirt/node/ui/__init__.py
@@ -170,6 +170,7 @@
         dialog: The dialog to close
     """
     dialog = None
+
     def __init__(self, callback=None, dialog=None):
         super(CloseAction, self).__init__(callback)
         self.dialog = dialog
diff --git a/scripts/tui/src/ovirt/node/ui/urwid_builder.py b/scripts/tui/src/ovirt/node/ui/urwid_builder.py
index d46dd6a..1988be0 100644
--- a/scripts/tui/src/ovirt/node/ui/urwid_builder.py
+++ b/scripts/tui/src/ovirt/node/ui/urwid_builder.py
@@ -476,7 +476,7 @@
             # Hack to alow to close a dialog by name
             for d in self.__widget_stack:
                 if d.title == dialog:
-                    dialog = d 
+                    dialog = d
         self.logger.debug("Widget stack: %s" % self.__widget_stack)
         new_stack = [w for w in self.__widget_stack if w != dialog]
         self.__widget_stack = new_stack
diff --git a/scripts/tui/src/ovirt/node/ui/widgets.py b/scripts/tui/src/ovirt/node/ui/widgets.py
index c8f71b6..82825f0 100644
--- a/scripts/tui/src/ovirt/node/ui/widgets.py
+++ b/scripts/tui/src/ovirt/node/ui/widgets.py
@@ -102,7 +102,6 @@
             urwid.emit_signal(self, "changed", widget)
         urwid.connect_signal(self.__walker, 'modified', __on_item_change)
 
-
         self.__box = urwid.BoxAdapter(self.__list, height)
         self.__box_attrmap = urwid.AttrMap(self.__box, self._table_attr)
 
diff --git a/scripts/tui/src/ovirt/node/utils/__init__.py b/scripts/tui/src/ovirt/node/utils/__init__.py
index af51a02..7603c09 100644
--- a/scripts/tui/src/ovirt/node/utils/__init__.py
+++ b/scripts/tui/src/ovirt/node/utils/__init__.py
@@ -20,7 +20,7 @@
 # also available at http://www.gnu.org/copyleft/gpl.html.
 from ovirt.node import base, exceptions
 import augeas as _augeas
-import hashlib
+import system_config_keyboard.keyboard
 import time
 import traceback
 
@@ -138,6 +138,27 @@
     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/network.py b/scripts/tui/src/ovirt/node/utils/network.py
index 9f7fb44..7926f3d 100644
--- a/scripts/tui/src/ovirt/node/utils/network.py
+++ b/scripts/tui/src/ovirt/node/utils/network.py
@@ -285,7 +285,6 @@
     def exists(self):
         """If this NIC currently exists in the system
         """
-        
         return self.iface in all_ifaces()
 
     def has_link(self):
diff --git a/scripts/tui/src/ovirt/node/utils/system.py b/scripts/tui/src/ovirt/node/utils/system.py
index 84fa6a7..c0678ed 100644
--- a/scripts/tui/src/ovirt/node/utils/system.py
+++ b/scripts/tui/src/ovirt/node/utils/system.py
@@ -30,7 +30,6 @@
 """
 
 
-
 def reboot():
     process.system("reboot")
 
diff --git a/scripts/tui/src/ovirt/node/utils/virt.py b/scripts/tui/src/ovirt/node/utils/virt.py
index 7414720..e8f0e0e 100644
--- a/scripts/tui/src/ovirt/node/utils/virt.py
+++ b/scripts/tui/src/ovirt/node/utils/virt.py
@@ -87,9 +87,9 @@
     try:
         with LibvirtConnection() as con:
             num_domains = str(con.numOfDomains())
-    except libvirt.libvirtError as e:
+    except:  # libvirt.libvirtError as e:
         pass
-        # warning("Error while working with libvirt: %s" % e.message)
+        #warning("Error while working with libvirt: %s" % e.message)
     return num_domains
 
 
diff --git a/scripts/tui/src/ovirt/node/valid.py b/scripts/tui/src/ovirt/node/valid.py
index 706d3fa..9900274 100644
--- a/scripts/tui/src/ovirt/node/valid.py
+++ b/scripts/tui/src/ovirt/node/valid.py
@@ -31,7 +31,6 @@
 """
 
 
-
 class Validator(base.Base):
     """This class is used to validate user inputs
     Basically an exception is raised if an invalid value was given. The value
@@ -215,7 +214,8 @@
             self.description = "%s" % (exactly)
 
     def validate(self, value):
-        self.logger.debug("Checking number %s %s %s" % (self, self.pattern, value))
+        self.logger.debug("Checking number %s %s %s" % (self, self.pattern,
+                                                        value))
         valid = RegexValidator.validate(self, value)
         if valid and self.bounds:
             self.logger.debug("Checking bounds: %s" % self.bounds)
@@ -442,6 +442,6 @@
                 subprocess.check_call("test -b %s" % value, shell=True,
                                       close_fds=True)
                 is_valid = True
-        except Exception as e:
+        except:
             is_valid = False
-        return is_valid
\ No newline at end of file
+        return is_valid


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I03197f7daa20cabe1de8e7722f64248776121539
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