prelude-correlator/master: Catch exception on plugin loading

[email protected] Thu, 18 Jun 2009 15:33:16 +0200 (CEST)
Newsgroups gmane.comp.security.ids.prelude.cvs
Message-ID <[email protected]>
commit 1cc0b307bce48106744c93caae41311dcb126be9
Author: Yoann Vandoorselaere <[email protected]>
Date:   Thu Jun 18 13:04:11 2009 +0200

    Catch exception on plugin loading
    
    Prevent prelude-correlator from abording if a plugin fail. Emit
    a warning explaining why a given plugin couldn't load, and continue
    processing.


========================================

 PreludeCorrelator/pluginmanager.py |    8 +++++++-
 1 files changed, 7 insertions(+), 1 deletions(-)

========================================

diff --git a/PreludeCorrelator/pluginmanager.py b/PreludeCorrelator/pluginmanager.py
index a476497..4bd24eb 100644
--- a/PreludeCorrelator/pluginmanager.py
+++ b/PreludeCorrelator/pluginmanager.py
@@ -54,7 +54,13 @@ class PluginManager:
         for entrypoint in pkg_resources.iter_entry_points(ENTRYPOINT):
             plugin_class = entrypoint.load()
 
-            self.__instances.append(plugin_class(env))
+            try:
+                pi = plugin_class(env)
+            except Exception, e:
+                env.logger.warning("Exception occurred while loading %s: %s" % (plugin_class.__name__, e))
+                continue
+
+            self.__instances.append(pi)
             self._count += 1
 
     def getPluginCount(self):
_______________________________________________
Prelude-cvslog site list
[email protected]
http://lists.prelude-ids.org/mailman/listinfo/prelude-cvslog