[Nym3-commit] r427 - in trunk: . nymbaron/Client nymbaron/Server
jr at conuropsis.org
jr at conuropsis.org
Thu Nov 24 18:54:13 CET 2005
Author: jr
Date: 2005-11-24 18:54:11 +0100 (Thu, 24 Nov 2005)
New Revision: 427
Modified:
trunk/TODO
trunk/nymbaron/Client/Account.py
trunk/nymbaron/Client/Config.py
trunk/nymbaron/Server/Config.py
trunk/nymbaron/Server/Main.py
trunk/nymbaron/Server/User.py
Log:
- fix DEBUG behaviour and add online option [client] [server]
- remove the cleaning of surbs when surbs are added
- add a helper function to Main.py [server]
- doc TODO item
Modified: trunk/TODO
===================================================================
--- trunk/TODO 2005-11-23 19:12:50 UTC (rev 426)
+++ trunk/TODO 2005-11-24 17:54:11 UTC (rev 427)
@@ -34,6 +34,7 @@
X reorder the items of the usage string [client]
doc:
+ - use doc strings instead of comments in Config.py [client]
* document new client command (remove-accounts)
* improve the explanation of the client philosophy in Getting Started
o add doc strings in __init__.py in every module.
Modified: trunk/nymbaron/Client/Account.py
===================================================================
--- trunk/nymbaron/Client/Account.py 2005-11-23 19:12:50 UTC (rev 426)
+++ trunk/nymbaron/Client/Account.py 2005-11-24 17:54:11 UTC (rev 427)
@@ -281,10 +281,12 @@
f.close()
mixcall = "mixminion send -t %s -i %s" % \
(self['servername'], msgpath)
- os.system(mixcall)
- if not self.config.DEBUG:
+ if self.config.online:
+ os.system(mixcall)
+ if self.config.DEBUG:
+ print "Raw control message left in " + msgpath
+ else:
os.unlink(msgpath)
- else: print "Raw control message left in " + msgpath
def mboxfile(self):
"""Gets the path of the mailbox"""
@@ -427,10 +429,10 @@
self._save_journal()
self._save_data()
else:
+ self.tagmap.remove(self.idTag)
for f in os.listdir(self.base_path):
os.unlink(self.base_path + '/' + f)
os.rmdir(self.base_path)
- self.tagmap.remove(self.idTag)
self._release()
def _load_mbox(self):
Modified: trunk/nymbaron/Client/Config.py
===================================================================
--- trunk/nymbaron/Client/Config.py 2005-11-23 19:12:50 UTC (rev 426)
+++ trunk/nymbaron/Client/Config.py 2005-11-24 17:54:11 UTC (rev 427)
@@ -31,7 +31,10 @@
#####Default values#####
#Tells the client whether he should send the messages he generates
- # through mixminion or output them on stdout
+ # through mixminion
+ self.online = True
+ #Tells the client whether he should leave the commands sent in temporary
+ #files
self.DEBUG = False
#The path to the directory containing the user accounts
self.path = os.environ['HOME'] + '/.nymbaron-account'
@@ -51,6 +54,8 @@
config.read(filename)
if config.has_section('general'):
+ if config.has_option('general', 'online'):
+ self.online = config.getboolean('general', 'online')
if config.has_option('general', 'DEBUG'):
self.DEBUG = config.getboolean('general', 'DEBUG')
if config.has_option('general', 'path'):
Modified: trunk/nymbaron/Server/Config.py
===================================================================
--- trunk/nymbaron/Server/Config.py 2005-11-23 19:12:50 UTC (rev 426)
+++ trunk/nymbaron/Server/Config.py 2005-11-24 17:54:11 UTC (rev 427)
@@ -39,9 +39,12 @@
def __init__(self, filename = None):
self.DEBUG = False
- """Whether the server sends the message it generates to mixminion or to
- stdout"""
+ """Whether the server erases the messages it generates from tmp"""
+ self.online = True
+ """Whether the server sends the messages it generates on the mixminion
+ network"""
+
self.serverName = 'nymserv.komite.net'
"""The hostname of the host on which the nymserver is running."""
@@ -66,6 +69,8 @@
config.read(filename)
if config.has_section('general'):
+ if config.has_option('general', 'online'):
+ self.online = config.getboolean('general', 'online')
if config.has_option('general', 'DEBUG'):
self.DEBUG = config.getboolean('general', 'DEBUG')
if config.has_option('general', 'path'):
Modified: trunk/nymbaron/Server/Main.py
===================================================================
--- trunk/nymbaron/Server/Main.py 2005-11-23 19:12:50 UTC (rev 426)
+++ trunk/nymbaron/Server/Main.py 2005-11-24 17:54:11 UTC (rev 427)
@@ -53,6 +53,19 @@
except OSError:
config = Config.Config()
+def mapAccount(config, fun, funargs = None):
+ """Applies the function fun to each account of the server. The signature of
+ fun is: fun(account[, tuple of arguments specific to fun]), returns nothing
+ """
+ for f in os.listdir(config.path):
+ if len(f) >= 4 and f[-4:] == ".dat":
+ username = f[:-4]
+ nymuser = User.User(username, config)
+ if funargs:
+ fun(nymuser, *funargs)
+ else:
+ fun(nymuser)
+
def processIncoming(localpart, msg):
"""Process incoming mail from the MTA
- identifies the nym the mail is addressed to
Modified: trunk/nymbaron/Server/User.py
===================================================================
--- trunk/nymbaron/Server/User.py 2005-11-23 19:12:50 UTC (rev 426)
+++ trunk/nymbaron/Server/User.py 2005-11-24 17:54:11 UTC (rev 427)
@@ -326,16 +326,17 @@
def send(self, msg):
"""Sends a message to the nymholder through the mixminion network,
using the surbs provided by the nymholder"""
- if self.config.DEBUG:
- print msg
- return 0
- else:
- fname = Mail.tmpFileMsg(msg)
- ec = os.system("mixminion send -R " + self.surbfile() + " -i " + fname)
- # TODO : debugging cruft
- #os.unlink(fname)
+ fname = Mail.tmpFileMsg(msg)
+ if self.config.online:
+ ec = os.system("mixminion send -R " + self.surbfile() + " -i " +
+ fname)
+ else:
+ ec = 0
+ if self.config.DEBUG:
print "Message file left in " + fname
- return ec
+ else:
+ os.unlink(fname)
+ return ec
def clean_surbs(self):
"""Inspect the surbs and delete the used/outdated"""
@@ -372,31 +373,26 @@
except IOError:
surbslist = []
#keep the not used ones
+ olds = []
goods = []
- na = 0
- nr = 0
for surb in surbslist:
surbp = surb.pack()
- if check_surb(surbp):
- goods.append(surbp)
- else:
- nr = nr + 1
+ olds.append(surbp)
try:
#add the new ones
newsurbslist = parseReplyBlocks(newsurbs)
for newsurb in newsurbslist:
newsurbp = newsurb.pack()
- if (not newsurbp in goods) and check_surb(newsurbp):
+ if (not newsurbp in (olds + goods)) and check_surb(newsurbp):
goods.append(newsurbp)
- na = na + 1
#save the result
- self['nSurbs'] = len(goods)
+ self['nSurbs'] = self['nSurbs'] + len(goods)
fname = self.surbfile()
- f = open(fname, "w")
+ f = open(fname, "a")
for surbp in goods:
f.write(surbp)
f.close()
- print "%d surbs added\n%d used surbs removed" % (na, nr)
+ print "%d surbs added" % len(goods)
except ParseError:
#the provided binary data isn't a succession of binary surbs
return
More information about the Nym3-commit
mailing list