From 0aa48dc740012b94cdd0cea3e49c1cb0258d9ce9 Mon Sep 17 00:00:00 2001 From: imarom Date: Tue, 9 Feb 2016 09:21:36 -0500 Subject: [PATCH] path checkup for lib --- .../stl/trex_stl_lib/trex_stl_ext.py | 23 ++++++++++------------ 1 file changed, 10 insertions(+), 13 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 f3fd5224..835918d9 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 @@ -11,11 +11,6 @@ if not TREX_STL_EXT_PATH: # ../../../../external_libs TREX_STL_EXT_PATH = os.path.abspath(os.path.join(CURRENT_PATH, os.pardir, os.pardir, os.pardir, os.pardir, 'external_libs')) -# check path exists -if not os.path.exists(TREX_STL_EXT_PATH): - print "Unable to find external packages path: '{0}'".format(TREX_STL_EXT_PATH) - print "Please provide the correct path using TREX_STL_EXT_PATH variable" - exit(0) # the modules required CLIENT_UTILS_MODULES = ['dpkt-1.8.6', @@ -24,20 +19,22 @@ CLIENT_UTILS_MODULES = ['dpkt-1.8.6', 'scapy-2.3.1' ] -def import_client_utils_modules(): - import_module_list(CLIENT_UTILS_MODULES) - def import_module_list(modules_list): assert(isinstance(modules_list, list)) + for p in modules_list: full_path = os.path.join(TREX_STL_EXT_PATH, p) fix_path = os.path.normcase(full_path) - sys.path.insert(1, 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(TREX_STL_EXT_PATH) + exit(0) + + sys.path.insert(1, full_path) - import_platform_dirs() - def import_platform_dirs (): @@ -73,5 +70,5 @@ def import_platform_dirs (): warnings.warn("unable to determine platform type for ZMQ import") -import_client_utils_modules() - +import_module_list(CLIENT_UTILS_MODULES) +import_platform_dirs() -- 2.16.6