From 9932ff8dcf4f8b6b6f3986832f8a1a8f8461c743 Mon Sep 17 00:00:00 2001 From: imarom Date: Mon, 18 Jan 2016 06:59:36 -0500 Subject: async publish now --- .../automation/trex_control_plane/common/trex_types.py | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'scripts/automation/trex_control_plane/common') diff --git a/scripts/automation/trex_control_plane/common/trex_types.py b/scripts/automation/trex_control_plane/common/trex_types.py index 21deffd2..5c29f59b 100644 --- a/scripts/automation/trex_control_plane/common/trex_types.py +++ b/scripts/automation/trex_control_plane/common/trex_types.py @@ -17,7 +17,7 @@ class RC(): def __init__ (self, rc = None, data = None): self.rc_list = [] - if (rc != None) and (data != None): + if (rc != None): tuple_rc = namedtuple('RC', ['rc', 'data']) self.rc_list.append(tuple_rc(rc, data)) @@ -35,16 +35,26 @@ class RC(): def data (self): d = [x.data if x.rc else "" for x in self.rc_list] - return (d if len(d) > 1 else d[0]) + return (d if len(d) != 1 else d[0]) def err (self): e = [x.data if not x.rc else "" for x in self.rc_list] - return (e if len(e) > 1 else e[0]) + return (e if len(e) != 1 else e[0]) def __str__ (self): return str(self.data()) if self else str(self.err()) - def annotate (self, log_func, desc = None, show_status = True): + def prn_func (self, msg, newline = True): + if newline: + print msg + else: + print msg, + + def annotate (self, log_func = None, desc = None, show_status = True): + + if not log_func: + log_func = self.prn_func + if desc: log_func(format_text('\n{:<60}'.format(desc), 'bold'), newline = False) else: -- cgit 1.2.3-korg