aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoss Brattain <ross.b.brattain@intel.com>2017-05-21 21:08:49 -0700
committerRoss Brattain <ross.b.brattain@intel.com>2017-06-02 16:06:40 -0700
commitaa63d13770d6417963afff7d5304dee04c3d35a1 (patch)
tree83cacaea48a96da4e4b237bddfa916373f9095d0
parent28a97ee05186295b7d71f449ac703bf78e5fd358 (diff)
utils: make module import safer
If a module fails to import, then ignore it and try the next module. This can help if certain module depenencies aren't installed, e.g. TREX. Change-Id: I2bc4384429fabd61cd430817489cb2f3c86fe9b2 Signed-off-by: Ross Brattain <ross.b.brattain@intel.com>
-rw-r--r--yardstick/common/utils.py5
1 files changed, 4 insertions, 1 deletions
diff --git a/yardstick/common/utils.py b/yardstick/common/utils.py
index f4def8533..7aab46942 100644
--- a/yardstick/common/utils.py
+++ b/yardstick/common/utils.py
@@ -81,7 +81,10 @@ def import_modules_from_package(package):
continue
new_package = ".".join(root.split(os.sep)).split("....")[1]
module_name = "%s.%s" % (new_package, filename[:-3])
- try_append_module(module_name, sys.modules)
+ try:
+ try_append_module(module_name, sys.modules)
+ except ImportError:
+ logger.exception("unable to import %s", module_name)
def parse_yaml(file_path):