diff options
author | imarom <imarom@cisco.com> | 2015-12-07 03:40:55 -0500 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2015-12-07 09:08:40 -0500 |
commit | b420c37087df630bcc0f97baccd073b838517b46 (patch) | |
tree | d45cf1224a94b3fc49bd0c0470ed5ec8021f84ec /scripts/automation/trex_control_plane/common | |
parent | 7a501df413eafeff45d826c44824a74c8180394a (diff) |
some validate info
Diffstat (limited to 'scripts/automation/trex_control_plane/common')
-rwxr-xr-x | scripts/automation/trex_control_plane/common/text_opts.py | 11 |
1 files changed, 11 insertions, 0 deletions
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') |