[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[minion-cvs] Numerous fixes and cleanups suggested by pychecker



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.seul.org:/tmp/cvs-serv15080/lib/mixminion

Modified Files:
	Common.py Config.py Crypto.py MMTPClient.py MMTPServer.py 
	Main.py Modules.py Queue.py ServerInfo.py ServerMain.py 
	test.py testSupport.py 
Log Message:
Numerous fixes and cleanups suggested by pychecker

Index: Common.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Common.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Common.py	21 Aug 2002 20:49:16 -0000	1.16
+++ Common.py	25 Aug 2002 05:58:01 -0000	1.17
@@ -60,7 +60,7 @@
 	    raise MixFatalError("Nonexistent directory %s" % d)
 	try:
 	    os.makedirs(d, 0700)
-	except OSError, e:
+	except OSError, _:
 	    raise MixFatalError("Unable to create directory %s" % d)
 
     checkPrivateDir(d)
@@ -194,10 +194,12 @@
     """Helper class for logging.  Represents a file on disk, and allows the
        usual close-and-open gimmick for log rotation."""
     def __init__(self, fname):
+	"Create a new FileLogHandler to append messages to fname"
         self.file = None
         self.fname = fname
         self.reset()
     def reset(self):
+	"Close and reopen our underlying file"
         if self.file is not None:
             self.file.close()
 	try: 
@@ -206,6 +208,7 @@
 	    self.file = None
 	    raise MixError("Unable to open log file %r"%self.fname)
     def close(self):
+	"Close the underlying file"
         self.file.close()
     def write(self, severity, message):
 	if self.file is None:
@@ -274,7 +277,7 @@
         for k,v in _SEVERITIES.items():
             if v == self.severity:
                 return k
-        assert 0    
+	return _SEVERITIES['INFO']
         
     def addHandler(self, handler):
         self.handlers.append(handler)

Index: Config.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Config.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- Config.py	21 Aug 2002 19:09:48 -0000	1.11
+++ Config.py	25 Aug 2002 05:58:02 -0000	1.12
@@ -52,7 +52,6 @@
 import re
 import binascii
 import time
-import copy
 import socket # for inet_aton and error
 from cStringIO import StringIO
 
@@ -128,7 +127,7 @@
     i = integer.strip().lower()
     try:
         return int(i)
-    except ValueError, e:
+    except ValueError, _:
         raise ConfigError("Expected an integer but got %r" % (integer))
 
 _ip_re = re.compile(r'\d+\.\d+\.\d+\.\d+')
@@ -145,7 +144,7 @@
 	raise ConfigError("Invalid IP %r" % i)
     try:
         f = socket.inet_aton(i)
-    except socket.error, ex:
+    except socket.error, _:
         raise ConfigError("Invalid IP %r" % i)
 
     return i
@@ -225,7 +224,7 @@
 	    return binascii.a2b_hex(s)
 	else:
 	    return binascii.a2b_base64(s)
-    except (TypeError, binascii.Error, binascii.Incomplete), e:
+    except (TypeError, binascii.Error, binascii.Incomplete), _:
 	raise ConfigError("Invalid Base64 data")
 
 def _parseHex(s):
@@ -377,7 +376,7 @@
     linelength = len(linecontents[0])
     for v in val.split(" "):
         if linelength+1+len(v) <= w:
-            linescontents.append(v)
+            linecontents.append(v)
 	    linelength += 1+len(v)
         else:
 	    lines.append(" ".join(linecontents))
@@ -420,6 +419,9 @@
     #   the entry's value will be set to default.  Otherwise, the value
     #   will be set to None.
 
+    _syntax = None
+    _restrictFormat = 0
+
     def __init__(self, filename=None, string=None, assumeValid=0):
         """Create a new _ConfigFile.  If <filename> is set, read from
            a corresponding file.  If <string> is set, parse its contents.
@@ -709,4 +711,5 @@
         self._syntax.update(self.moduleManager.getConfigSyntax())
     
     def getModuleManager(self):
+	"Return the module manager initialized by this server."
 	return self.moduleManager

Index: Crypto.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Crypto.py,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- Crypto.py	21 Aug 2002 19:09:48 -0000	1.16
+++ Crypto.py	25 Aug 2002 05:58:02 -0000	1.17
@@ -13,7 +13,6 @@
 import stat
 from types import StringType
 
-import mixminion.Config
 import mixminion._minionlib as _ml
 from mixminion.Common import MixError, MixFatalError, floorDiv, ceilDiv, getLog
 
@@ -43,7 +42,7 @@
     try:
         # Try to read /dev/urandom
         trng(1)
-    except MixFatalError, e:
+    except MixFatalError, _:
 	raise
     except:
         raise MixFatalError("Error initializing entropy source")

Index: MMTPClient.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/MMTPClient.py,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- MMTPClient.py	19 Aug 2002 20:27:02 -0000	1.7
+++ MMTPClient.py	25 Aug 2002 05:58:02 -0000	1.8
@@ -41,7 +41,7 @@
         #XXXX session resumption
         self.tls.connect()
         peer_pk = self.tls.get_peer_cert_pk()
-        keyID = sha1(self.tls.get_peer_cert_pk().encode_key(public=1))
+        keyID = sha1(peer_pk.encode_key(public=1))
         if self.targetKeyID is not None and (keyID != self.targetKeyID):
             raise MixProtocolError("Bad Key ID: Expected %r but got %r" % (
                 self.targetKeyID, keyID))

Index: MMTPServer.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/MMTPServer.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- MMTPServer.py	21 Aug 2002 19:09:48 -0000	1.13
+++ MMTPServer.py	25 Aug 2002 05:58:02 -0000	1.14
@@ -489,6 +489,8 @@
 
 # FFFF We need to note retriable situations better.
 class MMTPClientConnection(SimpleTLSConnection):
+    """Asynchronious implementation of the sending ("client") side of a
+       mixminion connection."""
     def __init__(self, context, ip, port, keyID, messageList, handleList,
                  sentCallback=None, failCallback=None):
 	"""Create a connection to send messages to an MMTP server.  
@@ -604,11 +606,12 @@
        del self.messageList[0]
        del self.handleList[0]
        if self.sentCallback is not None:
-           self.sentCallback(justSent, justSetHandle)
+           self.sentCallback(justSent, justSentHandle)
 	   
        self.beginNextMessage()
 
     def handleFail(self, retriable):
+	"""Invoked when a message is not deliverable."""
 	if self.failCallback is not None:
 	    for msg, handle in zip(self.messageList, self.handleList):
 		self.failCallback(msg,handle,retriable)
@@ -618,6 +621,8 @@
     """A helper class to invoke AsyncServer, MMTPServerConnection, and
        MMTPClientConnection"""
     def __init__(self, config):
+	AsyncServer.__init__(self)
+
         self.context = config.getTLSContext(server=1)
 	# FFFF Don't always listen; don't always retransmit!
 	# FFFF Support listening on specific IPs
@@ -625,7 +630,7 @@
                                          config['Outgoing/MMTP']['Port'],
 					 LISTEN_BACKLOG,
                                          self._newMMTPConnection)
