From 9a9f5e05db62550074d5abae5503f3a45526dd60 Mon Sep 17 00:00:00 2001 From: Sol Jerome Date: Fri, 16 Jul 2010 16:39:50 -0500 Subject: TGenshi: Warn when genshi is not installed Signed-off-by: Sol Jerome --- src/lib/Server/Plugins/TGenshi.py | 23 ++++++++++++++--------- 1 file 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.""" -- cgit v1.2.3-1-g7c22