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

fabiand at fedoraproject.org fabiand at fedoraproject.org
Mon Feb 25 17:27:03 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: Several syntax cleanups
......................................................................

Several syntax cleanups

Change-Id: Ic1d59ff95586cffc00075f04406e27f606168f24
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/installer/installation_device_page.py
M scripts/tui/src/ovirt/node/installer/password_page.py
M scripts/tui/src/ovirt/node/installer/progress_page.py
M scripts/tui/src/ovirt/node/installer/upgrade_page.py
M scripts/tui/src/ovirt/node/installer/welcome_page.py
M scripts/tui/src/ovirt/node/plugins.py
M scripts/tui/src/ovirt/node/setup/security_page.py
M scripts/tui/src/ovirt/node/setup/snmp_page.py
M scripts/tui/src/ovirt/node/setup/status_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/utils/fs.py
12 files changed, 35 insertions(+), 28 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/21/12421/1

diff --git a/scripts/tui/src/ovirt/node/installer/installation_device_page.py b/scripts/tui/src/ovirt/node/installer/installation_device_page.py
index c551830..35612d9 100644
--- a/scripts/tui/src/ovirt/node/installer/installation_device_page.py
+++ b/scripts/tui/src/ovirt/node/installer/installation_device_page.py
@@ -113,4 +113,4 @@
         elif changes.contains_any(["installation.device.custom",
                                    "dialog.device.custom.save"]):
             self._dialog.close()
-            return self.ui_content()
\ No newline at end of file
+            return self.ui_content()
diff --git a/scripts/tui/src/ovirt/node/installer/password_page.py b/scripts/tui/src/ovirt/node/installer/password_page.py
index 72d3e95..8470cc3 100644
--- a/scripts/tui/src/ovirt/node/installer/password_page.py
+++ b/scripts/tui/src/ovirt/node/installer/password_page.py
@@ -59,8 +59,10 @@
         if changes.contains_any(["root.password",
                                  "root.password_confirmation"]):
             self._model.update(changes)
-            if self._model.get("root.password", "") != \
-                self._model.get("root.password_confirmation", ""):
+            root_pw, root_pw_conf = self._model.get("root.password", ""), \
+                self._model.get("root.password_confirmation", "")
+
+            if root_pw != root_pw_conf:
                 raise exceptions.InvalidData("Passwords must be the same.")
             else:
                 self.widgets["root.password"].valid(True)
diff --git a/scripts/tui/src/ovirt/node/installer/progress_page.py b/scripts/tui/src/ovirt/node/installer/progress_page.py
index 97e09db..412f404 100644
--- a/scripts/tui/src/ovirt/node/installer/progress_page.py
+++ b/scripts/tui/src/ovirt/node/installer/progress_page.py
@@ -22,7 +22,6 @@
 from ovirt.node.config import defaults
 import threading
 import time
