summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Laszlo <tim.laszlo@gmail.com>2010-07-16 21:31:53 +0000
committerSol Jerome <sol.jerome@gmail.com>2010-07-16 16:36:15 -0500
commitb40469de951c4f8c042db943832ed9339dfd654a (patch)
treede5e0eafd185ac80d7da4152b295262db2745966
parent646a8f42b21477788a759942f14a8d1997df1709 (diff)
downloadbcfg2-b40469de951c4f8c042db943832ed9339dfd654a.tar.gz
bcfg2-b40469de951c4f8c042db943832ed9339dfd654a.tar.bz2
bcfg2-b40469de951c4f8c042db943832ed9339dfd654a.zip
Bundler: Log something for genshi errors
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5978 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r--src/lib/Server/Plugins/SGenshi.py20
1 files changed, 14 insertions, 6 deletions
diff --git a/src/lib/Server/Plugins/SGenshi.py b/src/lib/Server/Plugins/SGenshi.py
index 84fbb507d..cead06e34 100644
--- a/src/lib/Server/Plugins/SGenshi.py
+++ b/src/lib/Server/Plugins/SGenshi.py
@@ -1,6 +1,7 @@
'''This module implements a templating generator based on Genshi'''
__revision__ = '$Revision$'
+import genshi.input
import genshi.template
import lxml.etree
import logging
@@ -17,10 +18,18 @@ class SGenshiTemplateFile(Bcfg2.Server.Plugins.TGenshi.TemplateFile):
if not hasattr(self, 'template'):
logger.error("No parsed template information for %s" % (self.name))
raise Bcfg2.Server.Plugin.PluginExecutionError
- stream = self.template.generate(metadata=metadata,).filter( \
- Bcfg2.Server.Plugins.TGenshi.removecomment)
- data = stream.render('xml', strip_whitespace=False)
- return lxml.etree.XML(data)
+ try:
+ stream = self.template.generate(metadata=metadata,).filter( \
+ Bcfg2.Server.Plugins.TGenshi.removecomment)
+ data = stream.render('xml', strip_whitespace=False)
+ return lxml.etree.XML(data)
+ except LookupError, lerror:
+ logger.error('Genshi lookup error: %s' % lerror)
+ except genshi.template.TemplateError, terror:
+ logger.error('Genshi template error: %s' % terror)
+ except genshi.input.ParseError, perror:
+ logger.error('Genshi parse error: %s' % perror)
+ raise
class SGenshiEntrySet(Bcfg2.Server.Plugin.EntrySet):
@@ -42,8 +51,7 @@ class SGenshiEntrySet(Bcfg2.Server.Plugin.EntrySet):
for entry in self.get_matching(metadata):
try:
ret.append(entry.get_xml_value(metadata))
- except genshi.template.TemplateError, terror:
- logger.error('Genshi template error: %s' % terror)
+ except:
logger.error("SGenshi: Failed to template file %s" % entry.name)
return ret