summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSol Jerome <sol.jerome@gmail.com>2010-07-16 16:39:50 -0500
committerSol Jerome <sol.jerome@gmail.com>2010-07-16 16:39:50 -0500
commit9a9f5e05db62550074d5abae5503f3a45526dd60 (patch)
treed44e9e06ec1cfc0bdb407d55bb9c048814698b94
parentb40469de951c4f8c042db943832ed9339dfd654a (diff)
downloadbcfg2-9a9f5e05db62550074d5abae5503f3a45526dd60.tar.gz
bcfg2-9a9f5e05db62550074d5abae5503f3a45526dd60.tar.bz2
bcfg2-9a9f5e05db62550074d5abae5503f3a45526dd60.zip
TGenshi: Warn when genshi is not installed
Signed-off-by: Sol Jerome <sol.jerome@gmail.com>
-rw-r--r--src/lib/Server/Plugins/TGenshi.py23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/lib/Server/Plugins/TGenshi.py b/src/lib/Server/Plugins/TGenshi.py
index b83f00b02..53b78b84f 100644
--- a/src/lib/Server/Plugins/TGenshi.py
+++ b/src/lib/Server/Plugins/TGenshi.py
@@ -1,20 +1,25 @@
"""This module implements a templating generator based on Genshi."""
__revision__ = '$Revision$'
-from genshi.template import TemplateLoader, \
- TextTemplate, MarkupTemplate, TemplateError
-try:
- from genshi.template import NewTextTemplate
- have_ntt = True
-except:
- have_ntt = False
import logging
import Bcfg2.Server.Plugin
-import genshi.core
-import genshi.input
logger = logging.getLogger('Bcfg2.Plugins.TGenshi')
+# try to import genshi stuff
+try:
+ import genshi.core
+ import genshi.input
+ from genshi.template import TemplateLoader, \
+ TextTemplate, MarkupTemplate, TemplateError
+except ImportError:
+ logger.error("TGenshi: Failed to import Genshi. Is it installed?")
+ raise Bcfg2.Server.Plugin.PluginInitError
+try:
+ from genshi.template import NewTextTemplate
+ have_ntt = True
+except:
+ have_ntt = False
def removecomment(stream):
"""A genshi filter that removes comments from the stream."""