summaryrefslogtreecommitdiffstats
path: root/scripts
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-01-13 04:20:33 -0500
committerimarom <imarom@cisco.com>2016-01-13 04:28:34 -0500
commit862ec9b81ef22c860d4fb9fa45f0531f1c238bcc (patch)
treeba7916f8159f3da3f7e8016f72a0a781d290fa31 /scripts
parentfdc012345f5ab9dc40d5a571855a7d2010d88475 (diff)
TUI now writes to a string buffer and then to screen
(should be faster, like double buffering and switch)
Diffstat (limited to 'scripts')
-rw-r--r--scripts/automation/trex_control_plane/client_utils/text_tables.py2
-rwxr-xr-xscripts/automation/trex_control_plane/common/trex_stats.py8
-rwxr-xr-xscripts/automation/trex_control_plane/console/trex_console.py2
-rw-r--r--scripts/automation/trex_control_plane/console/trex_tui.py15
4 files changed, 18 insertions, 9 deletions
diff --git a/scripts/automation/trex_control_plane/client_utils/text_tables.py b/scripts/automation/trex_control_plane/client_utils/text_tables.py
index 2fa17f09..d8928da8 100644
--- a/scripts/automation/trex_control_plane/client_utils/text_tables.py
+++ b/scripts/automation/trex_control_plane/client_utils/text_tables.py
@@ -25,8 +25,8 @@ def generate_trex_stats_table():
def print_table_with_header(texttable_obj, header="", untouched_header=""):
header = header.replace("_", " ").title() + untouched_header
print format_text(header, 'cyan', 'underline') + "\n"
- print texttable_obj.draw() + "\n"
+ print (texttable_obj.draw() + "\n").encode('utf-8')
if __name__ == "__main__":
pass
diff --git a/scripts/automation/trex_control_plane/common/trex_stats.py b/scripts/automation/trex_control_plane/common/trex_stats.py
index e88a1148..a6add4ac 100755
--- a/scripts/automation/trex_control_plane/common/trex_stats.py
+++ b/scripts/automation/trex_control_plane/common/trex_stats.py
@@ -116,11 +116,11 @@ class CTRexInfoGenerator(object):
("state", []),
("--", []),
("opackets", []),
- ("obytes", []),
("ipackets", []),
+ ("obytes", []),
("ibytes", []),
- ("ierrors", []),
("oerrors", []),
+ ("ierrors", []),
("tx-bytes", []),
("rx-bytes", []),
("tx-pkts", []),
@@ -478,11 +478,11 @@ class CPortStats(CTRexStats):
"state": self._port_obj.get_port_state_name() if self._port_obj else "",
"--": " ",
"opackets" : self.get_rel("opackets"),
- "obytes" : self.get_rel("obytes"),
"ipackets" : self.get_rel("ipackets"),
+ "obytes" : self.get_rel("obytes"),
"ibytes" : self.get_rel("ibytes"),
- "ierrors" : self.get_rel("ierrors"),
"oerrors" : self.get_rel("oerrors"),
+ "ierrors" : self.get_rel("ierrors"),
"tx-bytes": self.get_rel("obytes", format = True, suffix = "B"),
"rx-bytes": self.get_rel("ibytes", format = True, suffix = "B"),
diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py
index a6090832..fe909c09 100755
--- a/scripts/automation/trex_control_plane/console/trex_console.py
+++ b/scripts/automation/trex_control_plane/console/trex_console.py
@@ -498,7 +498,7 @@ class TRexConsole(TRexGeneralCmd):
exe += './trex-console -t -q -s {0} -p {1}'.format(self.stateless_client.get_server_ip(), self.stateless_client.get_server_port())
- cmd = ['xterm', '-geometry', '111x42', '-title', 'trex_tui', '-e', exe]
+ cmd = ['xterm', '-geometry', '111x42', '-sl', '0', '-title', 'trex_tui', '-e', exe]
subprocess.Popen(cmd)
return
diff --git a/scripts/automation/trex_control_plane/console/trex_tui.py b/scripts/automation/trex_control_plane/console/trex_tui.py
index c2048c9d..dbbac02b 100644
--- a/scripts/automation/trex_control_plane/console/trex_tui.py
+++ b/scripts/automation/trex_control_plane/console/trex_tui.py
@@ -7,6 +7,7 @@ from common import trex_stats
from client_utils import text_tables
from collections import OrderedDict
import datetime
+from cStringIO import StringIO
class SimpleBar(object):
def __init__ (self, desc, pattern):
@@ -322,8 +323,7 @@ class TrexTUIPanelManager():
if self.show_log:
self.log.show()
-
- sys.stdout.flush()
+
def handle_key (self, ch):
# check for the manager registered actions
@@ -459,8 +459,17 @@ class TrexTUI():
def draw_screen (self, force_draw = False):
if (self.draw_policer >= 5) or (force_draw):
- self.clear_screen()
+
+ # capture stdout to a string
+ old_stdout = sys.stdout
+ sys.stdout = mystdout = StringIO()
self.pm.show()
+ sys.stdout = old_stdout
+
+ self.clear_screen()
+ print mystdout.getvalue()
+ sys.stdout.flush()
+
self.draw_policer = 0
else:
self.draw_policer += 1