summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-05-19 18:27:24 +0300
committerimarom <imarom@cisco.com>2016-05-19 18:28:12 +0300
commit134182597898323d1d47229e9af55df7616b7a1e (patch)
tree8e4e8ed3daa9a0c08029486465fc97c2566365c1 /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py
parent85fb692a12e7b0777e233bd94f0c4f7e2aacb2fd (diff)
enhance stats to support JSON
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py11
1 files changed, 5 insertions, 6 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py
index d84af22f..85215f3d 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_types.py
@@ -147,16 +147,15 @@ def listify (x):
return [x]
# shows as 'N/A', but does not let any compares for user to not mistake in automation
-class StatNotAvailable(object):
- def __init__(self, stat_name):
- self.stat_name = stat_name
-
- def __repr__(self, *args, **kwargs):
- return 'N/A'
+class StatNotAvailable(str):
+ def __new__(cls, value, *args, **kwargs):
+ cls.stat_name = value
+ return super(X, cls).__new__(cls, 'N/A')
def __cmp__(self, *args, **kwargs):
raise Exception("Stat '%s' not available at this setup" % self.stat_name)
+
class LRU_cache(OrderedDict):
def __init__(self, maxlen = 20, *args, **kwargs):
OrderedDict.__init__(self, *args, **kwargs)