[Python-checkins] r69778 - tracker/instances/spambayes_integration/detectors/spambayes.py

martin.v.loewis python-checkins at python.org
Thu Feb 19 20:57:48 CET 2009


Author: martin.v.loewis
Date: Thu Feb 19 20:57:48 2009
New Revision: 69778

Log:
Issue #237: Make spambayes settings optional.


Modified:
   tracker/instances/spambayes_integration/detectors/spambayes.py

Modified: tracker/instances/spambayes_integration/detectors/spambayes.py
==============================================================================
--- tracker/instances/spambayes_integration/detectors/spambayes.py	(original)
+++ tracker/instances/spambayes_integration/detectors/spambayes.py	Thu Feb 19 20:57:48 2009
@@ -38,8 +38,16 @@
     return (content, tokens)
 
 def check_spambayes(db, content, tokens):
-    spambayes_uri = db.config.detectors['SPAMBAYES_URI']
-    server = xmlrpclib.ServerProxy(spambayes_uri, verbose=False)
+    try:
+        spambayes_uri = db.config.detectors['SPAMBAYES_URI']
+    except KeyError, e:
+        return (False, str(e))
+
+    try:
+        server = xmlrpclib.ServerProxy(spambayes_uri, verbose=False)
+    except IOError, e:
+        return (False, str(e))
+
 
     try:
         prob = server.score({'content':content}, tokens, {})


More information about the Python-checkins mailing list