diff options
author | imarom <imarom@cisco.com> | 2016-01-18 06:59:36 -0500 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-01-21 10:11:54 -0500 |
commit | 9932ff8dcf4f8b6b6f3986832f8a1a8f8461c743 (patch) | |
tree | 28c577725377131eafbd54319407066dcbd385a8 /scripts/automation/trex_control_plane/common | |
parent | 11d328d3e40b04540489eec83ac484d5b06254bb (diff) |
async publish now
Diffstat (limited to 'scripts/automation/trex_control_plane/common')
-rw-r--r-- | scripts/automation/trex_control_plane/common/trex_types.py | 18 |
1 files changed, 14 insertions, 4 deletions
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: |