path checkup for lib
authorimarom <[email protected]>
Tue, 9 Feb 2016 14:21:36 +0000 (09:21 -0500)
committerimarom <[email protected]>
Tue, 9 Feb 2016 14:21:36 +0000 (09:21 -0500)
scripts/automation/trex_control_plane/stl/trex_stl_lib/trex_stl_ext.py

index f3fd522..835918d 100644 (file)
@@ -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()