summaryrefslogtreecommitdiffstats
path: root/ipalib/cli.py
diff options
context:
space:
mode:
authorPetr Viktorin <pviktori@redhat.com>2013-09-30 16:11:46 +0200
committerMartin Kosek <mkosek@redhat.com>2013-10-30 11:50:05 +0100
commitdadf7cddf0da834feafe234cecd23b4a0e9f39ba (patch)
tree24b537c503de3efbcc66b2cfd8484882f45818b6 /ipalib/cli.py
parent15618beab6b22558933e650a416dcd038c7ffc8a (diff)
downloadfreeipa-dadf7cddf0da834feafe234cecd23b4a0e9f39ba.tar.gz
freeipa-dadf7cddf0da834feafe234cecd23b4a0e9f39ba.tar.xz
freeipa-dadf7cddf0da834feafe234cecd23b4a0e9f39ba.zip
Help plugin: don't fail if a topic's module is not found
Previously the help plugin failed when searching for the docstring when a topic's module was not found. This can happen when some server plugins are loaded (e.g. for tests). Use empty documentation when the topic is not found.
Diffstat (limited to 'ipalib/cli.py')
-rw-r--r--ipalib/cli.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/ipalib/cli.py b/ipalib/cli.py
index 5f02e929f..b17888e52 100644
--- a/ipalib/cli.py
+++ b/ipalib/cli.py
@@ -722,9 +722,14 @@ class help(frontend.Local):
self._topics[topic_name][2].append(c)
else:
m = '%s.%s' % (self._PLUGIN_BASE_MODULE, topic_name)
- doc = (
- unicode(_(sys.modules[m].__doc__)) or ''
- ).strip().split('\n', 1)[0]
+ try:
+ module = sys.modules[m]
+ except KeyError:
+ doc = ''
+ else:
+ doc = (
+ unicode(_(module.__doc__)) or ''
+ ).strip().split('\n', 1)[0]
self._topics[topic_name] = [doc, 0, [c]]
mcl = max((self._topics[topic_name][1], len(c.name)))
self._topics[topic_name][1] = mcl