diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2004-11-08 20:59:47 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2004-11-08 20:59:47 +0000 |
commit | 7d6ee00bf805867080eb6c123f4d8159ef1633ed (patch) | |
tree | 43973f1d4b2e9f3f5ca2190f05577b59f7154cee /src/lib/Server | |
parent | 426e8fad3aa09a124d3bd5c9e628739d05797909 (diff) | |
download | bcfg2-7d6ee00bf805867080eb6c123f4d8159ef1633ed.tar.gz bcfg2-7d6ee00bf805867080eb6c123f4d8159ef1633ed.tar.bz2 bcfg2-7d6ee00bf805867080eb6c123f4d8159ef1633ed.zip |
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
Diffstat (limited to 'src/lib/Server')
-rw-r--r-- | src/lib/Server/Structures/Bundler.py | 29 |
1 files changed, 27 insertions, 2 deletions
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': |