[node-patches] Change in ovirt-node[master]: Add application to plugins and time page building

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


Fabian Deutsch has uploaded a new change for review.

Change subject: Add application to plugins and time page building
......................................................................

Add application to plugins and time page building

… and some additional fixes.

Change-Id: I650592a500bf0127dfd085db3cfaa08720148a3f
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/app.py
M scripts/tui/src/ovirt/node/plugins/__init__.py
M scripts/tui/src/ovirt/node/tui.py
M scripts/tui/src/ovirt/node/ui/widgets.py
4 files changed, 22 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/07/9907/1

diff --git a/scripts/tui/src/ovirt/node/app.py b/scripts/tui/src/ovirt/node/app.py
index 6a92967..9950ca3 100644
--- a/scripts/tui/src/ovirt/node/app.py
+++ b/scripts/tui/src/ovirt/node/app.py
@@ -45,7 +45,7 @@
         self.ui = ovirt.node.tui.UrwidTUI(self)
 
     def __load_plugins(self):
-        self.plugins = [m.Plugin() for m in ovirt.node.plugins.load_all()]
+        self.plugins = [m.Plugin(self) for m in ovirt.node.plugins.load_all()]
 
         for plugin in self.plugins:
             LOGGER.debug("Loading plugin %s" % plugin)
@@ -55,8 +55,19 @@
         with self.ui.suspended():
             ovirt.node.utils.process.system("reset ; bash")
 
+    def model(self, plugin_name):
+        model = None
+        for plugin in self.plugins:
+            if plugin.name() == plugin_name:
+                model = plugin.model()
+        return model
+
     def run(self):
         self.__load_plugins()
         self.ui.register_hotkey("f12", self.__drop_to_shell)
         self.ui.footer = "Press ctrl+x or esc to quit."
         self.ui.run()
+
+    def quit(self):
+        LOGGER.info("Quitting")
+        self.ui.quit()
diff --git a/scripts/tui/src/ovirt/node/plugins/__init__.py b/scripts/tui/src/ovirt/node/plugins/__init__.py
index 4f2a7ab..f3b2337 100644
--- a/scripts/tui/src/ovirt/node/plugins/__init__.py
+++ b/scripts/tui/src/ovirt/node/plugins/__init__.py
@@ -67,8 +67,9 @@
     Errors are propagated back by using Errors/Exceptions.
     """
 
-    def __init__(self):
+    def __init__(self, application):
         self.__changes = {}
+        self.application = application
 
     def name(self):
         """Returns the name of the plugin.
diff --git a/scripts/tui/src/ovirt/node/tui.py b/scripts/tui/src/ovirt/node/tui.py
index c32de79..0fcd2db 100644
--- a/scripts/tui/src/ovirt/node/tui.py
+++ b/scripts/tui/src/ovirt/node/tui.py
@@ -25,6 +25,7 @@
 import urwid
 
 import logging
+import timeit
 
 import ovirt.node
 import ovirt.node.plugins
@@ -101,12 +102,15 @@
         return urwid.Frame(body, header, footer)
 
     def __change_to_plugin(self, plugin):
+        timer = timeit.Timer()
         page = ovirt.node.ui.builder.page_from_plugin(self, plugin)
         self.display_page(page)
+        LOGGER.debug("Build and displayed page in %ss" % timer.timeit())
 
     def display_page(self, page):
         # FIXME why is this fixed?
         filler = urwid.Filler(page, ("fixed top", 1), height=30)
+#        filler = urwid.Filler(page)
         self.__page_frame.body = filler
 
     def display_dialog(self, body, title):
@@ -192,6 +196,7 @@
     def quit(self):
         """Quit the UI
         """
+        LOGGER.info("Quitting, exitting mainloop")
         raise urwid.ExitMainLoop()
 
     def run(self):
diff --git a/scripts/tui/src/ovirt/node/ui/widgets.py b/scripts/tui/src/ovirt/node/ui/widgets.py
index 41a0aa0..defe838 100644
--- a/scripts/tui/src/ovirt/node/ui/widgets.py
+++ b/scripts/tui/src/ovirt/node/ui/widgets.py
@@ -395,9 +395,9 @@
 
     def __init__(self, widgets):
 #        self._listwalker = urwid.SimpleListWalker(widgets)
-#        self._listbox = urwid.ListBox(self._listwalker)
-        self._pile = urwid.Pile(widgets)
-        super(PageWidget, self).__init__(self._pile)
+#        self._container = urwid.ListBox(self._listwalker)
+        self._container = urwid.Pile(widgets)
+        super(PageWidget, self).__init__(self._container)
 
 
 class RowWidget(urwid.Columns):


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

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