From b420c37087df630bcc0f97baccd073b838517b46 Mon Sep 17 00:00:00 2001 From: imarom Date: Mon, 7 Dec 2015 03:40:55 -0500 Subject: some validate info --- scripts/automation/trex_control_plane/common/text_opts.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'scripts/automation/trex_control_plane/common') diff --git a/scripts/automation/trex_control_plane/common/text_opts.py b/scripts/automation/trex_control_plane/common/text_opts.py index 06c2c056..69c76674 100755 --- a/scripts/automation/trex_control_plane/common/text_opts.py +++ b/scripts/automation/trex_control_plane/common/text_opts.py @@ -19,6 +19,17 @@ TEXT_CODES = {'bold': {'start': '\x1b[1m', 'end': '\x1b[24m'}} +def format_num (size, suffix = ""): + for unit in ['','K','M','G','T','P']: + if abs(size) < 1000.0: + return "%3.2f %s%s" % (size, unit, suffix) + size /= 1000.0 + + return "NaN" + +def format_percentage (size): + return "%0.2f %%" % (size) + def bold(text): return text_attribute(text, 'bold') -- cgit 1.2.3-korg