Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def ascii_split (s):
output = []
lines = s.split('\n')
for elem in lines:
if ansi_len(elem) > 0:
output.append(elem)
return output
# success
if func_rc is None:
self.last_status = format_text("[OK]", 'green')
# errors
else:
err_msgs = ascii_split(str(func_rc))
if not err_msgs:
err_msgs = ['Unknown error']
self.last_status = format_text(clear_formatting(err_msgs[0]), 'red')
if len(err_msgs) > 1:
self.last_status += " [{0} more errors messages]".format(len(err_msgs) - 1)
color = 'red'
# trim too long lines
if ansi_len(self.last_status) > TrexTUI.MIN_COLS:
self.last_status = format_text(self.last_status[:TrexTUI.MIN_COLS] + "...", color, 'bold')
self.remove_all_streams(opts.ports)
# pack the profile
try:
for port in opts.ports:
profile = STLProfile.load(opts.file[0],
direction = tunables.get('direction', port % 2),
port_id = port,
**tunables)
self.add_streams(profile.get_streams(), ports = port)
except STLError as e:
for line in e.brief().splitlines():
if ansi_len(line.strip()):
error = line
msg = format_text("\nError loading profile '{0}'".format(opts.file[0]), 'bold')
self.logger.log(msg + '\n')
self.logger.log(e.brief() + "\n")
return RC_ERR("%s: %s" % (msg, error))
if opts.dry:
self.validate(opts.ports, opts.mult, opts.duration, opts.total)
else:
self.start(opts.ports,
opts.mult,
opts.force,
opts.duration,
opts.total,