-        self.config = config
+	#self.config = config
         self.listener.register(self)
 
     def _newMMTPConnection(self, sock):

Index: Main.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Main.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- Main.py	25 Aug 2002 03:48:48 -0000	1.1
+++ Main.py	25 Aug 2002 05:58:02 -0000	1.2
@@ -17,7 +17,7 @@
 	ino1 = os.stat(f1)[stat.ST_INO]
 	ino2 = os.stat(f2)[stat.ST_INO]
 	return ino1 and ino1 > 0 and ino1 == ino2
-    except OSError, e:
+    except OSError, _:
 	return 0
 
 def correctPath(myself):
@@ -33,14 +33,14 @@
     orig_cmd = myself
     # First, resolve all links.
     while os.path.islink(myself):
-	f = os.readlink(myself)
+	myself = os.readlink(myself)
 
     # Now, the module ought to be living in x/y/z/mixminon/Foo.py.
     # The "x/y/z" is the part we're interested in.
     mydir = os.path.split(myself)[0]
     parentdir, miniondir = os.path.split(mydir)
     if not miniondir == 'mixminion':
-	print >>sys.stderrr, ("Bad mixminion installation:\n"+
+	print >>sys.stderr, ("Bad mixminion installation:\n"+
 	 " I resolved %s to %s, but expected to find ../mixminion/Main.py")%(
 	     orig_cmd, myself)
 
@@ -62,8 +62,8 @@
 
     # Finally, we make sure it all works.
     try:
-	import mixminion.Main
-    except ImportError, e:
+	import mixminion.Main as _
+    except ImportError, _:
 	print >>sys.stderr,"Unable to find correct path for mixminion."
 	sys.exit(1)
 

Index: Modules.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Modules.py,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- Modules.py	25 Aug 2002 03:48:48 -0000	1.8
+++ Modules.py	25 Aug 2002 05:58:02 -0000	1.9
@@ -13,12 +13,14 @@
 import os
 import sys
 import smtplib
+import socket
+import base64
 
 import mixminion.Config
 import mixminion.Packet
 import mixminion.Queue
 from mixminion.Config import ConfigError, _parseBoolean, _parseCommand
-from mixminion.Common import getLog, createPrivateDir
+from mixminion.Common import getLog, createPrivateDir, MixError
 
 # Return values for processMessage
 DELIVER_OK = 1
@@ -50,6 +52,7 @@
 	   * It must know which types it handles.
 	   * Of course, it needs to know how to deliver a message."""
     def __init__(self):
+	"Zero-argument constructor, as required by Module protocol."
 	pass
 
     def getConfigSyntax(self):
@@ -195,6 +198,7 @@
             if self.syntax.has_key(sec):
                 raise ConfigError("Multiple modules want to define [%s]"% sec)
         self.syntax.update(syn)
+	self.nameToModule[module.getName()] = module
 
     def setPath(self, path):
 	"""Sets the search path for Python modules"""
@@ -302,7 +306,6 @@
     # FFFF local MTA.
     def __init__(self):
         DeliveryModule.__init__(self)
-        self.command = None
         self.enabled = 0
         self.addresses = {}
 
@@ -324,6 +327,7 @@
 	
         self.enabled = config['Delivery/MBOX'].get("Enabled", 0)
 	if not self.enabled:
+	    moduleManager.disableModule(self)
 	    return
 
 	self.server = config['Delivery/MBOX']['SMTPServer']
@@ -357,10 +361,7 @@
                 raise ConfigError("Duplicate MBOX user %s"%k)
             self.addresses[k] = v
 
-        if enabled:
-            moduleManager.enableModule(self)
-        else:
-            moduleManager.disableModule(self)
+	moduleManager.enableModule(self)
 
     def getServerInfoBlock(self):
         return """\
@@ -377,16 +378,16 @@
     def processMessage(self, message, exitType, exitInfo):
         assert exitType == MBOX_TYPE
         getLog().trace("Received MBOX message")
-        info = mixminion.packet.parseMBOXInfo(exitInfo)
+        info = mixminion.Packet.parseMBOXInfo(exitInfo)
 	try:
-	    address = addresses[info.user]
-	except KeyError, e:
+	    address = self.addresses[info.user]
+	except KeyError, _:
             getLog.warn("Unknown MBOX user %r", info.user)
 
         msg = _escapeMessageForEmail(message)
 
         fields = { 'user': address,
-                   'return': self.returnAddr,
+                   'return': self.returnAddress,
                    'nickname': self.nickname,
                    'addr': self.addr,
                    'contact': self.contact,
@@ -404,7 +405,7 @@
 %(msg)s
 """ % fields
 
-        return sendSMTPMessage(self.server, [address], self.returnAddr, msg)
+        return sendSMTPMessage(self.server, [address], self.returnAddress, msg)
 
 #----------------------------------------------------------------------
 def sendSMTPMessage(server, toList, fromAddr, message):

Index: Queue.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Queue.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Queue.py	21 Aug 2002 20:49:16 -0000	1.14
+++ Queue.py	25 Aug 2002 05:58:02 -0000	1.15
@@ -136,7 +136,6 @@
 
     def removeAll(self):
         """Removes all messages from this queue."""
-        removed = []
         for m in os.listdir(self.dir):
             if m[:4] in ('inp_', 'msg_'):
                 self.__changeState(m[4:], m[:3], "rmv")
@@ -406,11 +405,12 @@
     # Now we're in the child process.
     try:
         secureDelete(files, blocking=1)
-    except OSError, e:
+    except OSError, _:
         # This is sometimes thrown when shred finishes before waitpid.
         pass
     try:
         os.unlink(cleanFile)
-    except OSError, e:
+    except OSError, _:
         pass
     os._exit(0)
+    return None # Never reached.

Index: ServerInfo.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ServerInfo.py,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- ServerInfo.py	19 Aug 2002 15:33:56 -0000	1.10
+++ ServerInfo.py	25 Aug 2002 05:58:02 -0000	1.11
@@ -15,6 +15,7 @@
 import binascii
 import socket
 
+from mixminion.Common import createPrivateDir
 from mixminion.Modules import SWAP_FWD_TYPE, FWD_TYPE
 from mixminion.Packet import IPV4Info
 import mixminion.Config
@@ -146,14 +147,14 @@
        When we create a new ServerKeyset object, the associated keys are not
        read from disk unil the object's load method is called."""
     def __init__(self, keyroot, keyname, hashroot):
-	keydir = self.keydir = os.path.join(keyroot, "key_"+keyname)
+	keydir  = os.path.join(keyroot, "key_"+keyname)
 	self.hashlogFile = os.path.join(hashroot, "hash_"+keyname)
 	self.packetKeyFile = os.path.join(keydir, "mix.key")
 	self.mmtpKeyFile = os.path.join(keydir, "mmtp.key")
 	self.certFile = os.path.join(keydir, "mmtp.cert")
         self.descFile = os.path.join(keydir, "ServerDesc")
         if not os.path.exists(keydir):
-            os.mkdir(keydir, 0700)
+	    createPrivateDir(keydir)
         
     def load(self, password=None):
         "Read this set of keys from disk."

Index: ServerMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ServerMain.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ServerMain.py	21 Aug 2002 20:49:17 -0000	1.5
+++ ServerMain.py	25 Aug 2002 05:58:02 -0000	1.6
@@ -10,11 +10,15 @@
 import os
 import getopt
 import sys
+import time
+import bisect
 
 import mixminion._minionlib
 import mixminion.Queue
-from mixminion.ServerInfo import ServerKeySet, ServerInfo
-from mixminion.Common import getLog, MixFatalError, MixError, createPrivateDir
+import mixminion.MMTPServer
+from mixminion.ServerInfo import ServerKeyset, ServerInfo
+from mixminion.Common import getLog, MixFatalError, MixError, secureDelete, \
+     createPrivateDir
 
 # Directory layout:
 #     MINION_HOME/work/queues/incoming/
@@ -34,13 +38,13 @@
 
 class ServerKeyring:
     # homeDir: ----
-    # keysDir: ----
+    # keyDir: ----
     # keySloppiness: ----
-    # keyIntervals: list of (start, end, ServerKeySetName)
+    # keyIntervals: list of (start, end, ServerKeyset Name)
     def __init__(self, config):
 	self.configure(config)
 
-    def configure(self):
+    def configure(self, config):
 	self.homeDir = config['Server']['Homedir']
 	self.keyDir = os.path.join(self.homeDir, 'keys')
 	self.keySloppiness = config['Server']['PublicKeySloppiness']
@@ -48,15 +52,15 @@
 
     def checkKeys(self):
         self.keyIntervals = [] 
-        for dirname in os.listdir(self.keysDir):
+        for dirname in os.listdir(self.keyDir):
             if not dirname.startswith('key_'):
 		getLog().warn("Unexpected directory %s under %s",
-			      dirname, self.keysDir)
+			      dirname, self.keyDir)
                 continue
             keysetname = dirname[4:]
             
-            d = os.path.join(self.keysDir, dirname)
-            si = os.path.join(self.keysDir, "ServerDesc")
+            d = os.path.join(self.keyDir, dirname)
+            si = os.path.join(d, "ServerDesc")
             if os.path.exists(si):
                 inf = ServerInfo(fname=si, assumeValid=1)
                 t1 = inf['Server']['Valid-After']
@@ -73,8 +77,8 @@
 
 	for dirname in dirs:
 	    files = [ os.path.join(dirname,f) 
-		                      for f in os.listdir(dirname) ])
-	    secureDelete(filenames, blocking=1)
+		                 for f in os.listdir(dirname) ]
+	    secureDelete(files, blocking=1)
 	    os.rmdir(dirname)
 	    
 	self.checkKeys()
