[node-patches] Change in ovirt-node[master]: fix list index error on plugins page when a manifest file do...

jboggs at redhat.com jboggs at redhat.com
Wed Apr 2 20:22:03 UTC 2014


Joey Boggs has uploaded a new change for review.

Change subject: fix list index error on plugins page when a manifest file does not exist
......................................................................

fix list index error on plugins page when a manifest file does not exist

rhbz#1039233

Signed-off-by: Joey Boggs <jboggs at redhat.com>
Change-Id: I0d82583b3aee98b6b544ec89b75fa4f6ea314685
---
M src/ovirt/node/setup/core/plugins_page.py
1 file changed, 17 insertions(+), 15 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/76/26376/1

diff --git a/src/ovirt/node/setup/core/plugins_page.py b/src/ovirt/node/setup/core/plugins_page.py
index bb8451c..f0e877c 100644
--- a/src/ovirt/node/setup/core/plugins_page.py
+++ b/src/ovirt/node/setup/core/plugins_page.py
@@ -21,6 +21,7 @@
 from ovirt.node import ui
 from ovirt.node.plugins import NodePlugin
 from ovirt.node.utils import process
+from ovirt.node.ui import InfoDialog
 import glob
 import os
 import re
@@ -99,24 +100,25 @@
             self._model["plugin"] = name
 
     def on_merge(self, changes):
+        manifest_keys = ["button.drpm", "button.dsrpm", "button.dfile"]
         p_manifests_dir = "/etc/ovirt-plugins-manifests.d"
         fn = None
-        if "button.drpm" in changes:
-            fn = glob.glob("%s/delta-manifest-rpm.txt" %
-                           (p_manifests_dir))[0]
-        elif "button.dsrpm" in changes:
-            fn = glob.glob("%s/delta-manifest-srpm.txt" %
-                           (p_manifests_dir))[0]
-        elif "button.dfile" in changes:
-            fn = glob.glob("%s/delta-manifest-file.txt" %
-                           (p_manifests_dir))[0]
+        for k in manifest_keys:
+            pfix = k.split(".")[1].lstrip("d")
+            if k in changes:
+                fn = glob.glob("%s/delta-manifest-%s.txt" %
+                               (p_manifests_dir, pfix))
+                try:
+                    fn = fn[0] # grabs plain text and not gzipped
+                    self.logger.debug("Reading manifest from: %s" % fn)
+                    with open(fn) as src:
+                        contents = src.read()
+                    return ui.TextViewDialog("output.dialog", "Manifest",
+                                             contents)
+                except:
+                    return InfoDialog("dialog.info", "An Error Occured",
+                                  "No manifest found")
 
-        if fn:
-            self.logger.debug("Reading manifest from: %s" % fn)
-            with open(fn) as src:
-                contents = src.read()
-            return ui.TextViewDialog("output.dialog", "Manifest",
-                                     contents)
 
     def __list_of_plugins(self):
         sp = sorted(self.get_plugins_list().items())


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I0d82583b3aee98b6b544ec89b75fa4f6ea314685
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-node
Gerrit-Branch: master
Gerrit-Owner: Joey Boggs <jboggs at redhat.com>



More information about the node-patches mailing list