From 7d6ee00bf805867080eb6c123f4d8159ef1633ed Mon Sep 17 00:00:00 2001 From: Narayan Desai Date: Mon, 8 Nov 2004 20:59:47 +0000 Subject: fix constructor call 2004/11/07 11:11:24-06:00 anl.gov!desai fix pylint initialization conditions 2004/11/04 16:49:17-06:00 anl.gov!desai fix parse failures (Logical change 1.148) git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@661 ce84e21b-d406-0410-9b95-82705330c041 --- src/lib/Server/Structures/Bundler.py | 29 +++++++++++++++++++++++++++-- 1 file changed, 27 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/lib/Server/Structures/Bundler.py b/src/lib/Server/Structures/Bundler.py index 4f0cc7e56..e26b44373 100644 --- a/src/lib/Server/Structures/Bundler.py +++ b/src/lib/Server/Structures/Bundler.py @@ -8,13 +8,25 @@ from Bcfg2.Server.Generator import SingleXMLFileBacked, XMLFileBacked, Directory from Bcfg2.Server.Structure import Structure from elementtree.ElementTree import Element, XML +from xml.parsers.expat import ExpatError class ImageFile(SingleXMLFileBacked): '''This file contains image -> system mappings''' + def __init__(self, filename, fam): + SingleXMLFileBacked.__init__(self, filename, fam) + self.images = {} + def Index(self): '''Build data structures out of the data''' + try: + xdata = XML(self.data) + except ExpatError, err: + syslog(LOG_ERR, "Failed to parse file %s" % (self.name)) + syslog(LOG_ERR, err) + del self.data + return self.images = {} - for child in XML(self.data).getchildren(): + for child in xdata.getchildren(): [name, pkg, service] = [child.get(field) for field in ['name', 'package', 'service']] for grandchild in child.getchildren(): self.images[grandchild.get('name')] = (name, pkg, service) @@ -22,12 +34,25 @@ class ImageFile(SingleXMLFileBacked): class Bundle(XMLFileBacked): '''Bundles are configuration specifications (with image/translation abstraction)''' + def __init__(self, filename, fam): + XMLFileBacked.__init__(self, filename, fam) + self.all = [] + self.attributes = {} + self.systems = {} + def Index(self): '''Build data structures from the source data''' + try: + xdata = XML(self.data) + except ExpatError, err: + syslog(LOG_ERR, "Failed to parse file %s" % (self.name)) + syslog(LOG_ERR, err) + del self.data + return self.all = [] self.systems = {} self.attributes = {} - for entry in XML(self.data).getchildren(): + for entry in xdata.getchildren(): if entry.tag == 'System': self.systems[entry.attrib['name']] = entry.getchildren() elif entry.tag == 'Attribute': -- cgit v1.2.3-1-g7c22