[Spambayes-checkins] SF.net SVN: spambayes:[3206] trunk/spambayes
montanaro at users.sourceforge.net
montanaro at users.sourceforge.net
Tue Nov 25 04:29:21 CET 2008
Revision: 3206
http://spambayes.svn.sourceforge.net/spambayes/?rev=3206&view=rev
Author: montanaro
Date: 2008-11-25 03:29:21 +0000 (Tue, 25 Nov 2008)
Log Message:
-----------
accidentally checked in the whole shootin' match
Modified Paths:
--------------
trunk/spambayes/CHANGELOG.txt
trunk/spambayes/contrib/SmarterHTTPServer.py
trunk/spambayes/contrib/bulkgraph.py
trunk/spambayes/contrib/findbest.py
trunk/spambayes/contrib/mod_spambayes.py
trunk/spambayes/contrib/nway.py
trunk/spambayes/contrib/pycksum.py
trunk/spambayes/contrib/sb_culler.py
trunk/spambayes/contrib/spamcounts.py
trunk/spambayes/contrib/tte.py
trunk/spambayes/pspam/pop.py
trunk/spambayes/pspam/scoremsg.py
trunk/spambayes/pspam/update.py
trunk/spambayes/scripts/core_server.py
trunk/spambayes/scripts/sb_bnfilter.py
trunk/spambayes/scripts/sb_bnserver.py
trunk/spambayes/scripts/sb_client.py
trunk/spambayes/scripts/sb_dbexpimp.py
trunk/spambayes/scripts/sb_imapfilter.py
trunk/spambayes/scripts/sb_mailsort.py
trunk/spambayes/scripts/sb_mboxtrain.py
trunk/spambayes/scripts/sb_notesfilter.py
trunk/spambayes/scripts/sb_pop3dnd.py
trunk/spambayes/scripts/sb_server.py
trunk/spambayes/scripts/sb_upload.py
trunk/spambayes/scripts/sb_xmlrpcserver.py
trunk/spambayes/setup.py
trunk/spambayes/spambayes/ImapUI.py
trunk/spambayes/spambayes/Options.py
trunk/spambayes/spambayes/Version.py
trunk/spambayes/spambayes/__init__.py
trunk/spambayes/spambayes/chi2.py
trunk/spambayes/spambayes/optimize.py
trunk/spambayes/spambayes/storage.py
trunk/spambayes/spambayes/tokenizer.py
trunk/spambayes/testtools/es2hs.py
trunk/spambayes/testtools/incremental.py
trunk/spambayes/utilities/HistToGNU.py
trunk/spambayes/utilities/convert_config_file.py
trunk/spambayes/utilities/convert_db.py
trunk/spambayes/utilities/extractmessages.py
trunk/spambayes/utilities/hammer.py
trunk/spambayes/utilities/loosecksum.py
trunk/spambayes/utilities/mboxcount.py
trunk/spambayes/utilities/mkreversemap.py
trunk/spambayes/utilities/split.py
trunk/spambayes/utilities/splitn.py
trunk/spambayes/utilities/splitndirs.py
trunk/spambayes/windows/autoconfigure.py
trunk/spambayes/windows/pop3proxy_service.py
Modified: trunk/spambayes/CHANGELOG.txt
===================================================================
--- trunk/spambayes/CHANGELOG.txt 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/CHANGELOG.txt 2008-11-25 03:29:21 UTC (rev 3206)
@@ -1,11 +1,5 @@
[Note that all dates are in ISO 8601 format, e.g. YYYY-MM-DD to ease sorting]
-Release 1.1b1
-=============
-
-Skip Montanaro 2008-11-23 Route all pickle reads and writes through safepickle module.
-Skip Montanaro 2008-11-23 Pick off a bunch of pylint nit (still tons to do).
-
Release 1.1a5
=============
Modified: trunk/spambayes/contrib/SmarterHTTPServer.py
===================================================================
--- trunk/spambayes/contrib/SmarterHTTPServer.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/contrib/SmarterHTTPServer.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -20,6 +20,7 @@
import SimpleHTTPServer
import urllib
import cgi
+import shutil
import mimetypes
import re
try:
Modified: trunk/spambayes/contrib/bulkgraph.py
===================================================================
--- trunk/spambayes/contrib/bulkgraph.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/contrib/bulkgraph.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -32,15 +32,15 @@
quiet mode; no output
"""
+import mboxutils
import getopt
+import hammie
import sys
import os
import re
import time
import filecmp
-from spambayes import mboxutils, hammie
-
program = sys.argv[0]
loud = True
day = 24 * 60 * 60
Modified: trunk/spambayes/contrib/findbest.py
===================================================================
--- trunk/spambayes/contrib/findbest.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/contrib/findbest.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -66,6 +66,7 @@
import sys
import os
+import cPickle as pickle
import getopt
import math
@@ -74,8 +75,6 @@
from spambayes.hammie import Hammie
from spambayes.tokenizer import tokenize
from spambayes.Options import options
-from spambayes import storage
-from spambayes.safepickle import pickle_read, pickle_write
cls = Classifier()
h = Hammie(cls)
@@ -99,6 +98,7 @@
def score(unsure, h, cls, scores, msgids=None, skipspam=False):
"""See what effect on others each msg in unsure has"""
+ ham_cutoff = options["Categorization", "ham_cutoff"]
spam_cutoff = options["Categorization", "spam_cutoff"]
# compute a base - number of messages in unsure already in the
@@ -223,7 +223,7 @@
print "scoring"
if best:
- last_scores = pickle_read(bestfile)
+ last_scores = pickle.load(file(bestfile))
last_scores = last_scores.items()
last_scores.sort()
msgids = set()
@@ -240,7 +240,7 @@
pass
if not best:
- pickle_write(bestfile, scores)
+ pickle.dump(scores, file(bestfile, 'w'))
return 0
Modified: trunk/spambayes/contrib/mod_spambayes.py
===================================================================
--- trunk/spambayes/contrib/mod_spambayes.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/contrib/mod_spambayes.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -5,24 +5,26 @@
## Author: Skip Montanaro <skip at pobox.com>
##
+import os
+
from proxy3_filter import *
import proxy3_options
-from spambayes import hammie, Options
+from spambayes import hammie, Options, mboxutils
dbf = Options.get_pathname_option("Storage", "persistent_storage_file")
class SpambayesFilter(BufferAllFilter):
- checker = hammie.open(dbf, 1, 'r')
+ hammie = hammie.open(dbf, 1, 'r')
def filter(self, s):
if self.reply.split()[1] == '200':
- prob = self.checker.score("%s\r\n%s" % (self.serverheaders, s))
+ prob = self.hammie.score("%s\r\n%s" % (self.serverheaders, s))
print "| prob: %.5f" % prob
if prob >= Options.options["Categorization", "spam_cutoff"]:
print self.serverheaders
print "text:", s[0:40], "...", s[-40:]
return "not authorized"
- return s
+ return s
from proxy3_util import *
Modified: trunk/spambayes/contrib/nway.py
===================================================================
--- trunk/spambayes/contrib/nway.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/contrib/nway.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -70,7 +70,7 @@
prog = os.path.basename(sys.argv[0])
-def usage():
+def help():
print >> sys.stderr, __doc__ % globals()
def main(args):
@@ -78,9 +78,10 @@
for opt, arg in opts:
if opt == '-h':
- usage()
+ help()
return 0
+ tagdb_list = []
msg = mboxutils.get_message(sys.stdin)
try:
del msg["X-Spambayes-Classification"]
Modified: trunk/spambayes/contrib/pycksum.py
===================================================================
--- trunk/spambayes/contrib/pycksum.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/contrib/pycksum.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -97,12 +97,12 @@
body = text.split("\n\n", 1)[1]
lines = clean(body).split("\n")
chunksize = len(lines)//4+1
- digest = []
+ sum = []
for i in range(4):
chunk = "\n".join(lines[i*chunksize:(i+1)*chunksize])
- digest.append(md5.new(chunk).hexdigest())
+ sum.append(md5.new(chunk).hexdigest())
- return ".".join(digest)
+ return ".".join(sum)
def save_checksum(cksum, f):
pieces = cksum.split('.')
@@ -118,12 +118,12 @@
if not db.has_key(subsum):
db[subsum] = str(time.time())
if len(db) > maxdblen:
- items = [(float(db[k]), k) for k in db.keys()]
+ items = [(float(db[k]),k) for k in db.keys()]
items.sort()
# the -20 brings us down a bit below the max so we aren't
# constantly running this chunk of code
items = items[:-(maxdblen-20)]
- for v, k in items:
+ for v,k in items:
del db[k]
else:
result = 0
Modified: trunk/spambayes/contrib/sb_culler.py
===================================================================
--- trunk/spambayes/contrib/sb_culler.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/contrib/sb_culler.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -30,23 +30,20 @@
This program requires Python 2.3 or newer.
"""
-import socket
-socket.setdefaulttimeout(10)
-
-import traceback, md5, os
+import sets, traceback, md5, os
import poplib
import posixpath
-
-import sets
from email import Header, Utils
from spambayes import mboxutils, hammie
-from spambayes.Options import options
+import socket
+socket.setdefaulttimeout(10)
+
DO_ACTIONS = 1
VERBOSE_LEVEL = 1
APPEND_TO_FILE = "append_to_file"
-DELETE_FROM_MAILBOX = "delete"
+DELETE = "delete"
KEEP_IN_MAILBOX = "keep in mailbox"
SPAM = "spam"
VIRUS = "virus"
@@ -111,7 +108,7 @@
def DELETE(mi, log):
"""Action: delete message from mailbox"""
- log.do_action(DELETE_FROM_MAILBOX)
+ log.do_action(DELETE)
if not DO_ACTIONS:
return
mi.mailbox.dele(mi.i)
Modified: trunk/spambayes/contrib/spamcounts.py
===================================================================
--- trunk/spambayes/contrib/spamcounts.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/contrib/spamcounts.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -19,11 +19,13 @@
import getopt
import re
import sets
+import os
+import shelve
import csv
-from spambayes.Options import options
+from spambayes.Options import options, get_pathname_option
from spambayes.tokenizer import tokenize
-from spambayes.storage import database_type, open_storage
+from spambayes.storage import STATE_KEY, database_type, open_storage
prog = sys.argv[0]
Modified: trunk/spambayes/contrib/tte.py
===================================================================
--- trunk/spambayes/contrib/tte.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/contrib/tte.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -100,7 +100,7 @@
def train(store, hambox, spambox, maxmsgs, maxrounds, tdict, reverse, verbose,
ratio):
- round = 0
+ smisses = hmisses = round = 0
ham_cutoff = Options.options["Categorization", "ham_cutoff"]
spam_cutoff = Options.options["Categorization", "spam_cutoff"]
@@ -114,19 +114,19 @@
hambone_ = list(reversed(hambone_))
spamcan_ = list(reversed(spamcan_))
- nspam, nham = len(spamcan_), len(hambone_)
+ nspam,nham = len(spamcan_),len(hambone_)
if ratio:
- rspam, rham = ratio
+ rspam,rham = ratio
# If the actual ratio of spam to ham in the database is better than
# what was asked for, use that better ratio.
if (rspam > rham) == (rspam * nham > rham * nspam):
- rspam, rham = nspam, nham
+ rspam,rham = nspam,nham
# define some indexing constants
ham = 0
spam = 1
name = ('ham','spam')
- misses = [0, 0]
+ misses = [0,0]
misclassified = lambda is_spam, score: (
is_spam and score < spam_cutoff or not is_spam and score > ham_cutoff)
@@ -140,9 +140,9 @@
hambone = iter(hambone_)
spamcan = iter(spamcan_)
- i = [0, 0]
+ i = [0,0]
msgs_processed = 0
- misses = [0, 0]
+ misses = [0,0]
training_sets = [hambone, spamcan]
while not maxmsgs or msgs_processed < maxmsgs:
@@ -153,7 +153,7 @@
try:
train_msg = training_sets[train_spam].next()
except StopIteration:
- break
+ break;
i[train_spam] += 1
msgs_processed += 1
@@ -164,7 +164,7 @@
score = store.spamprob(tokens)
selector = train_msg["message-id"] or train_msg["subject"]
- if misclassified(train_spam, score) and selector is not None:
+ if misclassified(train_spam,score) and selector is not None:
if verbose:
print >> sys.stderr, "\tmiss %s: %.6f %s" % (
name[train_spam], score, selector)
@@ -179,25 +179,24 @@
print "\rround: %2d, msgs: %4d, ham misses: %3d, spam misses: %3d, %.1fs" % \
(round, msgs_processed, misses[0], misses[1], seconds)
- training_sets = [hambone, spamcan]
+ training_sets = [hambone,spamcan]
# We count all untrained messages so the user knows what was skipped.
# We also tag them for saving so we don't lose messages which might have
# value in a future run
- for is_spam in ham, spam:
+ for is_spam in ham,spam:
nleft = 0
try:
while True:
msg = training_sets[is_spam].next()
score = store.spamprob(tokenize(msg))
- if misclassified(is_spam, score):
+ if misclassified(is_spam,score):
tdict[msg["message-id"]] = True
nleft += 1
except StopIteration:
- if nleft:
- print nleft, "untrained %ss" % name[is_spam]
+ if nleft: print nleft, "untrained %ss" % name[is_spam]
def cull(mbox_name, cullext, designation, tdict):
print "writing new %s mbox..." % designation
Modified: trunk/spambayes/pspam/pop.py
===================================================================
--- trunk/spambayes/pspam/pop.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/pspam/pop.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -27,6 +27,7 @@
"""
import SocketServer
+import asyncore
try:
import cStringIO as StringIO
except ImportError:
@@ -36,8 +37,11 @@
import re
import socket
import sys
+import threading
import time
+import ZODB
+from ZEO.ClientStorage import ClientStorage
import zLOG
from spambayes.tokenizer import tokenize
Modified: trunk/spambayes/pspam/scoremsg.py
===================================================================
--- trunk/spambayes/pspam/scoremsg.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/pspam/scoremsg.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -6,7 +6,11 @@
import locale
from types import UnicodeType
+import ZODB
+from ZEO.ClientStorage import ClientStorage
+
import pspam.database
+from spambayes.Options import options
from spambayes.tokenizer import tokenize
try:
Modified: trunk/spambayes/pspam/update.py
===================================================================
--- trunk/spambayes/pspam/update.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/pspam/update.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -2,6 +2,9 @@
import os
import sys
+import ZODB
+from ZEO.ClientStorage import ClientStorage
+
import pspam.database
from pspam.profile import Profile
Modified: trunk/spambayes/scripts/core_server.py
===================================================================
--- trunk/spambayes/scripts/core_server.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/scripts/core_server.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -94,9 +94,11 @@
o Graphs. Of something. Who cares what?
"""
-import sys, getopt
+import sys, getopt, time
+from email.Header import Header
from spambayes import Dibbler
+from spambayes import storage
from spambayes.Options import options, _
from spambayes.UserInterface import UserInterfaceServer
from spambayes.Version import get_current_version
Modified: trunk/spambayes/scripts/sb_bnfilter.py
===================================================================
--- trunk/spambayes/scripts/sb_bnfilter.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/scripts/sb_bnfilter.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -157,44 +157,40 @@
if error:
sys.exit(error)
-def make_socket(server_options, filename):
+def make_socket(server_options, file):
refused_count = 0
no_server_count = 0
while 1:
try:
- s = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
- s.connect(filename)
+ s = socket.socket(socket.AF_UNIX,socket.SOCK_STREAM)
+ s.connect(file)
except socket.error,e:
if e[0] == errno.EAGAIN:
# baaah
pass
- elif e[0] == errno.ENOENT or not os.path.exists(filename):
- # We need to check os.path.exists for use on operating
- # systems that never return ENOENT; linux 2.2.
+ elif e[0] == errno.ENOENT or not os.path.exists(file):
+ # We need to check os.path.exists for use on operating systems that
+ # never return ENOENT; linux 2.2.
#
# no such file.... no such server. create one.
no_server_count += 1
- if no_server_count > 4:
+ if no_server_count>4:
raise
- # Reset refused count to start the sleep process over.
- # Otherwise we run the risk of waiting a *really* long time
- # and/or hitting the refused_count limit.
- refused_count = 0
fork_server(server_options)
elif e[0] == errno.ECONNREFUSED:
# socket file exists but noone listening.
refused_count += 1
- if refused_count == 4:
+ if refused_count == 6:
# We have been waiting ages and still havent been able
# to connect. Maybe that socket file has got
# orphaned. remove it, wait, and try again. We need to
# allow enough time for sb_bnserver to initialise the
# rest of spambayes
try:
- os.unlink(filename)
+ os.unlink(file)
except EnvironmentError:
pass
- elif refused_count > 6:
+ elif refused_count>6:
raise
else:
raise # some other problem
@@ -216,9 +212,9 @@
os.setsid()
# Use exec rather than import here because eventually it may be nice to
# reimplement this one file in C
- os.execv(sys.executable, [sys.executable,
- os.path.join(os.path.split(sys.argv[0])[0],
- 'sb_bnserver.py') ]+options)
+ os.execv(sys.executable,[sys.executable,
+ os.path.join(os.path.split(sys.argv[0])[0],
+ 'sb_bnserver.py') ]+options)
# should never get here
sys._exit(1)
Modified: trunk/spambayes/scripts/sb_bnserver.py
===================================================================
--- trunk/spambayes/scripts/sb_bnserver.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/scripts/sb_bnserver.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -27,7 +27,7 @@
unix domain socket used on which we listen
"""
-import os, getopt, sys, SocketServer, traceback, select, socket, errno
+import os, getopt, sys, SocketServer, time, traceback, select, socket, errno
try:
True, False
@@ -63,7 +63,7 @@
try:
server = BNServer(args[0], BNRequest)
except socket.error,e:
- if e[0] == errno.EADDRINUSE:
+ if e[0]==errno.EADDRINUSE:
pass # in use, no need
else:
raise # a real error
@@ -108,7 +108,7 @@
pass
def get_request(self):
- r, w, e = select.select([self.socket], [], [], self.timeout)
+ r,w,e = select.select([self.socket], [], [], self.timeout)
if r:
return self.socket.accept()
else:
@@ -119,16 +119,15 @@
switches = self.rfile.readline()
body = self.rfile.read()
try:
- response = self._calc_response(switches, body)
+ response = self._calc_response(switches,body)
self.wfile.write('0\n%d\n'%(len(response),))
self.wfile.write(response)
except:
- response = traceback.format_exception_only(sys.exc_info()[0],
- sys.exc_info()[1])[0]
+ response = traceback.format_exception_only(sys.exc_info()[0],sys.exc_info()[1])[0]
self.wfile.write('1\n%d\n'%(len(response),))
self.wfile.write(response)
- def _calc_response(self, switches, body):
+ def _calc_response(self,switches,body):
switches = switches.split()
actions = []
opts, args = getopt.getopt(switches, 'fgstGS')
Modified: trunk/spambayes/scripts/sb_client.py
===================================================================
--- trunk/spambayes/scripts/sb_client.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/scripts/sb_client.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -10,7 +10,7 @@
import xmlrpclib
import sys
-RPCBASE = "http://localhost:65000"
+RPCBASE="http://localhost:65000"
def main():
msg = sys.stdin.read()
Modified: trunk/spambayes/scripts/sb_dbexpimp.py
===================================================================
--- trunk/spambayes/scripts/sb_dbexpimp.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/scripts/sb_dbexpimp.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -101,7 +101,8 @@
import spambayes.storage
from spambayes.Options import options
-import sys, os, getopt, errno
+import sys, os, getopt, errno, re
+import urllib
from types import UnicodeType
def uquote(s):
@@ -136,8 +137,8 @@
writer = csv.writer(fp)
- nham = bayes.nham
- nspam = bayes.nspam
+ nham = bayes.nham;
+ nspam = bayes.nspam;
print "Exporting database %s to file %s" % (dbFN, outFN)
print "Database has %s ham, %s spam, and %s words" \
@@ -214,7 +215,7 @@
try:
opts, args = getopt.getopt(sys.argv[1:], 'iehmvd:p:f:o:')
except getopt.error, msg:
- print >> sys.stderr, str(msg) + '\n\n' + __doc__
+ print >>sys.stderr, str(msg) + '\n\n' + __doc__
sys.exit()
useDBM = "pickle"
@@ -226,7 +227,7 @@
for opt, arg in opts:
if opt == '-h':
- print >> sys.stderr, __doc__
+ print >>sys.stderr, __doc__
sys.exit()
elif opt == '-f':
flatFN = arg
@@ -246,4 +247,4 @@
if imp:
runImport(dbFN, useDBM, newDBM, flatFN)
else:
- print >> sys.stderr, __doc__
+ print >>sys.stderr, __doc__
Modified: trunk/spambayes/scripts/sb_imapfilter.py
===================================================================
--- trunk/spambayes/scripts/sb_imapfilter.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/scripts/sb_imapfilter.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -110,7 +110,7 @@
else:
temp_dir = win32api.GetTempPath()
status = "Log file opened in " + temp_dir
- for i in range(3, 0, -1):
+ for i in range(3,0,-1):
try:
os.unlink(os.path.join(temp_dir, "SpamBayesIMAP%d.log" % (i+1)))
except os.error:
@@ -132,15 +132,20 @@
import getopt
import types
import thread
+import traceback
import email
import email.Parser
from getpass import getpass
from email.Utils import parsedate
+try:
+ import cStringIO as StringIO
+except ImportError:
+ import StringIO
from spambayes import Stats
from spambayes import message
-from spambayes.Options import options, optionsPathname
-from spambayes import storage, Dibbler
+from spambayes.Options import options, get_pathname_option, optionsPathname
+from spambayes import tokenizer, storage, Dibbler
from spambayes.UserInterface import UserInterfaceServer
from spambayes.ImapUI import IMAPUserInterface, LoginFailure
@@ -172,6 +177,7 @@
timeout = 60 # seconds
def __init__(self, server, debug=0, do_expunge = options["imap", "expunge"] ):
+
if server.find(':') > -1:
server, port = server.split(':', 1)
port = int(port)
@@ -488,7 +494,7 @@
class IMAPMessage(message.SBHeaderMessage):
def __init__(self):
- message.SBHeaderMessage.__init__(self)
+ message.Message.__init__(self)
self.folder = None
self.previous_folder = None
self.rfc822_command = "(BODY.PEEK[])"
@@ -542,7 +548,7 @@
# Can't select the folder, so getting the substance will not
# work.
self.could_not_retrieve = True
- print >> sys.stderr, "Could not select folder %s for message " \
+ print >>sys.stderr, "Could not select folder %s for message " \
"%s (uid %s)" % (self.folder.name, self.id, self.uid)
return self
@@ -565,7 +571,7 @@
# characters for classification. For now, we just carry on,
# warning the user and ignoring the message.
self.could_not_retrieve = True
- print >> sys.stderr, "MemoryError with message %s (uid %s)" % \
+ print >>sys.stderr, "MemoryError with message %s (uid %s)" % \
(self.id, self.uid)
return self
@@ -608,7 +614,7 @@
self.got_substance = True
# Print the exception and a traceback.
- print >> sys.stderr, details
+ print >>sys.stderr, details
return self
@@ -654,7 +660,7 @@
We can't actually update the message with IMAP, so what we do is
create a new message and delete the old one."""
- assert self.folder is not None, \
+ assert self.folder is not None,\
"Can't save a message that doesn't have a folder."
assert self.id, "Can't save a message that doesn't have an id."
assert self.imap_server, "Can't do anything without IMAP connection."
@@ -727,8 +733,7 @@
data = self.imap_server.check_response("recent", response)
if data[0] is not None:
if options["globals", "verbose"]:
- print "[imapfilter] found saved message", self.uid,
- print "in iteration", i
+ print "[imapfilter] found saved message %s in iteration" % self.uid, i
break
else:
if options["globals", "verbose"]:
@@ -958,7 +963,7 @@
cls = msg.GetClassification()
if cls is None or hamfolder is not None:
if options["globals", "verbose"]:
- print "[imapfilter] classified as %s:" % cls, msg.uid
+ print "[imapfilter] classified as %s:"%cls, msg.uid
msg = msg.get_full_message()
if msg.could_not_retrieve:
@@ -1135,13 +1140,13 @@
for u in usernames:
pwds.append(getpass("Enter password for %s:" % (u,)))
- return zip(servers, usernames, pwds)
+ return zip(servers,usernames,pwds)
def run(force_UI=False):
try:
opts, args = getopt.getopt(sys.argv[1:], 'hbPtcvl:e:i:d:p:o:')
except getopt.error, msg:
- print >> sys.stderr, str(msg) + '\n\n' + __doc__
+ print >>sys.stderr, str(msg) + '\n\n' + __doc__
sys.exit()
doTrain = False
@@ -1154,7 +1159,7 @@
for opt, arg in opts:
if opt == '-h':
- print >> sys.stderr, __doc__
+ print >>sys.stderr, __doc__
sys.exit()
elif opt == "-b":
launchUI = True
@@ -1243,7 +1248,7 @@
IMAPSession, stats=stats,
close_db=close_db,
change_db=change_db))
- launchBrowser = launchUI or options["html_ui", "launch_browser"]
+ launchBrowser=launchUI or options["html_ui", "launch_browser"]
if sleepTime:
# Run in a separate thread, as we have more work to do.
thread.start_new_thread(Dibbler.run, (),
Modified: trunk/spambayes/scripts/sb_mailsort.py
===================================================================
--- trunk/spambayes/scripts/sb_mailsort.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/scripts/sb_mailsort.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -25,7 +25,7 @@
import time
import signal
import socket
-import errno
+import email
DB_FILE = os.path.expanduser(DB_FILE)
@@ -65,7 +65,7 @@
try:
fd = os.open(pathname, os.O_WRONLY|os.O_CREAT|os.O_EXCL, 0600)
except IOError, exc:
- if exc[0] not in (errno.EINT, errno.EEXIST):
+ if exc[i] not in (errno.EINT, errno.EEXIST):
raise
else:
break
@@ -142,7 +142,7 @@
prob, evidence = bayes.spamprob(tokenize(msg), evidence=True)
print msg_name, prob
for word, prob in evidence:
- print ' ', repr(word), prob
+ print ' ', `word`, prob
def main():
global DB_FILE, CONFIG_FILE
Modified: trunk/spambayes/scripts/sb_mboxtrain.py
===================================================================
--- trunk/spambayes/scripts/sb_mboxtrain.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/scripts/sb_mboxtrain.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -111,8 +111,7 @@
def maildir_train(h, path, is_spam, force, removetrained):
"""Train bayes with all messages from a maildir."""
- if loud:
- print " Reading %s as Maildir" % (path,)
+ if loud: print " Reading %s as Maildir" % (path,)
import time
import socket
@@ -163,8 +162,7 @@
def mbox_train(h, path, is_spam, force):
"""Train bayes with a Unix mbox"""
- if loud:
- print " Reading as Unix mbox"
+ if loud: print " Reading as Unix mbox"
import mailbox
import fcntl
@@ -221,8 +219,7 @@
def mhdir_train(h, path, is_spam, force):
"""Train bayes with an mh directory"""
- if loud:
- print " Reading as MH mailbox"
+ if loud: print " Reading as MH mailbox"
import glob
@@ -334,15 +331,13 @@
h = hammie.open(pck, usedb, "c")
for g in good:
- if loud:
- print "Training ham (%s):" % g
+ if loud: print "Training ham (%s):" % g
train(h, g, False, force, trainnew, removetrained)
sys.stdout.flush()
save = True
for s in spam:
- if loud:
- print "Training spam (%s):" % s
+ if loud: print "Training spam (%s):" % s
train(h, s, True, force, trainnew, removetrained)
sys.stdout.flush()
save = True
Modified: trunk/spambayes/scripts/sb_notesfilter.py
===================================================================
--- trunk/spambayes/scripts/sb_notesfilter.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/scripts/sb_notesfilter.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -144,15 +144,14 @@
return not not val
import sys
+from spambayes import tokenizer, storage
+from spambayes.Options import options
+import cPickle as pickle
import errno
-import getopt
-
import win32com.client
import pywintypes
+import getopt
-from spambayes import tokenizer, storage
-from spambayes.Options import options
-from spambayes.safepickle import pickle_read, pickle_write
def classifyInbox(v, vmoveto, bayes, ldbname, notesindex, log):
@@ -188,18 +187,20 @@
# probably due to this unicode problem.
options["Tokenizer", "generate_long_skips"] = False
tokens = tokenizer.tokenize(message)
- prob = bayes.spamprob(tokens)
+ prob, clues = bayes.spamprob(tokens, evidence=True)
if prob < options["Categorization", "ham_cutoff"]:
+ disposition = options["Headers", "header_ham_string"]
numham += 1
elif prob > options["Categorization", "spam_cutoff"]:
+ disposition = options["Headers", "header_spam_string"]
docstomove += [doc]
numspam += 1
else:
+ disposition = options["Headers", "header_unsure_string"]
numuns += 1
notesindex[nid] = 'classified'
- subj = message["subject"]
try:
print "%s spamprob is %s" % (subj[:30], prob)
if log:
@@ -304,13 +305,16 @@
bayes = storage.open_storage(bdbname, useDBM)
try:
- notesindex = pickle_read(idxname)
+ fp = open(idxname, 'rb')
except IOError, e:
if e.errno != errno.ENOENT:
raise
notesindex = {}
print "%s file not found, this is a first time run" % (idxname,)
print "No classification will be performed"
+ else:
+ notesindex = pickle.load(fp)
+ fp.close()
need_replicate = False
@@ -374,7 +378,9 @@
bayes.store()
- pickle_write(idxname, notesindex)
+ fp = open(idxname, 'wb')
+ pickle.dump(notesindex, fp)
+ fp.close()
if log:
log.LogAction("Finished running spambayes")
@@ -384,7 +390,7 @@
try:
opts, args = getopt.getopt(sys.argv[1:], 'htcPd:p:l:r:f:o:i:W:L:')
except getopt.error, msg:
- print >> sys.stderr, str(msg) + '\n\n' + __doc__
+ print >>sys.stderr, str(msg) + '\n\n' + __doc__
sys.exit()
ldbname = None # local notes database name
@@ -399,7 +405,7 @@
for opt, arg in opts:
if opt == '-h':
- print >> sys.stderr, __doc__
+ print >>sys.stderr, __doc__
sys.exit()
elif opt == '-l':
ldbname = arg
@@ -431,6 +437,9 @@
sbfname, doTrain, doClassify, pwd, idxname, logname)
if doPrompt:
- raw_input("Press Enter to end ")
+ try:
+ key = input("Press Enter to end")
+ except SyntaxError:
+ pass
else:
- print >> sys.stderr, __doc__
+ print >>sys.stderr, __doc__
Modified: trunk/spambayes/scripts/sb_pop3dnd.py
===================================================================
--- trunk/spambayes/scripts/sb_pop3dnd.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/scripts/sb_pop3dnd.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -67,11 +67,13 @@
import md5
import time
import errno
+import types
import email
import thread
import getopt
import socket
import imaplib
+import operator
import email.Utils
try:
@@ -83,12 +85,14 @@
import twisted.application.app
from twisted.internet import defer
from twisted.internet import reactor
+from twisted.internet.defer import maybeDeferred
from twisted.internet.protocol import ServerFactory
from twisted.protocols.imap4 import IMessage
-from twisted.protocols.imap4 import IAccount
-from twisted.protocols.imap4 import MessageSet
+from twisted.protocols.imap4 import parseNestedParens, parseIdList
+from twisted.protocols.imap4 import IllegalClientResponse, IAccount
+from twisted.protocols.imap4 import collapseNestedLists, MessageSet
from twisted.protocols.imap4 import IMAP4Server, MemoryAccount, IMailbox
-from twisted.protocols.imap4 import IMailboxListener
+from twisted.protocols.imap4 import IMailboxListener, collapseNestedLists
from spambayes import storage
from spambayes import message
@@ -97,7 +101,7 @@
from spambayes.tokenizer import tokenize
from spambayes import FileCorpus, Dibbler
from spambayes.Version import get_current_version
-from sb_server import POP3ProxyBase, State, _addressPortStr
+from sb_server import POP3ProxyBase, State, _addressPortStr, _recreateState
def ensureDir(dirname):
"""Ensure that the given directory exists - in other words, if it
@@ -534,7 +538,7 @@
class SpambayesInbox(SpambayesMailbox):
"""A special mailbox that holds status messages from SpamBayes."""
def __init__(self, id, state):
- SpambayesMailbox.__init__(self, "INBOX", "spambayes", id)
+ IMAPMailbox.__init__(self, "INBOX", "spambayes", id)
self.mdb = state.mdb
self.UID_validity = id
self.nextUID = 1
@@ -822,8 +826,8 @@
msg = email.message_from_string(messageText,
_class=message.SBHeaderMessage)
# Now find the spam disposition and add the header.
- (prob, clues) = state.bayes.spamprob(msg.tokenize(),
- evidence=True)
+ (prob, clues) = state.bayes.spamprob(msg.tokenize(),\
+ evidence=True)
# Note that the X-SpamBayes-MailID header will be worthless
# because we don't know the message id at this point. It's
@@ -866,7 +870,7 @@
message.insert_exception_header(messageText)
# Print the exception and a traceback.
- print >> sys.stderr, details
+ print >>sys.stderr, details
retval = ok + "\n" + messageText
if terminatingDotPresent:
retval += '.\r\n'
@@ -1005,12 +1009,12 @@
try:
opts, args = getopt.getopt(sys.argv[1:], 'ho:')
except getopt.error, msg:
- print >> sys.stderr, str(msg) + '\n\n' + __doc__
+ print >>sys.stderr, str(msg) + '\n\n' + __doc__
sys.exit()
for opt, arg in opts:
if opt == '-h':
- print >> sys.stderr, __doc__
+ print >>sys.stderr, __doc__
sys.exit()
elif opt == '-o':
options.set_from_cmdline(arg, sys.stderr)
Modified: trunk/spambayes/scripts/sb_server.py
===================================================================
--- trunk/spambayes/scripts/sb_server.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/scripts/sb_server.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -102,15 +102,16 @@
o NNTP proxy.
"""
-import sys, re, getopt, time, socket, email
+import os, sys, re, errno, getopt, time, traceback, socket, cStringIO, email
from thread import start_new_thread
+from email.Header import Header
import spambayes.message
from spambayes import i18n
from spambayes import Stats
from spambayes import Dibbler
from spambayes import storage
-from spambayes.FileCorpus import ExpiryFileCorpus
+from spambayes.FileCorpus import FileCorpus, ExpiryFileCorpus
from spambayes.FileCorpus import FileMessageFactory, GzipFileMessageFactory
from spambayes.Options import options, get_pathname_option, _
from spambayes.UserInterface import UserInterfaceServer
@@ -190,7 +191,7 @@
except socket.sslerror, why:
if why[0] == 1: # error:140770FC:SSL routines:SSL23_GET_SERVER_HELLO:unknown protocol'
# Probably not SSL after all.
- print >> sys.stderr, "Can't use SSL"
+ print >>sys.stderr, "Can't use SSL"
else:
raise
else:
@@ -366,7 +367,8 @@
raise SystemExit
elif verb == 'CRASH':
# For testing
- raise ZeroDivisionError
+ x = 0
+ y = 1/x
self.serverSocket.push(self.request + '\r\n')
if self.request.strip() == '':
@@ -566,8 +568,8 @@
_class=spambayes.message.SBHeaderMessage)
msg.setId(state.getNewMessageName())
# Now find the spam disposition and add the header.
- (prob, clues) = state.bayes.spamprob(msg.tokenize(),
- evidence=True)
+ (prob, clues) = state.bayes.spamprob(msg.tokenize(),\
+ evidence=True)
msg.addSBHeaders(prob, clues)
@@ -630,7 +632,7 @@
insert_exception_header(messageText)
# Print the exception and a traceback.
- print >> sys.stderr, details
+ print >>sys.stderr, details
# Restore the +OK and the POP3 .\r\n terminator if there was one.
retval = ok + "\n" + messageText
@@ -834,6 +836,7 @@
nham = self.bayes.nham
if nspam > 10 and nham > 10:
db_ratio = nham/float(nspam)
+ big = small = None
if db_ratio > 5.0:
self.warning = _("Warning: you have much more ham than " \
"spam - SpamBayes works best with " \
@@ -985,6 +988,8 @@
proxyListeners.append(listener)
def _recreateState():
+ global state
+
# Close the existing listeners and create new ones. This won't
# affect any running proxies - once a listener has created a proxy,
# that proxy is then independent of it.
@@ -1052,12 +1057,13 @@
try:
opts, args = getopt.getopt(sys.argv[1:], 'hbd:p:l:u:o:')
except getopt.error, msg:
- print >> sys.stderr, str(msg) + '\n\n' + __doc__
+ print >>sys.stderr, str(msg) + '\n\n' + __doc__
sys.exit()
+ runSelfTest = False
for opt, arg in opts:
if opt == '-h':
- print >> sys.stderr, __doc__
+ print >>sys.stderr, __doc__
sys.exit()
elif opt == '-b':
state.launchUI = True
@@ -1090,14 +1096,14 @@
try:
prepare()
except AlreadyRunningException:
- print >> sys.stderr, \
+ print >>sys.stderr, \
"ERROR: The proxy is already running on this machine."
- print >> sys.stderr, "Please stop the existing proxy and try again"
+ print >>sys.stderr, "Please stop the existing proxy and try again"
return
start()
else:
- print >> sys.stderr, __doc__
+ print >>sys.stderr, __doc__
if __name__ == '__main__':
run()
Modified: trunk/spambayes/scripts/sb_upload.py
===================================================================
--- trunk/spambayes/scripts/sb_upload.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/scripts/sb_upload.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -58,7 +58,7 @@
h.putheader('content-length', str(len(body)))
h.endheaders()
h.send(body)
- h.getreply()
+ errcode, errmsg, headers = h.getreply()
return h.file.read()
def encode_multipart_formdata(fields, files):
@@ -153,7 +153,7 @@
("text", "")],
[("file", "message.dat", data)])
else:
- post_multipart("%s:%d" % (server, port), "/upload", [],
+ post_multipart("%s:%d" % (server,port), "/upload", [],
[('file', 'message.dat', data)])
except:
# not an error if the server isn't responding
Modified: trunk/spambayes/scripts/sb_xmlrpcserver.py
===================================================================
--- trunk/spambayes/scripts/sb_xmlrpcserver.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/scripts/sb_xmlrpcserver.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -22,8 +22,10 @@
Port number to listen to.
"""
+import os
import getopt
import sys
+import traceback
import xmlrpclib
import SimpleXMLRPCServer
Modified: trunk/spambayes/setup.py
===================================================================
--- trunk/spambayes/setup.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/setup.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -1,10 +1,8 @@
#!/usr/bin/env python
import os
-import sys
-from setuptools import setup, find_packages
-
+import sys
if sys.version < '2.2':
print "Error: Python version too old. You need at least Python 2.2 to use this package."
print "(you're running version %s)"%sys.version
@@ -123,9 +121,6 @@
author = "the spambayes project",
author_email = "spambayes at python.org",
url = "http://spambayes.sourceforge.net",
- install_requires = ["lockfile>=0.2",
- "pydns>=2.0"],
-## packages=find_packages("spambayes"),
cmdclass = {'install_scripts': install_scripts,
'sdist': sdist,
},
Modified: trunk/spambayes/spambayes/ImapUI.py
===================================================================
--- trunk/spambayes/spambayes/ImapUI.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/spambayes/ImapUI.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -43,7 +43,7 @@
import cgi
-from spambayes import UserInterface
+import UserInterface
from spambayes.Options import options, optionsPathname, _
# These are the options that will be offered on the configuration page.
Modified: trunk/spambayes/spambayes/Options.py
===================================================================
--- trunk/spambayes/spambayes/Options.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/spambayes/Options.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -33,7 +33,7 @@
__all__ = ['options', '_']
# Grab the stuff from the core options class.
-from spambayes.OptionsClass import *
+from OptionsClass import *
# A little magic. We'd like to use ZODB as the default storage,
# because we've had so many problems with bsddb, and we'd like to swap
@@ -199,12 +199,6 @@
reasons if your corpora are from different sources."""),
BOOLEAN, RESTORE),
- ("x-mine_nntp_headers", _("Mine NNTP-Posting-Host headers"), False,
- _("""Usenet is host to a lot of spam. Usenet/Mailing list gateways
- can let it leak across. Similar to mining received headers, we pick
- apart the IP address or host name in this header for clues."""),
- BOOLEAN, RESTORE),
-
("address_headers", _("Address headers to mine"), ("from", "to", "cc",
"sender", "reply-to"),
_("""Mine the following address headers. If you have mixed source
@@ -609,8 +603,8 @@
("persistent_use_database", _("Database backend"), DB_TYPE[0],
_("""SpamBayes can use either a ZODB or dbm database (quick to score
one message) or a pickle (quick to train on huge amounts of messages).
- There is also (experimental) ability to use a mySQL or PostgresSQL
- database."""),
+ There is also (currently experimental) the ability to use a mySQL or
+ PostgrepSQL database."""),
("zeo", "zodb", "cdb", "mysql", "pgsql", "dbm", "pickle"), RESTORE),
("persistent_storage_file", _("Storage file name"), DB_TYPE[1],
@@ -1366,7 +1360,7 @@
# in the current directory, and no win32 extensions installed
# to locate the "user" directory - seeing things are so lamely
# setup, it is worth printing a warning
- print >> sys.stderr, "NOTE: We can not locate an INI file " \
+ print >>sys.stderr, "NOTE: We can not locate an INI file " \
"for SpamBayes, and the Python for Windows extensions " \
"are not installed, meaning we can't locate your " \
"'user' directory. An empty configuration file at " \
Modified: trunk/spambayes/spambayes/Version.py
===================================================================
--- trunk/spambayes/spambayes/Version.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/spambayes/Version.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -10,8 +10,8 @@
will generate the "ConfigParser" version for the web.
"""
-import sys
-import re
+import string, re
+from types import StringType
try:
_
@@ -22,8 +22,8 @@
# A reason for why the spambayes.org URL fails is given in a comment there.
#LATEST_VERSION_HOME="http://www.spambayes.org/download/Version.cfg"
# The SF URL instead works for Tim and xenogeist.
-LATEST_VERSION_HOME = "http://spambayes.sourceforge.net/download/Version.cfg"
-DEFAULT_DOWNLOAD_PAGE = "http://spambayes.sourceforge.net/windows.html"
+LATEST_VERSION_HOME="http://spambayes.sourceforge.net/download/Version.cfg"
+DEFAULT_DOWNLOAD_PAGE="http://spambayes.sourceforge.net/windows.html"
# This module is part of the spambayes project, which is Copyright 2002-2007
# The Python Software Foundation and is covered by the Python Software
@@ -66,7 +66,7 @@
# and massage it into a string format that will compare properly
# in update checks.
try:
- float(version)
+ ver_num = float(version)
# Version converted successfully to a float, which means it
# may be an old-format version number. Old convention was to
# use 1.01 to represent "1.0.1", so check to see if there is
@@ -86,8 +86,7 @@
def get_download_page(app = None,
version_dict = None):
- if version_dict is None:
- version_dict = versions
+ if version_dict is None: version_dict = versions
dict = version_dict # default to top level dictionary
if app is not None:
# attempt to get a sub-dict for the specific app
@@ -186,21 +185,21 @@
releaselevel = "final"
serial = 0
else:
- serial = int(prerelease_num)
+ serial = string.atoi(prerelease_num)
if prerelease == "a":
releaselevel = "alpha"
elif prerelease == "b":
releaselevel = "beta"
elif prerelease == "rc":
releaselevel = "candidate"
- self.version_info = tuple(map(int, [major, minor, patch]) + \
+ self.version_info = tuple(map(string.atoi, [major, minor, patch]) + \
[releaselevel, serial])
def __str__(self):
if self.version_info[2] == 0:
- vstring = '.'.join(map(str, self.version_info[0:2]))
+ vstring = string.join(map(str, self.version_info[0:2]), '.')
else:
- vstring = '.'.join(map(str, self.version_info[0:3]))
+ vstring = string.join(map(str, self.version_info[0:3]), '.')
releaselevel = self.version_info[3][0]
if releaselevel != 'f':
@@ -215,14 +214,13 @@
return vstring
def __cmp__(self, other):
- if isinstance(other, str):
+ if isinstance(other, StringType):
other = SBVersion(other)
return cmp(self.version_info, other.version_info)
def get_long_version(self, app_name = None):
- if app_name is None:
- app_name = "SpamBayes"
+ if app_name is None: app_name = "SpamBayes"
return _("%s Version %s (%s)") % (app_name, str(self), self.date)
#============================================================================
@@ -270,7 +268,7 @@
ret_dict = {}
apps_dict = ret_dict["Apps"] = {}
for sect in cfg.sections():
- if sect == "SpamBayes":
+ if sect=="SpamBayes":
target_dict = ret_dict
else:
target_dict = apps_dict.setdefault(sect, {})
@@ -350,6 +348,7 @@
_make_compatible_cfg_section(stream, appname, ver, versions["Apps"][appname])
def main(args):
+ import sys
if '-g' in args:
make_cfg(sys.stdout)
sys.exit(0)
@@ -371,5 +370,6 @@
print
print "Latest version:", v_latest.get_long_version()
-if __name__ == '__main__':
+if __name__=='__main__':
+ import sys
main(sys.argv)
Modified: trunk/spambayes/spambayes/__init__.py
===================================================================
--- trunk/spambayes/spambayes/__init__.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/spambayes/__init__.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -1,4 +1,4 @@
# package marker.
-__version__ = "1.1b1"
-__date__ = "November 23, 2008"
+__version__ = "1.1a4"
+__date__ = "June 25, 2007"
Modified: trunk/spambayes/spambayes/chi2.py
===================================================================
--- trunk/spambayes/spambayes/chi2.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/spambayes/chi2.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -1,5 +1,4 @@
import math as _math
-import random
try:
True, False
@@ -107,7 +106,7 @@
def __init__(self, baserandom=random.random, tabsize=513):
self.baserandom = baserandom
self.n = tabsize
- self.tab = [baserandom() for _i in range(tabsize)]
+ self.tab = [baserandom() for i in range(tabsize)]
self.next = baserandom()
def random(self):
@@ -151,8 +150,8 @@
s = Hist(20, lo=0.0, hi=1.0)
score = Hist(20, lo=0.0, hi=1.0)
- for _i in xrange(5000):
- ps = [random() for _j in xrange(50)]
+ for i in range(5000):
+ ps = [random() for j in range(50)]
s1, h1, score1 = judge(ps + [bias] * warp)
s.add(s1)
h.add(h1)
@@ -204,4 +203,5 @@
print "(S-H+1)/2", score
if __name__ == '__main__':
+ import random
main()
Modified: trunk/spambayes/spambayes/optimize.py
===================================================================
--- trunk/spambayes/spambayes/optimize.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/spambayes/optimize.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -4,8 +4,6 @@
# Optimize any parametric function.
#
import copy
-
-# XXX Numeric is obsolete. Replace with numpy.
import Numeric
def SimplexMaximize(var, err, func, convcrit = 0.001, minerr = 0.001):
@@ -32,7 +30,7 @@
if abs(value[bi] - value[wi]) <= convcrit:
return simplex[bi]
# Calculate average of non-worst
- ave = Numeric.zeros(len(var), 'd')
+ ave=Numeric.zeros(len(var), 'd')
for i in range(len(simplex)):
if i != wi:
ave = ave + simplex[i]
Modified: trunk/spambayes/spambayes/storage.py
===================================================================
--- trunk/spambayes/spambayes/storage.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/spambayes/storage.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -50,8 +50,8 @@
### situations prints to sys.stdout will garble the message (e.g., in
### hammiefilter).
-__author__ = ("Neale Pickett <neale at woozle.org>,"
- "Tim Stone <tim at fourstonesExpressions.com>")
+__author__ = "Neale Pickett <neale at woozle.org>, \
+Tim Stone <tim at fourstonesExpressions.com>"
__credits__ = "All the spambayes contributors."
try:
@@ -69,11 +69,11 @@
import tempfile
from spambayes import classifier
from spambayes.Options import options, get_pathname_option
+import cPickle as pickle
import errno
import shelve
from spambayes import cdb
from spambayes import dbmstorage
-from spambayes.safepickle import pickle_write
# Make shelve use binary pickles by default.
oldShelvePickler = shelve.Pickler
@@ -85,6 +85,36 @@
NO_UPDATEPROBS = False # Probabilities will not be autoupdated with training
UPDATEPROBS = True # Probabilities will be autoupdated with training
+def safe_pickle(filename, value, protocol=0):
+ '''Store value as a pickle without creating corruption'''
+
+ # Be as defensive as possible. Always keep a safe copy.
+ tmp = filename + '.tmp'
+ fp = None
+ try:
+ fp = open(tmp, 'wb')
+ pickle.dump(value, fp, protocol)
+ fp.close()
+ except IOError, e:
+ if options["globals", "verbose"]:
+ print >> sys.stderr, 'Failed update: ' + str(e)
+ if fp is not None:
+ os.remove(tmp)
+ raise
+ try:
+ # With *nix we can just rename, and (as long as permissions
+ # are correct) the old file will vanish. With win32, this
+ # won't work - the Python help says that there may not be
+ # a way to do an atomic replace, so we rename the old one,
+ # put the new one there, and then delete the old one. If
+ # something goes wrong, there is at least a copy of the old
+ # one.
+ os.rename(tmp, filename)
+ except OSError:
+ os.rename(filename, filename + '.bak')
+ os.rename(tmp, filename)
+ os.remove(filename + '.bak')
+
class PickledClassifier(classifier.Classifier):
'''Classifier object persisted in a pickle'''
@@ -106,12 +136,16 @@
# tempbayes object is reclaimed when load() returns.
if options["globals", "verbose"]:
- print >> sys.stderr, 'Loading state from', self.db_name, 'pickle'
+ print >> sys.stderr, 'Loading state from',self.db_name,'pickle'
+ tempbayes = None
try:
- tempbayes = pickle_read(self.db_name)
- except:
- tempbayes = None
+ fp = open(self.db_name, 'rb')
+ except IOError, e:
+ if e.errno != errno.ENOENT: raise
+ else:
+ tempbayes = pickle.load(fp)
+ fp.close()
if tempbayes:
# Copy state from tempbayes. The use of our base-class
@@ -135,9 +169,9 @@
'''Store self as a pickle'''
if options["globals", "verbose"]:
- print >> sys.stderr, 'Persisting', self.db_name, 'as a pickle'
+ print >> sys.stderr, 'Persisting',self.db_name,'as a pickle'
- pickle_write(self.db_name, self, PICKLE_TYPE)
+ safe_pickle(self.db_name, self, PICKLE_TYPE)
def close(self):
# we keep no resources open - nothing to do
@@ -164,8 +198,7 @@
def close(self):
# Close our underlying database. Better not assume all databases
# have close functions!
- def noop():
- pass
+ def noop(): pass
getattr(self.db, "close", noop)()
getattr(self.dbm, "close", noop)()
# should not be a need to drop the 'dbm' or 'db' attributes.
@@ -177,13 +210,13 @@
if hasattr(self, "dbm"):
del self.dbm
if options["globals", "verbose"]:
- print >> sys.stderr, 'Closed', self.db_name, 'database'
+ print >> sys.stderr, 'Closed',self.db_name,'database'
def load(self):
'''Load state from database'''
if options["globals", "verbose"]:
- print >> sys.stderr, 'Loading state from', self.db_name, 'database'
+ print >> sys.stderr, 'Loading state from',self.db_name,'database'
self.dbm = dbmstorage.open(self.db_name, self.mode)
self.db = shelve.Shelf(self.dbm)
@@ -211,8 +244,7 @@
'''Place state into persistent store'''
if options["globals", "verbose"]:
- print >> sys.stderr, 'Persisting', self.db_name,
- print >> sys.stderr, 'state in database'
+ print >> sys.stderr, 'Persisting',self.db_name,'state in database'
# Iterate over our changed word list.
# This is *not* thread-safe - another thread changing our
@@ -439,7 +471,7 @@
def fetchall(self, c):
return c.dictfetchall()
- def commit(self, _c):
+ def commit(self, c):
self.db.commit()
def load(self):
@@ -448,7 +480,7 @@
import psycopg
if options["globals", "verbose"]:
- print >> sys.stderr, 'Loading state from', self.db_name, 'database'
+ print >> sys.stderr, 'Loading state from',self.db_name,'database'
self.db = psycopg.connect('dbname=' + self.db_name)
@@ -513,7 +545,7 @@
def fetchall(self, c):
return c.fetchall()
- def commit(self, _c):
+ def commit(self, c):
self.db.commit()
def load(self):
@@ -522,7 +554,7 @@
import MySQLdb
if options["globals", "verbose"]:
- print >> sys.stderr, 'Loading state from', self.db_name, 'database'
+ print >> sys.stderr, 'Loading state from',self.db_name,'database'
params = {
'host': self.host, 'db': self.db_name,
@@ -692,11 +724,12 @@
object.__setattr__(self, att, value)
def create_storage(self):
+ import ZODB
from ZODB.FileStorage import FileStorage
try:
self.storage = FileStorage(self.db_filename,
read_only=self.mode=='r')
- except IOError:
+ except IOError, msg:
print >> sys.stderr, ("Could not create FileStorage from",
self.db_filename)
raise
@@ -735,6 +768,7 @@
def store(self):
'''Place state into persistent store'''
try:
+ import ZODB
import ZODB.Transaction
except ImportError:
import transaction
@@ -937,7 +971,7 @@
'''Untrain the database with the message'''
if options["globals", "verbose"]:
- print >> sys.stderr, 'untraining with', message.key()
+ print >> sys.stderr, 'untraining with',message.key()
self.bayes.unlearn(message.tokenize(), self.is_spam)
# self.updateprobs)
@@ -971,7 +1005,6 @@
class NoSuchClassifierError(Exception):
def __init__(self, invalid_name):
- Exception.__init__(self, invalid_name)
self.invalid_name = invalid_name
def __str__(self):
return repr(self.invalid_name)
@@ -1055,7 +1088,7 @@
try:
unused, unused, is_path = _storage_types[typ]
except KeyError:
- raise NoSuchClassifierError(typ)
+ raise NoSuchClassifierError(db_type)
if is_path:
nm = get_pathname_option(*default_name)
else:
@@ -1109,7 +1142,7 @@
try:
os.mkdir(dirname)
if options["globals", "verbose"]:
- print >> sys.stderr, "Creating directory", dirname
+ print >>sys.stderr, "Creating directory", dirname
except OSError, e:
if e.errno != errno.EEXIST:
raise
Modified: trunk/spambayes/spambayes/tokenizer.py
===================================================================
--- trunk/spambayes/spambayes/tokenizer.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/spambayes/tokenizer.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -14,8 +14,6 @@
import binascii
import urlparse
import urllib
-import socket
-
try:
# We have three possibilities for Set:
# (a) With Python 2.2 and earlier, we use our compatsets class
@@ -41,7 +39,7 @@
try:
- from spambayes import dnscache
+ import dnscache
cache = dnscache.cache(cachefile=options["Tokenizer", "lookup_ip_cache"])
cache.printStatsAtEnd = False
except (IOError, ImportError):
@@ -683,8 +681,6 @@
# by m19.grp.scd.yahoo.com with QMQP; 19 Dec 2003 04:06:53 -0000
received_ip_re = re.compile(r'[[(]((\d{1,3}\.?){4})[])]')
-received_nntp_ip_re = re.compile(r'((\d{1,3}\.?){4})')
-
message_id_re = re.compile(r'\s*<[^@]+@([^>]+)>\s*')
# I'm usually just splitting on whitespace, but for subject lines I want to
@@ -1088,12 +1084,19 @@
scheme, netloc, path, params, query, frag = urlparse.urlparse(url)
if cache is not None and options["Tokenizer", "x-lookup_ip"]:
- ips = cache.lookup(netloc)
+ ips=cache.lookup(netloc)
if not ips:
pushclue("url-ip:lookup error")
else:
- for clue in gen_dotted_quad_clues("url-ip", ips):
- pushclue(clue)
+ for ip in ips: # Should we limit to one A record?
+ pushclue("url-ip:%s/32" % ip)
+ dottedQuadList=ip.split(".")
+ pushclue("url-ip:%s/8" % dottedQuadList[0])
+ pushclue("url-ip:%s.%s/16" % (dottedQuadList[0],
+ dottedQuadList[1]))
+ pushclue("url-ip:%s.%s.%s/24" % (dottedQuadList[0],
+ dottedQuadList[1],
+ dottedQuadList[2]))
# one common technique in bogus "please (re-)authorize yourself"
# scams is to make it appear as if you're visiting a valid
@@ -1523,13 +1526,6 @@
for tok in breakdown(m.group(1)):
yield 'received:' + tok
- # Lots of spam gets posted on Usenet. If it is then gatewayed to a
- # mailing list perhaps the NNTP-Posting-Host info will yield some
- # useful clues.
- if options["Tokenizer", "x-mine_nntp_headers"]:
- for clue in mine_nntp(msg):
- yield clue
-
# Message-Id: This seems to be a small win and should not
# adversely affect a mixed source corpus so it's always enabled.
msgid = msg.get("message-id", "")
@@ -1702,56 +1698,5 @@
for t in self.tokenize_text(text):
yield t
-def mine_nntp(msg):
- nntp_headers = msg.get_all("nntp-posting-host", ())
- yield "has-nntp:%s" % not not nntp_headers
- for header in nntp_headers:
- try:
- address = header.split()[1]
- except IndexError:
- continue
- if received_nntp_ip_re.match(address):
- for clue in gen_dotted_quad_clues("nntp-host", [address]):
- yield clue
- try:
- h = socket.gethostbyaddr(address)
- except socket.herror:
- yield 'nntp-host-ip:has-no-reverse'
- else:
- yield 'nntp-host-ip:has-reverse'
- yield 'nntp-host-name:%s' % h[0]
- yield ('nntp-host-domain:%s' %
- '.'.join(h[0].split('.')[-2:]))
- else:
- # assume it's a hostname
- name = address
- yield 'nntp-host-name:%s' % name
- yield ('nntp-host-domain:%s' %
- '.'.join(name.split('.')[-2:]))
- try:
- address = socket.gethostbyname(name)
- except socket.gaierror:
- yield 'nntp-host-name:invalid'
- else:
- for clue in gen_dotted_quad_clues("nntp-host-ip", [address]):
- yield clue
- try:
- h = socket.gethostbyaddr(address)
- except socket.herror:
- yield 'nntp-host-ip:has-no-reverse'
- else:
- yield 'nntp-host-ip:has-reverse'
-
-def gen_dotted_quad_clues(pfx, ips):
- for ip in ips:
- yield "%s:%s/32" % (pfx, ip)
- dottedQuadList = ip.split(".")
- yield "%s:%s/8" % (pfx, dottedQuadList[0])
- yield "%s:%s.%s/16" % (pfx, dottedQuadList[0],
- dottedQuadList[1])
- yield "%s:%s.%s.%s/24" % (pfx, dottedQuadList[0],
- dottedQuadList[1],
- dottedQuadList[2])
-
global_tokenizer = Tokenizer()
tokenize = global_tokenizer.tokenize
Modified: trunk/spambayes/testtools/es2hs.py
===================================================================
--- trunk/spambayes/testtools/es2hs.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/testtools/es2hs.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -43,6 +43,8 @@
def main():
"""Main program; parse options and go."""
+ global loud
+
everything = None
spam = []
@@ -69,8 +71,7 @@
spamsizes = {}
for s in spam:
- if loud:
- print "Scanning spamdir (%s):" % s
+ if loud: print "Scanning spamdir (%s):" % s
files = os.listdir(s)
for f in files:
if f[0] in ('1', '2', '3', '4', '5', '6', '7', '8', '9'):
@@ -84,8 +85,7 @@
os.makedirs(spamdir)
os.makedirs(hamdir)
- if loud:
- print "Scanning everything"
+ if loud: print "Scanning everything"
for f in os.listdir(everything):
if f[0] in ('1', '2', '3', '4', '5', '6', '7', '8', '9'):
name = os.path.join(everything, f)
Modified: trunk/spambayes/testtools/incremental.py
===================================================================
--- trunk/spambayes/testtools/incremental.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/testtools/incremental.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -30,7 +30,7 @@
from spambayes import msgs
import email
from email import Message
-from testtools import regimes
+import regimes
try:
True, False
@@ -76,10 +76,10 @@
# The number of test instances correctly and incorrectly classified.
self.nham_right = 0
self.nham_wrong = 0
- self.nham_unsure = 0
+ self.nham_unsure = 0;
self.nspam_right = 0
self.nspam_wrong = 0
- self.nspam_unsure = 0
+ self.nspam_unsure = 0;
# Lists of bad predictions.
self.ham_wrong_examples = [] # False positives: ham called spam.
Modified: trunk/spambayes/utilities/HistToGNU.py
===================================================================
--- trunk/spambayes/utilities/HistToGNU.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/utilities/HistToGNU.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -18,13 +18,14 @@
set xrange [0.0:100.0]
"""
-dataSetOptions = "smooth unique"
+dataSetOptions="smooth unique"
+from spambayes.Options import options
+from spambayes.TestDriver import Hist
+
import sys
+import cPickle as pickle
-from spambayes.Options import options
-from spambayes.safepickle import pickle_read, pickle_write
-
program = sys.argv[0]
def usage(code, msg=''):
@@ -37,7 +38,7 @@
def loadHist(path):
"""Load the histogram pickle object"""
- return pickle_read(path)
+ return pickle.load(file(path))
def outputHist(hist, f=sys.stdout):
"""Output the Hist object to file f"""
@@ -48,7 +49,7 @@
def plot(files):
"""given a list of files, create gnu-plot file"""
- import cStringIO
+ import cStringIO, os
cmd = cStringIO.StringIO()
cmd.write(globalOptions)
args = []
Modified: trunk/spambayes/utilities/convert_config_file.py
===================================================================
--- trunk/spambayes/utilities/convert_config_file.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/utilities/convert_config_file.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -45,7 +45,7 @@
try:
opts, args = getopt.getopt(sys.argv[1:], 'vhf:')
except getopt.error, msg:
- print >> sys.stderr, str(msg) + '\n\n' + __doc__
+ print >>sys.stderr, str(msg) + '\n\n' + __doc__
sys.exit()
filename = "bayescustomize.ini"
@@ -53,7 +53,7 @@
for opt, arg in opts:
if opt == '-h':
- print >> sys.stderr, __doc__
+ print >>sys.stderr, __doc__
sys.exit()
elif opt == '-f':
filename = arg
@@ -64,6 +64,7 @@
if verbose:
print "Loading defaults"
o.load_defaults()
+ alts = []
if verbose:
print "Updating file:", filename
if os.path.exists(filename):
Modified: trunk/spambayes/utilities/convert_db.py
===================================================================
--- trunk/spambayes/utilities/convert_db.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/utilities/convert_db.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -41,13 +41,13 @@
try:
opts, args = getopt.getopt(sys.argv[1:], 'ht:T:n:N:')
except getopt.error, msg:
- print >> sys.stderr, str(msg) + '\n\n' + __doc__
+ print >>sys.stderr, str(msg) + '\n\n' + __doc__
sys.exit()
old_name = old_type = new_name = new_type = None
for opt, arg in opts:
if opt == '-h':
- print >> sys.stderr, __doc__
+ print >>sys.stderr, __doc__
sys.exit()
elif opt == '-t':
old_type = arg
Modified: trunk/spambayes/utilities/extractmessages.py
===================================================================
--- trunk/spambayes/utilities/extractmessages.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/utilities/extractmessages.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -23,11 +23,11 @@
import sys
import getopt
import re
+import cPickle as pickle
import locale
from email.Header import make_header, decode_header
from spambayes.mboxutils import getmbox
-from spambayes.safepickle import pickle_read, pickle_write
prog = sys.argv[0]
@@ -115,7 +115,7 @@
return 1
try:
- mapd = pickle_read(mapfile)
+ mapd = pickle.load(file(mapfile))
except IOError:
usage("Mapfile %s does not exist" % mapfile)
return 1
Modified: trunk/spambayes/utilities/hammer.py
===================================================================
--- trunk/spambayes/utilities/hammer.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/utilities/hammer.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -3,7 +3,7 @@
# Part of the SpamBayes project. Released under the Python Software
# Foundation license; see http://www.python.org/
-import os, re, random, textwrap
+import os, sys, re, random, textwrap
from spambayes import storage
from spambayes import tokenizer
Modified: trunk/spambayes/utilities/loosecksum.py
===================================================================
--- trunk/spambayes/utilities/loosecksum.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/utilities/loosecksum.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -26,8 +26,10 @@
import getopt
import sys
+import email.Parser
import md5
import re
+import time
import binascii
from spambayes.mboxutils import getmbox
Modified: trunk/spambayes/utilities/mboxcount.py
===================================================================
--- trunk/spambayes/utilities/mboxcount.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/utilities/mboxcount.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -29,6 +29,7 @@
import sys
import mailbox
+import email
import getopt
import glob
Modified: trunk/spambayes/utilities/mkreversemap.py
===================================================================
--- trunk/spambayes/utilities/mkreversemap.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/utilities/mkreversemap.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -17,12 +17,13 @@
import sys
import getopt
+import anydbm
+import cPickle as pickle
from spambayes.mboxutils import getmbox
from spambayes.tokenizer import tokenize
from spambayes.Options import options
from spambayes.classifier import Classifier
-from spambayes.safepickle import pickle_read, pickle_write
prog = sys.argv[0]
@@ -98,13 +99,13 @@
return 1
try:
- mapd = pickle_read(mapfile)
+ mapd = pickle.load(file(mapfile))
except IOError:
mapd = {}
for f in args:
mapmessages(f, mboxtype, mapd)
- pickle_write(mapfile, mapd)
+ pickle.dump(mapd, file(mapfile, "w"))
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))
Modified: trunk/spambayes/utilities/split.py
===================================================================
--- trunk/spambayes/utilities/split.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/utilities/split.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -28,6 +28,7 @@
import sys
import random
import mailbox
+import email
import getopt
from spambayes import mboxutils
Modified: trunk/spambayes/utilities/splitn.py
===================================================================
--- trunk/spambayes/utilities/splitn.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/utilities/splitn.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -42,6 +42,7 @@
import sys
import random
import mailbox
+import email
import getopt
from spambayes import mboxutils
Modified: trunk/spambayes/utilities/splitndirs.py
===================================================================
--- trunk/spambayes/utilities/splitndirs.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/utilities/splitndirs.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -47,6 +47,8 @@
import sys
import os
import random
+import mailbox
+import email
import getopt
import glob
Modified: trunk/spambayes/windows/autoconfigure.py
===================================================================
--- trunk/spambayes/windows/autoconfigure.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/windows/autoconfigure.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -496,6 +496,7 @@
results = []
for filename in os.listdir(config_location):
if filename.lower().startswith("pop") or filename.lower().startswith("smt"):
+ full_filename = os.path.join(config_location, filename)
working_filename = "%s.tmp" % (filename, )
shutil.copyfile(filename, working_filename)
c = OptionsClass.OptionsClass()
Modified: trunk/spambayes/windows/pop3proxy_service.py
===================================================================
--- trunk/spambayes/windows/pop3proxy_service.py 2008-11-25 02:11:59 UTC (rev 3205)
+++ trunk/spambayes/windows/pop3proxy_service.py 2008-11-25 03:29:21 UTC (rev 3206)
@@ -138,7 +138,7 @@
try:
# module imported by service manager, or 2.3 (in which __main__
# exists, *and* sys.argv[0] is always already absolute)
- this_filename = __file__
+ this_filename=__file__
except NameError:
this_filename = sys.argv[0]
if not os.path.isabs(sys.argv[0]):
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Spambayes-checkins
mailing list