summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/common
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2015-12-07 03:40:55 -0500
committerimarom <imarom@cisco.com>2015-12-07 09:08:40 -0500
commitb420c37087df630bcc0f97baccd073b838517b46 (patch)
treed45cf1224a94b3fc49bd0c0470ed5ec8021f84ec /scripts/automation/trex_control_plane/common
parent7a501df413eafeff45d826c44824a74c8180394a (diff)
some validate info
Diffstat (limited to 'scripts/automation/trex_control_plane/common')
-rwxr-xr-xscripts/automation/trex_control_plane/common/text_opts.py11
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')