@@ -92,17 +96,17 @@
 	# FFFF Support passwords on keys
 	_, _, name = self._getLiveKey()
 	hashroot = os.path.join(self.homeDir, 'work', 'hashlogs')
-	keyset = ServerKeySet(self.keyDir, name, hashroot)
-	keyset.load
+	keyset = ServerKeyset(self.keyDir, name, hashroot)
+	keyset.load()
 	return self.keyset
 	
     def getDHFile(self):
-	dhdir = os.path.join(self.homedir, 'work', 'tls')
+	dhdir = os.path.join(self.homeDir, 'work', 'tls')
 	createPrivateDir(dhdir)
 	dhfile = os.path.join(dhdir, 'dhparam')
         if not os.path.exists(dhfile):
             getLog().info("Generating Diffie-Helman parameters for TLS...")
-            mixminion._minionlib.generate_dh_parameters(self.dhfile, verbose=0)
+            mixminion._minionlib.generate_dh_parameters(dhfile, verbose=0)
             getLog().info("...done")
 
         return dhfile
@@ -136,18 +140,18 @@
 	    try:
 		res = ph.packetHandler(message)
 		if res is None:
-		    log.info("Padding message dropped")
+		    getLog().info("Padding message dropped")
 		else:
 		    self.mixQueue.queueObject(res)
 		    self.deliverySucceeded(handle)
 	    except mixminion.Crypto.CryptoError, e:
