summaryrefslogtreecommitdiff
path: root/openstackclient/common/clientmanager.py
diff options
context:
space:
mode:
authorHongbin Lu <hongbin034@gmail.com>2017-10-07 14:03:14 -0400
committerHongbin Lu <hongbin034@gmail.com>2017-10-07 17:07:24 -0400
commit599fa782623598208c012125dd988a48774cfc6e (patch)
tree221c3eac562de6cb66471f275083e491bbce9b01 /openstackclient/common/clientmanager.py
parenta87bd58fb4de5dc5f99193b88d2a3f8bd1338c52 (diff)
downloadpython-openstackclient-599fa782623598208c012125dd988a48774cfc6e.tar.gz
Be robust on import plugin module
On loading external plugin, OSC should be robust on importing the plugin module so that commands from other modules can continue to execute. Closes-Bug: #1722008 Change-Id: Ibe716681c7f78fabee31b7ef281af2588d68ab30
Diffstat (limited to 'openstackclient/common/clientmanager.py')
-rw-r--r--openstackclient/common/clientmanager.py8
1 files changed, 7 insertions, 1 deletions
diff --git a/openstackclient/common/clientmanager.py b/openstackclient/common/clientmanager.py
index ea581696..7b2c8a5c 100644
--- a/openstackclient/common/clientmanager.py
+++ b/openstackclient/common/clientmanager.py
@@ -134,7 +134,13 @@ def get_plugin_modules(group):
for ep in pkg_resources.iter_entry_points(group):
LOG.debug('Found plugin %r', ep.name)
- __import__(ep.module_name)
+ try:
+ __import__(ep.module_name)
+ except Exception:
+ sys.stderr.write(
+ "WARNING: Failed to import plugin %r.\n" % ep.name)
+ continue
+
module = sys.modules[ep.module_name]
mod_list.append(module)
init_func = getattr(module, 'Initialize', None)