summaryrefslogtreecommitdiffstats
path: root/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_ext.py
diff options
context:
space:
mode:
authorimarom <imarom@cisco.com>2016-03-20 11:49:17 +0200
committerimarom <imarom@cisco.com>2016-03-20 11:50:17 +0200
commit94ec2f0c0a6fc30fb3a9a11243146e0d878c4c5b (patch)
treea63d4b1e4b22938a3506a55030a3866e0d5211ca /scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_ext.py
parent33c80d0f2c3af8b302e50ce3925869dfd37267ed (diff)
ZMQ CEL5.9 / 32 bit / 64 bit with python 2 / python 3
Diffstat (limited to 'scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_ext.py')
-rw-r--r--scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_ext.py81
1 files changed, 31 insertions, 50 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_ext.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_ext.py
index 9289e513..fe89160a 100644
--- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_ext.py
+++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_ext.py
@@ -1,6 +1,7 @@
import sys
import os
import warnings
+import platform
# if not set - set it to default
TREX_STL_EXT_PATH = os.environ.get('TREX_STL_EXT_PATH')
@@ -20,9 +21,15 @@ CLIENT_UTILS_MODULES = ['dpkt-1.8.6',
]
-def import_module_list(modules_list):
+CLIENT_PLATFORM_MODULES = ['pyzmq-14.5.0']
+
+
+def import_module_list(modules_list, platform_modules_list):
+
assert(isinstance(modules_list, list))
+ assert(isinstance(platform_modules_list, list))
+ # regular modules
for p in modules_list:
full_path = os.path.join(TREX_STL_EXT_PATH, p)
fix_path = os.path.normcase(full_path)
@@ -30,57 +37,31 @@ def import_module_list(modules_list):
if not os.path.exists(fix_path):
print "Unable to find required module library: '{0}'".format(p)
print "Please provide the correct path using TREX_STL_EXT_PATH variable"
- print "current path used: '{0}'".format(TREX_STL_EXT_PATH)
+ print "current path used: '{0}'".format(fix_path)
exit(0)
sys.path.insert(1, full_path)
+ # platform depdendant modules
+ is_64bit = platform.architecture()[0] == '64bit'
+ is_python3 = (sys.version_info >= (3, 0))
+ is_cel = os.path.exists('/etc/system-profile')
+
+ platform_path = "{0}/{1}/{2}".format('cel59' if is_cel else 'fedora18',
+ 'python3' if is_python3 else 'python2',
+ '64bit' if is_64bit else '32bit')
+
+ for p in platform_modules_list:
+ full_path = os.path.join(TREX_STL_EXT_PATH, p, platform_path)
+ fix_path = os.path.normcase(full_path)
+
+ if not os.path.exists(fix_path):
+ print "Unable to find required platfrom dependant module library: '{0}'".format(p)
+ print "platform dependant path used was '{0}'".format(fix_path)
+ exit(0)
+
+ sys.path.insert(1, full_path)
+
+
-# TODO; REFACTOR THIS....it looks horrible
-def import_platform_dirs ():
- # handle platform dirs
-
- # try fedora 18 first and then cel5.9
- # we are using the ZMQ module to determine the right platform
-
- full_path = os.path.join(TREX_STL_EXT_PATH, 'platform/fedora18')
- fix_path = os.path.normcase(full_path)
- sys.path.insert(0, full_path)
- try:
- # try to import and delete it from the namespace
- import zmq
- del zmq
- return
- except:
- sys.path.pop(0)
- pass
-
- full_path = os.path.join(TREX_STL_EXT_PATH, 'platform/cel59')
- fix_path = os.path.normcase(full_path)
- sys.path.insert(0, full_path)
- try:
- # try to import and delete it from the namespace
- import zmq
- del zmq
- return
- except:
- sys.path.pop(0)
- pass
-
- full_path = os.path.join(TREX_STL_EXT_PATH, 'platform/cel59/32bit')
- fix_path = os.path.normcase(full_path)
- sys.path.insert(0, full_path)
- try:
- # try to import and delete it from the namespace
- import zmq
- del zmq
- return
-
- except:
- sys.path.pop(0)
- sys.modules['zmq'] = None
- warnings.warn("unable to determine platform type for ZMQ import")
-
-
-import_module_list(CLIENT_UTILS_MODULES)
-import_platform_dirs()
+import_module_list(CLIENT_UTILS_MODULES, CLIENT_PLATFORM_MODULES)