-		log.warn("Invalid PK or misencrypted packet header:"+str(e))
+		getLog().warn("Invalid PK or misencrypted packet header:"+str(e))
 		self.deliveryFailed(handle)
 	    except mixminion.Packet.ParseError, e:
-		log.warn("Malformed message dropped:"+str(e))
+		getLog().warn("Malformed message dropped:"+str(e))
 		self.deliveryFailed(handle)
 	    except mixminion.PacketHandler.ContentError, e:
-		log.warn("Discarding bad packet:"+str(e))
+		getLog().warn("Discarding bad packet:"+str(e))
 		self.deliveryFailed(handle)
 
 class MixQueue:
@@ -166,7 +170,7 @@
 	    tp, info = self.queue.getObject(h)
 	    if tp == 'EXIT':
 		rt, ri, app_key, payload = info
-		self.moduleManger.queueMessage((rt, ri), payload)
+		self.moduleManager.queueMessage((rt, ri), payload)
 	    else:
 		assert tp == 'QUEUE'
 		ipv4, msg = info
@@ -178,7 +182,7 @@
 	self.server = None
 
     def connectQueues(self, server):
-	self.server = sever
+	self.server = server
 
     def deliverMessages(self, msgList):
 	# Map from addr -> [ (handle, msg) ... ]
