skip unsupported plugin friendly
authorJF Ding <Jian-feng.Ding@intel.com>
Thu, 15 Sep 2011 09:17:59 +0000 (18:17 +0900)
committerJF Ding <Jian-feng.Ding@intel.com>
Thu, 15 Sep 2011 09:17:59 +0000 (18:17 +0900)
catch the ImportErrors, show warning, and skip it

mic/pluginmgr.py

index 61997dc..73775a9 100644 (file)
@@ -69,9 +69,12 @@ class PluginMgr(object):
                     if mod in sys.modules:
                         msger.debug("Module %s already exists, skip" % mod)
                     else:
-                        pymod = __import__(mod)
-                        self.plugin_dirs[pdir] = True
-                        msger.debug("Plugin module %s:%s importing" % (mod, pymod.__file__))
+                        try:
+                            pymod = __import__(mod)
+                            self.plugin_dirs[pdir] = True
+                            msger.debug("Plugin module %s:%s imported" % (mod, pymod.__file__))
+                        except ImportError, e:
+                            msger.warning('%s, skip plugin %s/%s' %(str(e), os.path.basename(pdir), mod))
 
             del(sys.path[0])