From f0c48e4ca5b07100063f0c5754523280349d72d5 Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Fri, 3 Dec 2004 19:44:47 +0000 Subject: fix base (Logical change 1.157) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@701 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Structures/Base.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/Server/Structures/Base.py b/src/lib/Server/Structures/Base.py index 5b3ac8865..b2c6be92a 100644 --- a/src/lib/Server/Structures/Base.py +++ b/src/lib/Server/Structures/Base.py @@ -2,11 +2,12 @@ __revision__ = '$Revision$' from copy import deepcopy - +from syslog import syslog, LOG_ERR from Bcfg2.Server.Generator import SingleXMLFileBacked from Bcfg2.Server.Structure import Structure from elementtree.ElementTree import Element, XML +from xml.parsers.expat import ExpatError class BaseFile(SingleXMLFileBacked): '''The Base file contains unstructured/independent configuration elements''' @@ -14,7 +15,12 @@ class BaseFile(SingleXMLFileBacked): def Index(self): '''Store XML data in reasonable structures''' self.store = {'Class':{'all':[]}, 'Image':{'all':[]}, 'all':[]} - for entry in XML(self.data).getchildren(): + try: + xdata = XML(self.data) + except ExpatError: + syslog(LOG_ERR, "Failed to parse base.xml") + return + for entry in xdata.getchildren(): self.store[entry.tag][entry.get('name')] = {'all':[], 'Class':{}, 'Image':{}} if entry.tag in ['Image', 'Class']: for child in entry.getchildren(): -- cgit v1.2.3-1-g7c22