@@ -190,11 +194,11 @@
 	    self.server.sendMessages(addr.ip, addr.port, addr.keyinfo,
 				     messages, handles)
 
-class _MMTPConnection(MMTPServer):
+class _MMTPConnection(mixminion.MMTPServer):
     def __init__(self, config):
         MMTPServer.__init__(self, config)
 
-    def connectQueues(self, incoming, outgoing)
+    def connectQueues(self, incoming, outgoing):
         self.incomingQueue = incoming
         self.outgoingQueue = outgoing
 
@@ -228,7 +232,7 @@
 
 	mixDir = os.path.join(queueDir, "mix")
 	# FFFF The choice of mix algorithm should be configurable
-	self.mixQueue = MixQueue(TimedMixQueue(mixDir, 60))
+	self.mixQueue = MixQueue(mixminion.Queue.TimedMixQueue(mixDir, 60))
 
 	outgoingDir = os.path.join(queueDir, "outgoing")
 	self.outgoingQueue = OutgoingQueue(outgoingDir)
@@ -266,16 +270,16 @@
 
 #----------------------------------------------------------------------
 
-def usageAndExit():
+def usageAndExit(cmd):
     executable = sys.argv[0]
     # XXXX show versioning info
     print >>sys.stderr, "Usage: %s [-h] [-f configfile]" % cmd
     sys.exit(0)
 
 def configFromArgs(cmd, args):