-import traceback
 
 
 """
diff --git a/scripts/tui/src/ovirt/node/installer/upgrade_page.py b/scripts/tui/src/ovirt/node/installer/upgrade_page.py
index 1c9623c..2632d12 100644
--- a/scripts/tui/src/ovirt/node/installer/upgrade_page.py
+++ b/scripts/tui/src/ovirt/node/installer/upgrade_page.py
@@ -75,8 +75,9 @@
         if changes.contains_any(["upgrade.password",
                                  "upgrade.password_confirmation"]):
             self._model.update(changes)
-            if self._model.get("upgrade.password", "") != \
-                self._model.get("upgrade.password_confirmation", ""):
+            up_pw, up_pw_conf = self._model.get("upgrade.password", ""), \
+                self._model.get("upgrade.password_confirmation", "")
+            if up_pw != up_pw_conf:
                 self.widgets["password.info"].text("")
                 raise exceptions.InvalidData("Passwords must be the same.")
             else:
@@ -91,12 +92,12 @@
             return
 
         if changes.contains_any(["upgrade.current_password",
-                                   "button.next"]):
+                                 "button.next"]):
             pam = security.PAM()
             if pam.authenticate(os.getlogin(),
                                 changes["upgrade.current_password"]):
-
-                    self.application.ui.navigate.to_plugin(installer.progress_page.Plugin)
+                nav = self.application.ui.navigate
+                nav.to_plugin(installer.progress_page.Plugin)
             else:
                 msg = "Current password is invalid"
             self.widgets["current_password.info"].text(msg)
diff --git a/scripts/tui/src/ovirt/node/installer/welcome_page.py b/scripts/tui/src/ovirt/node/installer/welcome_page.py
index c5d4056..a400891 100644
--- a/scripts/tui/src/ovirt/node/installer/welcome_page.py
+++ b/scripts/tui/src/ovirt/node/installer/welcome_page.py
@@ -18,7 +18,7 @@
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
 # MA  02110-1301, USA.  A copy of the GNU General Public License is
 # also available at http://www.gnu.org/copyleft/gpl.html.
-from ovirt.node import plugins, ui, utils, installer, config
+from ovirt.node import plugins, ui, utils, installer
 from ovirt.node.utils import virt, system
 import os
 
@@ -66,18 +66,18 @@
 
     def on_merge(self, effective_changes):
 
+        nav = self.application.ui.navigate
         if "button.install" in effective_changes:
             self.application.ui.navigate.to_next_plugin()
             self._model["method"] = "install"
 
         elif "button.upgrade" in effective_changes:
-            self.application.ui.navigate.to_plugin(installer.upgrade_page.Plugin)
+            nav.to_plugin(installer.upgrade_page.Plugin)
             self._model["method"] = "upgrade"
 
         elif "button.reinstall" in effective_changes:
-            self.application.ui.navigate.to_plugin(installer.upgrade_page.Plugin)
+            nav.to_plugin(installer.upgrade_page.Plugin)
             self._model["method"] = "reinstall"
-
 
     def ___installation_option(self):
         if self.application.args.dry:
diff --git a/scripts/tui/src/ovirt/node/plugins.py b/scripts/tui/src/ovirt/node/plugins.py
index 494c035..cd3bfd9 100644
--- a/scripts/tui/src/ovirt/node/plugins.py
+++ b/scripts/tui/src/ovirt/node/plugins.py
@@ -22,7 +22,7 @@
 """
 This contains much stuff related to plugins
 """
-from ovirt.node import base, exceptions, valid, ui
+from ovirt.node import base, exceptions, ui
 import pkgutil
 
 
@@ -280,7 +280,7 @@
             if self.validate_changes:
                 self.validate(change)
             self.on_change(change)
-        except exceptions.InvalidData as e:
+        except exceptions.InvalidData:
             self.on_valid(False)
             raise
         self.__changes.update(change)
diff --git a/scripts/tui/src/ovirt/node/setup/security_page.py b/scripts/tui/src/ovirt/node/setup/security_page.py
index 6265306..8b50b78 100644
--- a/scripts/tui/src/ovirt/node/setup/security_page.py
+++ b/scripts/tui/src/ovirt/node/setup/security_page.py
@@ -75,8 +75,11 @@
     def on_change(self, changes):
         if changes.contains_any(["passwd.admin.password",
                                  "passwd.admin.password_confirmation"]):
-            if self._model.get("passwd.admin.password", "") != \
-                self._model.get("passwd.admin.password_confirmation", ""):
+            model = self._model
+            admin_pw = model.get("passwd.admin.password", "")
+            admin_pw_conf = model.get("passwd.admin.password_confirmation", "")
+
+            if admin_pw != admin_pw_conf:
                 raise exceptions.InvalidData("Passwords must be the same.")
             else:
                 self.widgets["passwd.admin.password"].valid(True)
diff --git a/scripts/tui/src/ovirt/node/setup/snmp_page.py b/scripts/tui/src/ovirt/node/setup/snmp_page.py
index 397ba1c..cf69d62 100644
--- a/scripts/tui/src/ovirt/node/setup/snmp_page.py
+++ b/scripts/tui/src/ovirt/node/setup/snmp_page.py
@@ -70,8 +70,10 @@
     def on_change(self, changes):
         if changes.contains_any(["snmp.password",
                                  "snmp.password_confirmation"]):
-            if self._model.get("snmp.password", "") != \
-                self._model.get("snmp.password_confirmation", ""):
+
+            snmp_pw = self._model.get("snmp.password", "")
+            snmp_pw_conf = self._model.get("snmp.password_confirmation", "")
+            if snmp_pw != snmp_pw_conf:
                 raise exceptions.InvalidData("Passwords must be the same.")
             else:
                 self.widgets["snmp.password"].valid(True)
diff --git a/scripts/tui/src/ovirt/node/setup/status_page.py b/scripts/tui/src/ovirt/node/setup/status_page.py
index 3be1f81..32e56fc 100644
--- a/scripts/tui/src/ovirt/node/setup/status_page.py
+++ b/scripts/tui/src/ovirt/node/setup/status_page.py
@@ -192,14 +192,12 @@
         self.buttons = [ui.CloseButton("dialog.close")]
 
 
-class CPUFeaturesDialog(ui.Dialog):
+class CPUFeaturesDialog(ui.InfoDialog):
     """The dialog beeing displayed when th euser clicks CPU Details
     """
     def __init__(self, path, title):
-        super(CPUFeaturesDialog, self).__init__(path, title, [])
-        self.children = [ui.Label("label[0]", utils.system.cpu_details()),
-                         ]
-        self.buttons = [ui.CloseButton("dialog.close")]
+        msg = utils.system.cpu_details()
+        super(CPUFeaturesDialog, self).__init__(path, title, msg)
 
 
 class LockDialog(ui.Dialog):
diff --git a/scripts/tui/src/ovirt/node/ui/__init__.py b/scripts/tui/src/ovirt/node/ui/__init__.py
index 57de1cd..7237ff2 100644
--- a/scripts/tui/src/ovirt/node/ui/__init__.py
+++ b/scripts/tui/src/ovirt/node/ui/__init__.py
@@ -475,6 +475,7 @@
             self.on_activate.connect(ChangeAction())
             self.on_activate.connect(SaveAction())
         self.on_exception.connect(DisplayExceptionNotice())
+
     def selection(self, selected=None):
         """Get/Select the given item (key) or multiple items if multi
 
