diff options
author | imarom <imarom@cisco.com> | 2016-01-12 09:47:24 -0500 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-01-12 09:49:53 -0500 |
commit | 898fadae0e9bf9d0eb46abf286a888d791bdaf96 (patch) | |
tree | 43e6e6cf91a0d48aadf5aba420e25c5b107ab53b /scripts/automation/trex_control_plane/client | |
parent | 7ce793d732d7692a60672db7f9e4f1bac9cad81e (diff) |
perfectionist's job is never done - fixed the console prompt redraw when
an async event occurs so it looks nice
Diffstat (limited to 'scripts/automation/trex_control_plane/client')
-rwxr-xr-x | scripts/automation/trex_control_plane/client/trex_stateless_client.py | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/scripts/automation/trex_control_plane/client/trex_stateless_client.py b/scripts/automation/trex_control_plane/client/trex_stateless_client.py index 42d5031e..c7a9e533 100755 --- a/scripts/automation/trex_control_plane/client/trex_stateless_client.py +++ b/scripts/automation/trex_control_plane/client/trex_stateless_client.py @@ -69,7 +69,7 @@ class CTRexStatelessClient(object): self.session_id = random.getrandbits(32) self.read_only = False self.connected = False - + self.prompt_redraw_cb = None # returns the port object @@ -99,7 +99,7 @@ class CTRexStatelessClient(object): self.events.append("{:<10} - {:^8} - {:}".format(st, prefix, format_text(msg, 'bold'))) if show: - self.prn_func(format_text("\n{:^8} - {:}".format(prefix, format_text(msg, 'bold')))) + self.prn_func(format_text("\n{:^8} - {:}".format(prefix, format_text(msg, 'bold'))), redraw_console = True) def handle_async_stats_update(self, dump_data): @@ -475,10 +475,21 @@ class CTRexStatelessClient(object): def get_verbose (self): return self.verbose - def prn_func (self, msg, level = VERBOSE_REGULAR): - if self.check_verbose(level): + def prn_func (self, msg, level = VERBOSE_REGULAR, redraw_console = False): + if not self.check_verbose(level): + return + + if redraw_console and self.prompt_redraw_cb: + print "\n" + msg + "\n" + self.prompt_redraw_cb() + else: print msg + sys.stdout.flush() + + def set_prompt_redraw_cb(self, cb): + self.prompt_redraw_cb = cb + ############# server actions ################ # ping server |