-    options, args = getopt.getopt(args, "hf=", ["help", "config="])
+    options, args = getopt.getopt(args, "hf:", ["help", "config="])
     if args:
-	usageAndExit()
+	usageAndExit(cmd)
     configFile = "/etc/miniond.conf"
     for o,v in options:
 	if o in ('-h', '--help'):
@@ -284,7 +288,7 @@
 	    configFile = v
     try:
 	config = mixminion.Config.ServerConfig(fname=configFile)
-    except OSError:
+    except (IOError, OSError), e:
 	print >>sys.stderr, "Error reading configuration file %r"%configFile
 	sys.exit(1)
     except mixminion.Config.ConfigError, e:
@@ -319,6 +323,3 @@
     getLog().info("Server shutting down")
     
     sys.exit(0)
-
-if __name__ = '__main__':
-    runServer(sys.argv[0], sys.argv[1])

Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- test.py	25 Aug 2002 03:48:48 -0000	1.22
+++ test.py	25 Aug 2002 05:58:02 -0000	1.23
@@ -1391,7 +1391,7 @@
 	queue.removeAll()
 	queue.cleanQueue()
 
-    def testDeliveryQueues(self):
+    def testMixQueues(self):
 	d_m = mix_mktemp("qm")
 	queue = TimedMixQueue(d_m)
 	h1 = queue.queueMessage("Hello1")
@@ -1462,7 +1462,7 @@
         
 	buf.truncate(0)
 	try:
-	    1/0
+	    raise MixError()
 	except:
 	    inf = sys.exc_info()
 	log.error_exc(inf)
@@ -1493,6 +1493,8 @@
 
 class FileParanoiaTests(unittest.TestCase):
     def testPrivateDirs(self):
+	import mixminion.testSupport
+
 	noia = mix_mktemp("noia")
 	tempdir = mixminion.testSupport._MM_TESTING_TEMPDIR
 	try:
@@ -1696,7 +1698,7 @@
             server.process(0.1)
         t.join()
 
-        for i in xrange(10):
+        for _ in xrange(10):
             server.process(0.1)
 
         self.failUnless(messagesIn == messages)
@@ -1890,7 +1892,6 @@
         self.assertEquals(f['Sec3']['IntRS'], 9)
 
     def testBadFiles(self):
-        TCF = TestConfigFile
         def fails(string, self=self):
             self.failUnlessRaises(ConfigError, TestConfigFile, None, string)
 
@@ -1906,13 +1907,13 @@
         fails("[Sec1]\nFoo: Bar\n[Sec3]\nIntRS=Z\n") # Failed validation
 
         # now test the restricted format
-        def fails(string, self=self):
+        def failsR(string, self=self):
             self.failUnlessRaises(ConfigError, TestConfigFile, None, string, 1)
-        fails("[Sec1]\nFoo=Bar\n")
-        fails("[Sec1]\nFoo Bar\n")
-        fails("[Sec1]\n\nFoo: Bar\n")
-        fails("\n[Sec1]\nFoo: Bar\n")
-        fails("\n[Sec1]\nFoo: Bar\n\n")
+        failsR("[Sec1]\nFoo=Bar\n")
+        failsR("[Sec1]\nFoo Bar\n")
+        failsR("[Sec1]\n\nFoo: Bar\n")
+        failsR("\n[Sec1]\nFoo: Bar\n")
+        failsR("\n[Sec1]\nFoo: Bar\n\n")
 
     def testValidationFns(self):
         import mixminion.Config as C
@@ -2003,7 +2004,7 @@
                 self.assertEquals(opts, ["-meow"])
             else:
                 self.fail("_parseCommand is not working as expected")
-        except ConfigError, e:
+        except ConfigError, _:
             # This is what we expect
             pass
 
@@ -2098,7 +2099,7 @@
         # Now make sure everything was saved properly
         keydir = os.path.join(d, "key_key1")
         eq(inf, open(os.path.join(keydir, "ServerDesc")).read())
