From 4c6450049d82fb9f98dbafe98d3ea1e229bf2a6d Mon Sep 17 00:00:00 2001 From: imarom Date: Mon, 25 Jan 2016 10:04:26 -0500 Subject: API cleaning up --- scripts/automation/trex_control_plane/console/trex_console.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'scripts/automation/trex_control_plane/console/trex_console.py') diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index 88ff45dc..62b68861 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -36,7 +36,6 @@ from client_utils import parsing_opts import trex_tui from functools import wraps - __version__ = "1.1" # console custom logger @@ -56,7 +55,7 @@ class ConsoleLogger(LoggerApi): # override this for the prompt fix def async_log (self, msg, level = LoggerApi.VERBOSE_REGULAR, newline = True): self.log(msg, level, newline) - if self.prompt_redraw: + if ( (self.level >= LoggerApi.VERBOSE_REGULAR) and self.prompt_redraw ): self.prompt_redraw() self.flush() @@ -717,13 +716,14 @@ def main(): # TUI or no acquire will give us READ ONLY mode try: - stateless_client.connect("RO") + stateless_client.connect() except STLError as e: logger.log("Log:\n" + format_text(e.brief() + "\n", 'bold')) return if not options.tui and options.acquire: try: + # acquire all ports stateless_client.acquire() except STLError as e: logger.log("Log:\n" + format_text(e.brief() + "\n", 'bold')) @@ -751,7 +751,8 @@ def main(): print "\n\n*** Caught Ctrl + C... Exiting...\n\n" finally: - stateless_client.teardown(stop_traffic = False) + with stateless_client.logger.supress(): + stateless_client.disconnect() if __name__ == '__main__': -- cgit From 2828fc9aab33b742c59a499dbf06ea2239ec6220 Mon Sep 17 00:00:00 2001 From: imarom Date: Tue, 26 Jan 2016 08:57:43 -0500 Subject: API simplification and example --- scripts/automation/trex_control_plane/console/trex_console.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'scripts/automation/trex_control_plane/console/trex_console.py') diff --git a/scripts/automation/trex_control_plane/console/trex_console.py b/scripts/automation/trex_control_plane/console/trex_console.py index 62b68861..1defc6b2 100755 --- a/scripts/automation/trex_control_plane/console/trex_console.py +++ b/scripts/automation/trex_control_plane/console/trex_console.py @@ -29,11 +29,12 @@ import sys import tty, termios import trex_root_path from common.trex_streams import * -from client.trex_stateless_client import STLClient, LoggerApi, STLError +from client.trex_stateless_client import STLClient, LoggerApi from common.text_opts import * from client_utils.general_utils import user_input, get_current_user from client_utils import parsing_opts import trex_tui +from common.trex_stl_exceptions import * from functools import wraps __version__ = "1.1" @@ -752,7 +753,7 @@ def main(): finally: with stateless_client.logger.supress(): - stateless_client.disconnect() + stateless_client.disconnect(stop_traffic = False) if __name__ == '__main__': -- cgit