diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2006-04-25 20:54:30 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2006-04-25 20:54:30 +0000 |
commit | 1c445056e1b7868dffc6d566d14eaa806f11f926 (patch) | |
tree | e5b3453c5abe3e17102e2cbb346381caa0c03ebe /src/lib/Server/Plugin.py | |
parent | c499825cf78cdc20cd0b0c4b1442e756cc510924 (diff) | |
download | bcfg2-1c445056e1b7868dffc6d566d14eaa806f11f926.tar.gz bcfg2-1c445056e1b7868dffc6d566d14eaa806f11f926.tar.bz2 bcfg2-1c445056e1b7868dffc6d566d14eaa806f11f926.zip |
Fix cases where an empty xml file would tank Pkgmgr/Svcmgr/Rules
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@1850 ce84e21b-d406-0410-9b95-82705330c041
Diffstat (limited to 'src/lib/Server/Plugin.py')
-rw-r--r-- | src/lib/Server/Plugin.py | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/lib/Server/Plugin.py b/src/lib/Server/Plugin.py index dad8bec46..d78e6a5f1 100644 --- a/src/lib/Server/Plugin.py +++ b/src/lib/Server/Plugin.py @@ -1,7 +1,7 @@ '''This module provides the baseclass for Bcfg2 Server Plugins''' __revision__ = '$Revision$' -import logging, lxml.etree, time +import logging, lxml.etree from lxml.etree import XML, XMLSyntaxError @@ -39,15 +39,15 @@ class Plugin(object): self.data = "%s/%s" % (datastore, self.__name__) self.logger = logging.getLogger('Bcfg2.Plugins.%s' % (self.__name__)) - def BuildStructures(self, metadata): + def BuildStructures(self, _): '''Build a set of structures tailored to the client metadata''' return [] - def GetProbes(self, metadata): + def GetProbes(self, _): '''Return a set of probes for execution on client''' return [] - def ReceiveData(self, metadata, data): + def ReceiveData(self, _, dummy): '''Receive probe results pertaining to client''' pass @@ -66,7 +66,7 @@ class FileBacked(object): #self.readonce = 0 #self.HandleEvent() - def HandleEvent(self, event=None): + def HandleEvent(self, _=None): '''Read file upon update''' try: self.data = file(self.name).read() @@ -251,7 +251,7 @@ class XMLSrc(XMLFileBacked): self.pnode = None self.priority = -1 - def HandleEvent(self, event=None): + def HandleEvent(self, _=None): '''Read file upon update''' try: data = file(self.name).read() @@ -268,7 +268,7 @@ class XMLSrc(XMLFileBacked): self.cache = None try: self.priority = int(xdata.get('priority')) - except: + except (ValueError, TypeError): logger.error("Got bogus priority %s for file %s" % (xdata.get('priority'), self.name)) del xdata, data @@ -315,7 +315,8 @@ class PrioDir(Plugin, DirectoryBacked): self.logger.error("Called before data loaded") raise PluginExecutionError matching = [src for src in self.entries.values() - if src.cache[1].has_key(entry.tag) and src.cache[1][entry.tag].has_key(name)] + if src.cache and src.cache[1].has_key(entry.tag) + and src.cache[1][entry.tag].has_key(name)] if len(matching) == 0: raise PluginExecutionError elif len(matching) == 1: |