[node-patches] Change in ovirt-node[master]: [DRAFT] setup: Fix ping page

fabiand at fedoraproject.org fabiand at fedoraproject.org
Mon Mar 18 09:43:55 UTC 2013


Fabian Deutsch has uploaded a new change for review.

Change subject: [DRAFT] setup: Fix ping page
......................................................................

[DRAFT] setup: Fix ping page

Previously the progressbar wasn't updated correctly.

rhbz#917461
rhbz#917458

Change-Id: I4d1aa33185867a3bb84667e45c9cdfd7bb974370
Signed-off-by: Fabian Deutsch <fabiand at fedoraproject.org>
---
M scripts/tui/src/ovirt/node/setup/ping.py
1 file changed, 25 insertions(+), 7 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-node refs/changes/25/13125/1

diff --git a/scripts/tui/src/ovirt/node/setup/ping.py b/scripts/tui/src/ovirt/node/setup/ping.py
index 45f0b5e..4229ac0 100644
--- a/scripts/tui/src/ovirt/node/setup/ping.py
+++ b/scripts/tui/src/ovirt/node/setup/ping.py
@@ -18,13 +18,15 @@
 # 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, valid, ui
+from ovirt.node.utils import process
+import threading
+
 
 """
 A ping tool page
 """
 
-from ovirt.node import plugins, valid, ui
-from ovirt.node.utils import process
 
 
 class Plugin(plugins.NodePlugin):
@@ -107,11 +109,27 @@
                 cmd = "ping6"
 
             cmd = "%s -c %s %s" % (cmd, count, addr)
+
+            ping = PingThread(self, cmd, count)
+            ping.start()
+
+
+class PingThread(threading.Thread):
+    def __init__(self, plugin, cmd, count):
+        self.p = plugin
+        self.cmd = cmd
+        self.count = count
+
+    def run(self):
+            progressbar = self.p.widgets["ping.progress"]
+            stdoutdump = self.p.widgets["ping.result"]
+            ui_thread = self.p.application.ui.app.ui.thread_connection()
             out = ""
             current = 0
-            for line in process.pipe_async(cmd):
+
+            for line in process.pipe_async(self.cmd):
                 out += line
-                if "icmp_req" in line:
-                    current += 100.0 / float(count)
-                    self.widgets["ping.progress"].current(current)
-                self.widgets["ping.result"].text("Result:\n\n%s" % out)
+                if "time=" in line:
+                    current += 100.0 / float(self.count)
+                    ui_thread.call(lambda: progressbar.current(current))
+                ui_thread.call(lambda: stdoutdump.text("%s" % out))


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

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