summaryrefslogtreecommitdiffstats
path: root/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
diff options
context:
space:
mode:
authorChris St. Pierre <chris.a.st.pierre@gmail.com>2014-12-09 11:10:24 -0600
committerChris St. Pierre <chris.a.st.pierre@gmail.com>2015-02-18 08:24:24 -0600
commit89e7afbf74ffbbb54dd892bf2c4245aedee2a832 (patch)
treeed4623b5c6e39d80c132e9f21f3d4804cabd93be /src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
parent64b458b380620f84843b1841b441745a0984946f (diff)
downloadbcfg2-89e7afbf74ffbbb54dd892bf2c4245aedee2a832.tar.gz
bcfg2-89e7afbf74ffbbb54dd892bf2c4245aedee2a832.tar.bz2
bcfg2-89e7afbf74ffbbb54dd892bf2c4245aedee2a832.zip
Remove blanket excepts from plugins and lint
This removes most blanket except: clauses from all plugins, including the base plugin libraries, and bcfg2-lint. The few that remain should all be necessary. Most of the changes were quite minor, but this did require some restructuring of the CfgPrivateKeyCreator; as a result, the tests for that module were rewritten.
Diffstat (limited to 'src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py')
-rw-r--r--src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py16
1 files changed, 7 insertions, 9 deletions
diff --git a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
index 5dc3d98eb..355e53588 100644
--- a/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
+++ b/src/lib/Bcfg2/Server/Plugins/Cfg/__init__.py
@@ -553,12 +553,7 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
% (action, event.filename))
self.debug_log("%s handling %s event on %s" %
(hdlr.__name__, action, event.filename))
- try:
- self.entry_init(event, hdlr)
- except: # pylint: disable=W0702
- err = sys.exc_info()[1]
- self.logger.error("Cfg: Failed to parse %s: %s" %
- (event.filename, err))
+ self.entry_init(event, hdlr)
return
elif hdlr.ignore(event, basename=self.path):
return
@@ -732,7 +727,7 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
try:
return creator.create_data(entry, metadata)
- except:
+ except CfgCreationError:
raise PluginExecutionError("Cfg: Error creating data for %s: %s" %
(entry.get("name"), sys.exc_info()[1]))
@@ -760,6 +755,9 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
try:
return (generator.get_data(entry, metadata), generator)
except:
+ # TODO: the exceptions raised by ``get_data`` are not
+ # constrained in any way, so for now this needs to be a
+ # blanket except.
msg = "Cfg: Error rendering %s: %s" % (entry.get("name"),
sys.exc_info()[1])
self.logger.error(msg)
@@ -803,7 +801,7 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
try:
best = self.best_matching(metadata, generators)
rv.append(best.specific)
- except: # pylint: disable=W0702
+ except PluginExecutionError:
pass
if not rv or not rv[0].hostname:
@@ -835,7 +833,7 @@ class CfgEntrySet(Bcfg2.Server.Plugin.EntrySet):
raise PluginExecutionError(msg)
try:
etext = new_entry['text'].encode(Bcfg2.Options.setup.encoding)
- except:
+ except UnicodeDecodeError:
msg = "Cfg: Cannot encode content of %s as %s" % \
(name, Bcfg2.Options.setup.encoding)
self.logger.error(msg)