[Spambayes-checkins] spambayes/Outlook2000 addin.py, 1.141,
1.142 oastats.py, 1.9, 1.10
Kenny Pitt
kpitt at users.sourceforge.net
Mon Dec 6 19:04:38 CET 2004
Update of /cvsroot/spambayes/spambayes/Outlook2000
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv11566
Modified Files:
addin.py oastats.py
Log Message:
If I logged out of Windows without closing Outlook first, updated stats were
not saved. Saving the stats in the OnClose event of the explorer window
seems to fix this. To be safe, I left the Store() call in the
OnDisconnection event of the addin as well, and added a check in the Store()
routine so that stats are not saved again if they haven't changed.
Index: addin.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/addin.py,v
retrieving revision 1.141
retrieving revision 1.142
diff -C2 -d -r1.141 -r1.142
*** addin.py 3 Dec 2004 21:43:19 -0000 1.141
--- addin.py 6 Dec 2004 18:04:34 -0000 1.142
***************
*** 1137,1144 ****
def OnClose(self):
! self.manager.LogDebug(3, "OnClose", self)
self.explorers_collection._DoDeadExplorer(self)
self.explorers_collection = None
self.toolbar = None
self.close() # disconnect events.
--- 1137,1145 ----
def OnClose(self):
! self.manager.LogDebug(3, "Explorer window closing", self)
self.explorers_collection._DoDeadExplorer(self)
self.explorers_collection = None
self.toolbar = None
+ self.manager.stats.Store() # save stats
self.close() # disconnect events.
Index: oastats.py
===================================================================
RCS file: /cvsroot/spambayes/spambayes/Outlook2000/oastats.py,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** oastats.py 6 Dec 2004 17:50:04 -0000 1.9
--- oastats.py 6 Dec 2004 18:04:35 -0000 1.10
***************
*** 39,49 ****
def Store(self):
# Update totals, and save that.
for stat in ["num_ham", "num_spam", "num_unsure",
"num_deleted_spam", "num_deleted_spam_fn",
"num_recovered_good", "num_recovered_good_fp",]:
! self.totals[stat] += getattr(self, stat)
! store = open(self.stored_statistics_fn, 'wb')
! pickle.dump(self.totals, store)
! store.close()
# Reset, or the reporting for the remainder of this session will be
# incorrect.
--- 39,55 ----
def Store(self):
# Update totals, and save that.
+ should_store = False
for stat in ["num_ham", "num_spam", "num_unsure",
"num_deleted_spam", "num_deleted_spam_fn",
"num_recovered_good", "num_recovered_good_fp",]:
! count = getattr(self, stat)
! self.totals[stat] += count
! if count != 0:
! # One of the totals changed, so we need to store the updates.
! should_store = True
! if should_store:
! store = open(self.stored_statistics_fn, 'wb')
! pickle.dump(self.totals, store)
! store.close()
# Reset, or the reporting for the remainder of this session will be
# incorrect.
More information about the Spambayes-checkins
mailing list