[Nym3-commit] r316 - trunk/nymbaron/Server
jr at conuropsis.org
jr at conuropsis.org
Tue Oct 4 23:11:58 CEST 2005
Author: jr
Date: 2005-10-04 23:11:58 +0200 (Tue, 04 Oct 2005)
New Revision: 316
Modified:
trunk/nymbaron/Server/User.py
Log:
- factorize some code in clean_surbs in prevision of a rewrite of add_surbs
Modified: trunk/nymbaron/Server/User.py
===================================================================
--- trunk/nymbaron/Server/User.py 2005-10-04 20:42:23 UTC (rev 315)
+++ trunk/nymbaron/Server/User.py 2005-10-04 21:11:58 UTC (rev 316)
@@ -73,6 +73,17 @@
current = (max + min) / 2
return max
+def check_surb(surb):
+ """Returns True if the surb is usable, False if it was already used"""
+ fname = '/tmp/' + Mail.mid2filename(Mail.genMid())
+ fname = string.strip(fname)
+ f = open(fname, 'w')
+ f.write(surb)
+ f.close()
+ ec = os.system("mixminion inspect-surb " + fname + " |grep 'Used: no'")
+ os.unlink(fname)
+ return ec == 0
+
class User:
"""Hold user data"""
def __init__(self, username, create = 0):
@@ -308,20 +319,12 @@
surbs = parseReplyBlocks(buffer)
goods = []
for surb in surbs:
- fname = '/tmp/' + Mail.mid2filename(Mail.genMid())
- fname = string.strip(fname)
- f = open(fname, 'w')
- f.write(surb)
- f.close()
- ec = os.system("mixminion inspect-surb " + fname +
- " |grep 'Used: no'")
- os.unlink(fname)
- if ec == 0: goods.append(surb)
- self.data['nSurbs'] = 0
+ if check_surb(surb):
+ goods.append(surb)
f = open(self.surbfile(), "w")
for surb in goods:
f.write(surb)
- self.data['nSurbs'] = self.data['nSurbs'] + 1
+ self.data['nSurbs'] = len(goods)
f.close()
def addSurbs(self, surbs):
More information about the Nym3-commit
mailing list