diff options
author | imarom <imarom@cisco.com> | 2016-03-20 16:29:23 +0200 |
---|---|---|
committer | imarom <imarom@cisco.com> | 2016-03-21 14:49:06 +0200 |
commit | 7e7cc8a3f9cfa4b0bda18b50ea79145c6bc2a045 (patch) | |
tree | c74b87de7ba812f1d0ace7d834bcefae73528c0c /scripts/automation/trex_control_plane/stl | |
parent | 14b94326315f1fa46187868dac16503b3f454b9e (diff) |
python 3 - rearrange
Diffstat (limited to 'scripts/automation/trex_control_plane/stl')
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/__init__.py | 2 | ||||
-rw-r--r-- | scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_ext.py | 58 |
2 files changed, 29 insertions, 31 deletions
diff --git a/scripts/automation/trex_control_plane/stl/trex_stl_lib/__init__.py b/scripts/automation/trex_control_plane/stl/trex_stl_lib/__init__.py index 8488a80a..672036b4 100644 --- a/scripts/automation/trex_control_plane/stl/trex_stl_lib/__init__.py +++ b/scripts/automation/trex_control_plane/stl/trex_stl_lib/__init__.py @@ -6,6 +6,6 @@ if sys.version_info < (2, 7): if sys.version_info >= (3, 0): print("\n**** TRex STL pacakge does not support Python 3 (yet) ***\n") - exit(-1) + #exit(-1) import trex_stl_ext 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 fe89160a..f91ddfab 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 @@ -14,54 +14,52 @@ if not TREX_STL_EXT_PATH: # the modules required -CLIENT_UTILS_MODULES = ['dpkt-1.8.6', - 'yaml-3.11', - 'texttable-0.8.4', - 'scapy-2.3.1' +# py-dep requires python2/python3 directories +# arch-dep requires cel59/fedora and 32bit/64bit directories +CLIENT_UTILS_MODULES = [ {'name': 'dpkt-1.8.6'}, + {'name': 'pyyaml-3.11', 'py-dep': True}, + {'name': 'texttable-0.8.4'}, + {'name': 'scapy-2.3.1'}, + {'name': 'pyzmq-14.5.0', 'py-dep': True, 'arch-dep': True} ] -CLIENT_PLATFORM_MODULES = ['pyzmq-14.5.0'] +def generate_module_path (module, is_python3, is_64bit, is_cel): + platform_path = [module['name']] + if module.get('py-dep'): + platform_path.append('python3' if is_python3 else 'python2') -def import_module_list(modules_list, platform_modules_list): + if module.get('arch-dep'): + platform_path.append('cel59' if is_cel else 'fedora18') + platform_path.append('64bit' if is_64bit else '32bit') - assert(isinstance(modules_list, list)) - assert(isinstance(platform_modules_list, list)) + return os.path.normcase(os.path.join(TREX_STL_EXT_PATH, *platform_path)) - # regular modules - for p in modules_list: - full_path = os.path.join(TREX_STL_EXT_PATH, p) - fix_path = os.path.normcase(full_path) - 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(fix_path) - exit(0) - - sys.path.insert(1, full_path) +def import_module_list(modules_list): - # platform depdendant modules + # platform data 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) + # regular modules + for p in modules_list: + full_path = generate_module_path(p, is_python3, is_64bit, is_cel) + + if not os.path.exists(full_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(full_path) exit(0) sys.path.insert(1, full_path) -import_module_list(CLIENT_UTILS_MODULES, CLIENT_PLATFORM_MODULES) + +import_module_list(CLIENT_UTILS_MODULES) |