@@ -714,6 +715,7 @@
         except Exception as e:
             self.logger.warning("An exception in the Transaction: %s" % e,
                                 exc_info=True)
+
     def __run_transaction(self):
         try:
             self.add_update("Checking pre-conditions ...")
diff --git a/scripts/tui/src/ovirt/node/ui/urwid_builder.py b/scripts/tui/src/ovirt/node/ui/urwid_builder.py
index 0f1ff02..6848dec 100644
--- a/scripts/tui/src/ovirt/node/ui/urwid_builder.py
+++ b/scripts/tui/src/ovirt/node/ui/urwid_builder.py
@@ -19,7 +19,6 @@
 # MA  02110-1301, USA.  A copy of the GNU General Public License is
 # also available at http://www.gnu.org/copyleft/gpl.html.
 from ovirt.node import ui, exceptions, base
-from ovirt.node.exceptions import InvalidData
 from ovirt.node.ui import widgets as uw
 import urwid
 
@@ -27,7 +26,6 @@
 A visitor to build the urwid TUI from the abstract UI definitions.
 Is based on the visitor pattern
 """
-
 
 
 class UrwidUIBuilder(ui.AbstractUIBuilder):
@@ -382,7 +380,8 @@
                ('plugin.widget.label', element_styles["text"]),
                ('plugin.widget.label.keyword', element_styles["label"]),
                ('plugin.widget.progressbar.box', element_styles["disabled"]),
-               ('plugin.widget.progressbar.uncomplete', element_styles["label"]),
+               ('plugin.widget.progressbar.uncomplete',
+                element_styles["label"]),
                ('plugin.widget.progressbar.complete', "white",
                 element_styles["disabled"]),
                ('plugin.widget.options', element_styles["label"]),
diff --git a/scripts/tui/src/ovirt/node/utils/fs.py b/scripts/tui/src/ovirt/node/utils/fs.py
index 6cde158..84ef6bb 100644
--- a/scripts/tui/src/ovirt/node/utils/fs.py
+++ b/scripts/tui/src/ovirt/node/utils/fs.py
@@ -64,8 +64,9 @@
     LOGGER.debug("Moving '%s' to '%s' atomically" % fns)
     try:
         os.rename(*fns)
-    except Exception as e:
+    except Exception:
         backup.remove()
+        LOGGER.debug("Error on moving file '%s'" % fns, exc_info=True)
         raise
 
 


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

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