[node-patches] Change in ovirt-node[master]: utils: Add ProductInformation class

fabiand at fedoraproject.org fabiand at fedoraproject.org
Tue Dec 11 20:09:44 UTC 2012


Fabian Deutsch has uploaded a new change for review.

Change subject: utils: Add ProductInformation class
......................................................................

utils: Add ProductInformation class

Change-Id: I02dc78d8054a5959640b78a2d6037b414ae2325f
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/app.py
M scripts/tui/src/ovirt/node/utils/system.py
2 files changed, 29 insertions(+), 0 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/77/9977/1

diff --git a/scripts/tui/src/ovirt/node/app.py b/scripts/tui/src/ovirt/node/app.py
index f2f9fb6..e9842ec 100644
--- a/scripts/tui/src/ovirt/node/app.py
+++ b/scripts/tui/src/ovirt/node/app.py
@@ -101,12 +101,20 @@
                 model = plugin.model()
         return model
 
+    @property
+    def product(self):
+        return utils.system.ProductInformation()
+
     def run(self):
         self.__load_plugins()
         if not self.plugins:
             raise Exception("No plugins found in '%s'" % self.plugin_base)
         self.ui.register_hotkey("f2", self.__drop_to_shell)
         self.ui.register_hotkey("window resize", self.__check_terminal_size)
+
+        p = self.product
+        self.ui.header = "\n %s %s-%s\n" % (p.PRODUCT_SHORT, p.VERSION,
+                                          p.RELEASE)
         self.ui.footer = "Press esc to quit."
         self.ui.run()
 
diff --git a/scripts/tui/src/ovirt/node/utils/system.py b/scripts/tui/src/ovirt/node/utils/system.py
index d10c7f4..89cdd9e 100644
--- a/scripts/tui/src/ovirt/node/utils/system.py
+++ b/scripts/tui/src/ovirt/node/utils/system.py
@@ -24,6 +24,7 @@
 e.g. services, reboot ...
 """
 
+from ovirt.node import base, utils
 from ovirt.node.utils import process
 
 
@@ -33,3 +34,23 @@
 
 def poweroff():
     process.system("poweroff")
+
+
+class ProductInformation(base.Base):
+    _version_filename = "/files/etc/default/version"
+    PRODUCT_SHORT = None
+    VERSION = None
+    RLEASE = None
+
+    def __init__(self):
+        self.load()
+
+    def load(self):
+        aug = utils.AugeasWrapper()
+        augg = lambda k: aug.get("\n%s/%s\n" % (self._version_filename, k),
+                                                strip_quotes=True)
+
+        # read product / version info
+        self.PRODUCT_SHORT = augg("PRODUCT_SHORT") or "oVirt"
+        self.VERSION = augg("VERSION")
+        self.RELEASE = augg("RELEASE")


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

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