-        keys = mixminion.ServerInfo.ServerKeyset(d, "key1", d)
+	mixminion.ServerInfo.ServerKeyset(d, "key1", d) # Can we load?
         packetKey = mixminion.Crypto.pk_PEM_load(
             os.path.join(keydir, "mix.key"))
         eq(packetKey.get_public_key(),
@@ -2119,11 +2120,11 @@
 
         # Now with a shorter configuration
         conf = mixminion.Config.ServerConfig(string=SERVER_CONFIG_SHORT)
-        inf2 = mixminion.ServerInfo.generateServerDescriptorAndKeys(conf,
-                                                                    identity,
-                                                                    d,
-                                                                    "key2",
-                                                                    d)
+	mixminion.ServerInfo.generateServerDescriptorAndKeys(conf,
+							     identity,
+							     d,
+							     "key2",
+							     d)
         
         # Now with a bad signature
         sig2 = mixminion.Crypto.pk_sign(sha1("Hello"), identity)
@@ -2138,7 +2139,7 @@
         mixminion.ServerInfo.ServerInfo(None, badSig, assumeValid=1)
 
         # Now with a bad digest
-        badDig = inf.replace("a@b.c", "---")
+        badSig = inf.replace("a@b.c", "---")
         self.failUnlessRaises(ConfigError,
                               mixminion.ServerInfo.ServerInfo,
                               None, badSig)

Index: testSupport.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/testSupport.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- testSupport.py	25 Aug 2002 03:48:48 -0000	1.1
+++ testSupport.py	25 Aug 2002 05:58:02 -0000	1.2
@@ -10,13 +10,23 @@
 import sys
 import stat
 
-from mixminion.Common import waitForChildren
+from mixminion.Common import waitForChildren, createPrivateDir
 from mixminion.Config import _parseBoolean, ConfigError
 from mixminion.Modules import DeliveryModule, ImmediateDeliveryQueue, \
      SimpleModuleDeliveryQueue, DELIVER_OK, DELIVER_FAIL_RETRY, \
      DELIVER_FAIL_NORETRY
 
-def DirectoryDumpModule(DeliveryModule):
+class DirectoryStoreModule(DeliveryModule):
+    """Delivery module for testing: puts messages in files in a given
+       directory.  Can be configured to use a delivery queue or not.
+
+       When this module delivers a message:
+       If the routing info is 'FAIL!', the message is treated as undeliverable.
+       If the routing info is 'fail', the message is treated as temporarily
+         undeliverable (and so will eventually time out).
+       Otherwise, creates a file in the specified directory, containing
+          the routing info, a newline, and the message contents.
+    """
     def getConfigSyntax(self):
 	return { 'Testing/DirectoryDump':
 		 { 'Location' : ('REQUIRE', None, None),
@@ -34,6 +44,9 @@
 	self.useQueue = sections['Testing/DirectoryDump']['UseQueue']
 	manager.registerModule(self)
 	
+	if not os.path.exits(self.loc):
+	    createPrivateDir(self.loc)
+
 	max = -1
 	for f in os.listdir(self.loc):
 	    if int(f) > max: 
@@ -59,7 +72,7 @@
 	assert exitType == 0xFFFE
 	if exitInfo == 'fail':
 	    return DELIVER_FAIL_RETRY
-	elif exitIno == 'FAIL!':
+	elif exitInfo == 'FAIL!':
 	    return DELIVER_FAIL_NORETRY
 
 	f = open(os.path.join(self.loc, self.next), 'w')
@@ -118,7 +131,7 @@
 		    print "Directory %s has fishy permissions %o" %(parent,m)
 		    sys.exit(1)
 		if st[stat.ST_UID] not in (0, os.getuid()):
-		    print "Directory %s has bad owner %s" % st[stat.UID]
+		    print "Directory %s has bad owner %s" % st[stat.ST_UID]
 		    sys.exit(1)
 		    
 	_MM_TESTING_TEMPDIR = temp
@@ -132,6 +145,8 @@
 
 _WAIT_FOR_KIDS = 1
 def deltree(*dirs):
+    """Delete each one of a list of directories, along with all of its
+       contents"""
     global _WAIT_FOR_KIDS
     if _WAIT_FOR_KIDS:
 	print "Waiting for shred processes to finish."