Update of /cvsroot/spambayes/spambayes/scripts
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv507/scripts
Modified Files:
sb_imapfilter.py sb_pop3dnd.py sb_server.py
Log Message:
Use new stats manager properly.
Index: sb_imapfilter.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/scripts/sb_imapfilter.py,v
retrieving revision 1.48
retrieving revision 1.49
diff -C2 -d -r1.48 -r1.49
*** sb_imapfilter.py 20 Dec 2004 02:49:47 -0000 1.48
--- sb_imapfilter.py 22 Dec 2004 00:27:17 -0000 1.49
***************
*** 98,101 ****
--- 98,103 ----
import StringIO
+ from spambayes import Stats
+ from spambayes import message
from spambayes.Options import options, get_pathname_option
from spambayes import tokenizer, storage, message, Dibbler
***************
*** 1028,1031 ****
--- 1030,1034 ----
classifier = storage.open_storage(bdbname, useDBM)
+ message_db = message.open_storage(*message.database_type())
if options["globals", "verbose"]:
***************
*** 1083,1089 ****
else:
imap = IMAPSession(server, port, imapDebug, doExpunge)
httpServer = UserInterfaceServer(options["html_ui", "port"])
httpServer.register(IMAPUserInterface(classifier, imap, pwd,
! IMAPSession))
launchBrowser=launchUI or options["html_ui", "launch_browser"]
if sleepTime:
--- 1086,1096 ----
else:
imap = IMAPSession(server, port, imapDebug, doExpunge)
+
+ # Load stats manager.
+ stats = Stats(options, message_db)
+
httpServer = UserInterfaceServer(options["html_ui", "port"])
httpServer.register(IMAPUserInterface(classifier, imap, pwd,
! IMAPSession, stats=stats))
launchBrowser=launchUI or options["html_ui", "launch_browser"]
if sleepTime:
Index: sb_pop3dnd.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/scripts/sb_pop3dnd.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** sb_pop3dnd.py 21 Dec 2004 23:21:22 -0000 1.14
--- sb_pop3dnd.py 22 Dec 2004 00:27:17 -0000 1.15
***************
*** 538,544 ****
class SpambayesInbox(SpambayesMailbox):
"""A special mailbox that holds status messages from SpamBayes."""
! def __init__(self, id, message_db):
IMAPMailbox.__init__(self, "INBOX", "spambayes", id)
! self.mdb = message_db
self.UID_validity = id
self.nextUID = 1
--- 538,544 ----
class SpambayesInbox(SpambayesMailbox):
"""A special mailbox that holds status messages from SpamBayes."""
! def __init__(self, id, state):
IMAPMailbox.__init__(self, "INBOX", "spambayes", id)
! self.mdb = state.mdb
self.UID_validity = id
self.nextUID = 1
***************
*** 547,560 ****
self.storage = {}
self.createMessages()
! s_thres = options["Categorization", "spam_cutoff"]
! u_thres = options["Categorization", "ham_cutoff"]
! fp_cost = options["TestDriver", "best_cutoff_fp_weight"]
! fn_cost = options["TestDriver", "best_cutoff_fn_weight"]
! unsure_cost = options["TestDriver", "best_cutoff_unsure_weight"]
! h_string = options["Headers", "header_ham_string"]
! s_string = options["Headers", "header_spam_string"]
! u_string = options["Headers", "header_unsure_string"]
! self.stats = Stats(s_thres, u_thres, message_db, h_string, u_string,
! s_string, fp_cost, fn_cost, unsure_cost)
def buildStatusMessage(self, body=False, headers=False):
--- 547,551 ----
self.storage = {}
self.createMessages()
! self.stats = state.stats
def buildStatusMessage(self, body=False, headers=False):
***************
*** 607,611 ****
msg.append('\r\n')
if body:
! msg.extend(s.GetStats(use_html=False))
return "\r\n".join(msg)
--- 598,602 ----
msg.append('\r\n')
if body:
! msg.extend(self.stats.GetStats(use_html=False))
return "\r\n".join(msg)
***************
*** 918,921 ****
--- 909,913 ----
work is done elsewhere. We do need to load the classifier,
though, and build the status strings."""
+ # Load token and message databases.
if not hasattr(self, "DBName"):
self.DBName, self.useDB = storage.database_type([])
***************
*** 924,927 ****
--- 916,924 ----
self.MDBName, self.useMDB = message.database_type()
self.mdb = message.open_storage(self.MDBName, self.useMDB)
+
+ # Load stats manager.
+ self.stats = Stats(options, self.mdb)
+
+ # Build status strings.
self.buildStatusStrings()
***************
*** 955,959 ****
"spam_to_train")
spam_train_box = SpambayesMailbox("TrainAsSpam", 3, spam_train_cache)
! inbox = SpambayesInbox(4, state.mdb)
spam_trainer = Trainer(spam_train_box, True)
--- 952,956 ----
"spam_to_train")
spam_train_box = SpambayesMailbox("TrainAsSpam", 3, spam_train_cache)
! inbox = SpambayesInbox(4, state)
spam_trainer = Trainer(spam_train_box, True)
Index: sb_server.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/scripts/sb_server.py,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** sb_server.py 21 Dec 2004 23:13:47 -0000 1.34
--- sb_server.py 22 Dec 2004 00:27:17 -0000 1.35
***************
*** 111,114 ****
--- 111,115 ----
import spambayes.message
from spambayes import i18n
+ from spambayes import Stats
from spambayes import Dibbler
from spambayes import storage
***************
*** 804,808 ****
self.DBName, self.useDB = storage.database_type([])
self.bayes = storage.open_storage(self.DBName, self.useDB)
!
self.buildStatusStrings()
--- 805,815 ----
self.DBName, self.useDB = storage.database_type([])
self.bayes = storage.open_storage(self.DBName, self.useDB)
! if not hasattr(self, "MBDName"):
! self.MDBName, self.useMDB = message.database_type()
! self.mdb = message.open_storage(self.MDBName, self.useMDB)
!
! # Load stats manager.
! self.stats = Stats(options, self.mdb)
!
self.buildStatusStrings()
_______________________________________________
Spambayes-checkins mailing list
[EMAIL PROTECTED]
http://mail.python.org/mailman/listinfo/spambayes-checkins