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

[minion-cvs] Normalize EOL whitespace and add a target to do so for ...



Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv684/lib/mixminion

Modified Files:
	BuildMessage.py ClientMain.py Common.py Config.py 
	ServerInfo.py benchmark.py test.py 
Log Message:
Normalize EOL whitespace and add a target to do so for us in the future.

Index: BuildMessage.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/BuildMessage.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- BuildMessage.py	5 Jan 2003 01:27:12 -0000	1.30
+++ BuildMessage.py	5 Jan 2003 06:49:25 -0000	1.31
@@ -33,7 +33,7 @@
 
         Neither path1 nor path2 may be empty.  If one is, MixError is raised.
     """
-    if paddingPRNG is None: 
+    if paddingPRNG is None:
         paddingPRNG = Crypto.getCommonPRNG()
     if not path1:
         raise MixError("First leg of path is empty")
@@ -68,7 +68,7 @@
             paddingPRNG: random number generator used to generate padding.
                   If None, a new PRNG is initialized.
     """
-    if paddingPRNG is None: 
+    if paddingPRNG is None:
         paddingPRNG = Crypto.getCommonPRNG()
     if secretRNG is None: secretRNG = paddingPRNG
 
@@ -202,7 +202,7 @@
        block that stored its secrets on disk, and used an arbitrary tag to
        determine
        """
-    if secretRNG is None: 
+    if secretRNG is None:
         secretRNG = Crypto.getCommonPRNG()
 
     # We need to pick the seed to generate our keys.  To make the decoding
@@ -561,7 +561,7 @@
     origLength = len(payload)
     payload = compressData(payload)
     length = len(payload)
-    
+
     if length > 1024 and length*20 <= origLength:
         LOG.warn("Message is very compressible and will look like a zlib bomb")
 
@@ -661,11 +661,11 @@
             raise CompressedDataTooLong()
         except zlibutil.DecompressError, e:
             raise ParseError("Error in compressed data: %s"%e)
-    
+
     try:
         # We can't just call zlib.decompress(payload), since we may
         # want to limit the output size.
-        
+
         zobj = zlib.decompressobj(zlib.MAX_WBITS)
         # Decompress the payload.
         if maxLength is None:
@@ -676,7 +676,7 @@
             d = zobj.decompress(payload, maxLength)
             if zobj.unconsumed_tail:
                 raise CompressedDataTooLong()
-            
+
         # Get any leftovers, which shouldn't exist.
         nil = zobj.flush()
         if nil != '':

Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -d -r1.24 -r1.25
--- ClientMain.py	5 Jan 2003 05:15:03 -0000	1.24
+++ ClientMain.py	5 Jan 2003 06:49:25 -0000	1.25
@@ -67,9 +67,9 @@
     # DIR/imported/: A directory of server descriptors.
 
     MAGIC = "ClientKeystore-0"
-    # 
+    #
     DEFAULT_REQUIRED_LIFETIME = 3600
-    
+
     def __init__(self, directory):
         """Create a new ClientKeystore to keep directories and descriptors
            under <directory>."""
@@ -81,7 +81,7 @@
         self.__load()
         self.clean()
 
-        # Mixminion 0.0.1 used an obsolete directory-full-of-servers in 
+        # Mixminion 0.0.1 used an obsolete directory-full-of-servers in
         #   DIR/servers.  If there's nothing there, we remove it.  Otherwise,
         #   we warn.
         sdir = os.path.join(self.dir,"servers")
@@ -106,9 +106,9 @@
             self.downloadDirectory()
         else:
             LOG.debug("Directory is up to date.")
-        
+
     def downloadDirectory(self):
-        """Download a new directory from the network, validate it, and 
+        """Download a new directory from the network, validate it, and
            rescan its servers."""
         # Start downloading the directory.
         url = MIXMINION_DIRECTORY_URL
@@ -156,11 +156,11 @@
         else:
             os.rename(fname, os.path.join(self.dir, "dir"))
 
-        # And regenerate the cache. 
+        # And regenerate the cache.
         self.rescan()
         # FFFF Actually, we could be a bit more clever here, and same some
         # FFFF time. But that's for later.
-        
+
     def rescan(self, force=None, now=None):
         """Regenerate the cache based on files on the disk."""
         self.lastModified = self.lastDownload = -1
@@ -235,7 +235,7 @@
         if self.__scanning:
             raise MixFatalError("Recursive error while regenerating cache")
         self.rescan()
-        
+
     def __save(self):
         """Helper method. Recreate the cache on disk."""
         fname = os.path.join(self.dir, "cache.new")
@@ -253,7 +253,7 @@
 
     def importFromFile(self, filename):
         """Import a new server descriptor stored in 'filename'"""
-        
+
         contents = readPossiblyGzippedFile(filename)
         info = ServerInfo(string=contents, validatedDigests=self.digestMap)
 
@@ -279,7 +279,7 @@
         if self.byNickname.has_key(nickname):
             if info.isSupersededBy([s for s, _ in self.byNickname[nickname]]):
                 raise MixError("Server descriptor is superseded")
-        
+
         # Copy the server into DIR/servers.
         fnshort = "%s-%s"%(nickname, formatFnameTime())
         fname = os.path.join(self.dir, "imported", fnshort)
@@ -324,7 +324,7 @@
         """
         self.byNickname = {}
         self.allServers = []
-        self.byCapability = { 'mbox': [], 
+        self.byCapability = { 'mbox': [],
                               'smtp': [],
                               'relay': [],
                               None: self.allServers }
@@ -372,7 +372,7 @@
     def __find(self, lst, startAt, endAt):
         """Helper method.  Given a list of (ServerInfo, where), return all
            elements that are valid for all time between startAt and endAt.
-           
+
            Only one element is returned for each nickname; if multiple
            elements with a given nickname are valid over the given time
            interval, the most-recently-published one is included.
@@ -413,7 +413,7 @@
                     LOG.info("Couldn't remove %s: %s", where[2:], e)
             else:
                 # Don't scratch non-superseded, non-expired servers.
-                newServers.append((info, where))            
+                newServers.append((info, where))
 
         if len(self.serverList) != len(newServers):
             self.serverList = newServers
@@ -421,10 +421,10 @@
             self.__rebuildTables()
 
     def getServerInfo(self, name, startAt=None, endAt=None, strict=0):
-        """Return the most-recently-published ServerInfo for a given 
-           'name' valid over a given time range.  If strict, and no 
+        """Return the most-recently-published ServerInfo for a given
+           'name' valid over a given time range.  If strict, and no
            such server is found, return None.
-           
+
            name -- A ServerInfo object, a nickname, or a filename.
            """
 
@@ -465,13 +465,13 @@
            >= 'length' hops, path, beginning with startServers and ending with
            endServers.  If more servers are required to make up 'length' hops,
            they are selected at random.
-          
+
            All servers are chosen to be valid continuously from startAt to
            endAt.  All newly-selected servers except the last are required to
            have 'midCap' (typically 'relay'); the last server (if endServers
            is not set) is selected to have 'endCap' (typically 'mbox' or
            'smtp').
-           
+
            The path selection algorithm is a little complicated, but gets
            more reasonable as we know about more servers.
         """
@@ -481,9 +481,9 @@
             endAt = startAt + self.DEFAULT_REQUIRED_LIFETIME
         if prng is None:
             prng = mixminion.Crypto.getCommonPRNG()
-        
+
         # Look up the manditory servers.
-        startServers = [ self.getServerInfo(name,startAt,endAt,1) 
+        startServers = [ self.getServerInfo(name,startAt,endAt,1)
                          for name in startServers ]
         endServers = [ self.getServerInfo(name,startAt,endAt,1)
                        for name in endServers ]
@@ -492,7 +492,7 @@
         nNeeded = 0
         if length:
             nNeeded = length - len(startServers) - len(endServers)
-        
+
         if nNeeded <= 0:
             return startServers + endServers
 
@@ -504,7 +504,7 @@
                 raise MixError("No %s servers known" % endCap)
             # ... and pick one that hasn't been used, if possible.
             used = [ info.getNickname() for info in startServers ]
-            unusedEndList = [ info for info in endList 
+            unusedEndList = [ info for info in endList
                               if info.getNickname() not in used ]
             if unusedEndList:
                 endServers = [ prng.pick(unusedEndList) ]
@@ -520,20 +520,20 @@
         # This is hard.  We need to find a number of relay servers for
         # the midddle of the list.  If len(candidates) > length, we should
         # remove all servers that already appear, and shuffle from the
-        # rest.  Otherwise, if len(candidates) >= 3, we pick one-by-one from 
+        # rest.  Otherwise, if len(candidates) >= 3, we pick one-by-one from
         # the list of possibilities, just making sure not to get 2 in a row.
         # Otherwise, len(candidates) <= 3, so we just wing it.
         #
         # FFFF This algorithm is far from ideal, but the answer is to
         # FFFF get more servers deployed.
-        
+
         # Find our candidate servers.
         midList = self.__find(self.byCapability[midCap],startAt,endAt)
         # Which of them are we using now?
-        used = [ info.getNickname() 
+        used = [ info.getNickname()
                  for info in list(startServers)+list(endServers) ]
         # Which are left?
-        unusedMidList = [ info for info in midList 
+        unusedMidList = [ info for info in midList
                           if info.getNickname() not in used ]
         if len(unusedMidList) >= nNeeded:
             # We have enough enough servers to choose without replacement.
@@ -554,7 +554,7 @@
             else:
                 endNickname = " (impossible nickname) "
 
-            while nNeeded: 
+            while nNeeded:
                 info = prng.pick(midList)
                 n = info.getNickname()
                 if n != prevNickname and (nNeeded > 1 or n != endNickname):
@@ -562,7 +562,7 @@
                     prevNickname = n
                     nNeeded -= 1
         elif len(midList) == 2:
-            # We have enough servers to concoct a path that at least 
+            # We have enough servers to concoct a path that at least
             # _sometimes_ doesn't go to the same server twice in a row.
             LOG.warn("Not enough relays to avoid same-server hops")
             midList = prng.shuffle(midList)
@@ -608,11 +608,11 @@
     else:
         exitCap = None
 
-    # We have a normally-specified path. 
+    # We have a normally-specified path.
     if exitNode is not None:
         exitPath = exitPath[:]
         exitPath.append(exitNode)
-        
+
     path = keystore.getPath(length=nHops,
                             startServers=enterPath,
                             endServers=exitPath,
@@ -626,7 +626,7 @@
     if exitCap and exitCap not in path[-1].getCaps():
         raise MixError("Server %s does not support %s"
                        % (path[-1].getNickname(), exitCap))
- 
+
     if nSwap is None:
         nSwap = ceilDiv(len(path),2)-1
 
@@ -635,11 +635,11 @@
         raise MixError("Each leg of the path must have at least 1 hop")
     return path1, path2
 
-def parsePath(keystore, config, path, address, nHops=None, 
+def parsePath(keystore, config, path, address, nHops=None,
               nSwap=None, startAt=None, endAt=None):
     """Resolve a path as specified on the command line.  Returns a
        (path-leg-1, path-leg-2) tuple.
-       
+
        keystore -- the keystore to use.
        config -- unused for now.
        path -- the path, in a format described below.  If the path is
@@ -658,9 +658,9 @@
        You can use a colon as a separator to divides the first leg of the path
        from the second:
              'foo,bar:baz,quux'.
-       If nSwap and a colon are both used, they must match, or MixError is 
+       If nSwap and a colon are both used, they must match, or MixError is
        raised.
-       
+
        You can use a star to specify a fill point where randomly-selected
        servers will be added:
              'foo,bar,*,quux'.
@@ -672,7 +672,7 @@
     """
     if not path:
         path = '*'
-        
+
     # Turn 'path' into a list of server names, '*', and '*swap*'.
     #  (* is not a valid nickname character, so we're safe.)
     path = path.replace(":", ",*swap*,").split(",")
@@ -698,7 +698,7 @@
             swapPos = idx
         else:
             cur.append(ent)
-    
+
     # Now, we set the variables myNHops and myNSwap to the values of
     # nHops and nSwap (if any) implicit in the parsed path.
     if starPos is None:
@@ -710,7 +710,7 @@
             myNHops = config['Security'].get("PathLength", 6)
         else:
             myNHops = 6
-            
+
 
     if swapPos is None:
         # a,b,c,d or a,b,*,c
@@ -807,7 +807,7 @@
                the path, respectively."""
 
         message, firstHop = \
-                 self.generateForwardMessage(address, payload, 
+                 self.generateForwardMessage(address, payload,
                                              servers1, servers2)
 
         self.sendMessages([message], firstHop)
@@ -915,7 +915,7 @@
     configFile = os.path.expanduser(configFile)
 
     if not os.path.exists(configFile):
-        installDefaultConfig(configFile)    
+        installDefaultConfig(configFile)
 
     try:
         return ClientConfig(fname=configFile)
@@ -1006,10 +1006,11 @@
     mixminion.Common.configureShredCommand(config)
     mixminion.Crypto.init_crypto(config)
 
-    keystore = ClientKeystore(os.path.expanduser(config['User']['UserDir']))
+    userdir = os.path.expanduser(config['User']['UserDir'])
+    keystore = ClientKeystore(userdir)
     if download != 0:
         keystore.updateDirectory(forceDownload=download)
-    
+
     try:
         path1, path2 = parsePath(keystore, config, path, address, nHops, nSwap)
         LOG.info("Chose path: [%s][%s]",
@@ -1044,7 +1045,7 @@
 
     config = readConfigFile(configFile)
     userdir = os.path.expanduser(config['User']['UserDir'])
-    keystore = ClientKeystore(os.path.expanduser(config['User']['UserDir']))
+    keystore = ClientKeystore(userdir)
 
     for filename in args:
         print "Importing from", filename
@@ -1066,9 +1067,9 @@
             configFile = v
 
     config = readConfigFile(configFile)
+
     userdir = os.path.expanduser(config['User']['UserDir'])
+    keystore = ClientKeystore(userdir)
 
-    keystore = ClientKeystore(os.path.expanduser(config['User']['UserDir']))
-        
     for line in keystore.listServers():
         print line

Index: Common.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Common.py,v
retrieving revision 1.44
retrieving revision 1.45
diff -u -d -r1.44 -r1.45
--- Common.py	5 Jan 2003 04:29:11 -0000	1.44
+++ Common.py	5 Jan 2003 06:49:25 -0000	1.45
@@ -509,7 +509,7 @@
 class LogStream:
     """Replacement for stdout or stderr when running in daemon mode;
        sends all output to log.
-       
+
        We don't actually want to use these; but they keep us from dropping
        prints on the floor.
        """
@@ -616,7 +616,7 @@
         depth = 0
         newEdges = [ ('X', 'X') ] #marker value; will be removed.
         for t, e in edges:
-            # Traverse the edges in order; keep track of how many more 
+            # Traverse the edges in order; keep track of how many more
             # +'s we have seen than -'s.  Whenever that number increases
             # above nMin, add a +.  Whenever that number drops below nMin,
             # add a - ... but if the new edge would cancel out the most
@@ -666,7 +666,7 @@
     def isEmpty(self):
         """Return true iff this set contains no points"""
         return len(self.edges) == 0
-    
+
     def __nonzero__(self):
         """Return true iff this set contains some points"""
         return len(self.edges) != 0
@@ -674,7 +674,7 @@
     def __repr__(self):
         s = [ "(%s,%s)"%(start,end) for start, end in self.getIntervals() ]
         return "IntervalSet([%s])"%",".join(s)
-    
+
     def getIntervals(self):
         """Returns a list of (start,end) tuples for a the intervals in this
            set."""
@@ -682,9 +682,9 @@
         for i in range(0, len(self.edges), 2):
             s.append((self.edges[i][0], self.edges[i+1][0]))
         return s
-            
+
     def _checkRep(self):
-        """Helper function: raises AssertionError if this set's data is 
+        """Helper function: raises AssertionError if this set's data is
            corrupted."""
         assert (len(self.edges) % 2) == 0
         for i in range(0, len(self.edges), 2):
@@ -704,7 +704,7 @@
     def end(self):
         """Return the last point contained in this interval."""
         return self.edges[-1][0]
-        
+
 #----------------------------------------------------------------------
 # SMTP address functionality
 
@@ -814,7 +814,7 @@
 # File helpers.
 
 def readPossiblyGzippedFile(fname, mode='r'):
-    """Read the contents of the file <fname>.  If <fname> ends with ".gz", 
+    """Read the contents of the file <fname>.  If <fname> ends with ".gz",
        treat it as a gzipped file."""
     f = None
     try:

Index: Config.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Config.py,v
retrieving revision 1.30
retrieving revision 1.31
diff -u -d -r1.30 -r1.31
--- Config.py	3 Jan 2003 08:25:47 -0000	1.30
+++ Config.py	5 Jan 2003 06:49:25 -0000	1.31
@@ -278,7 +278,7 @@
     m = _time_re.match(s.strip())
     if not m:
         raise ConfigError("Invalid time %r" % s)
-    
+
     yyyy, MM, dd, hh, mm, ss = map(int, m.groups())
     if not ((1 <= dd <= 31) and (1 <= MM <= 12) and
             (1970 <= yyyy)  and (0 <= hh < 24) and
@@ -367,7 +367,7 @@
                 raise ConfigError("Unknown section at line %s" % lineno)
 
     return sections
-    
+
 def _readRestrictedConfigFile(contents):
     # List of (heading, [(key, val, lineno), ...])
     sections = []
@@ -399,13 +399,13 @@
             colonIdx = line.find(':')
             if colonIdx >= 1:
                 try:
-                    curSection.append( (line[:colonIdx].strip(), 
+                    curSection.append( (line[:colonIdx].strip(),
                                         line[colonIdx+1:].strip(), lineno) )
                 except AttributeError:
                     raise ConfigError("Unknown section at line %s" % lineno)
             else:
                 raise ConfigError("Bad Entry at line %s" % lineno)
-        
+
     return sections
 
 def _formatEntry(key,val,w=79,ind=4):
@@ -590,7 +590,7 @@
                     if rule in ('REQUIRE', 'REQUIRE*'):
                         raise ConfigError("Missing entry %s from section %s"
                                           % (k, secName))
-                    else:                   
+                    else:
                         if parseFn is None or default is None:
                             if rule == 'ALLOW*':
                                 section[k] = []

Index: ServerInfo.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ServerInfo.py,v
retrieving revision 1.32
retrieving revision 1.33
diff -u -d -r1.32 -r1.33
--- ServerInfo.py	5 Jan 2003 04:29:11 -0000	1.32
+++ ServerInfo.py	5 Jan 2003 06:49:25 -0000	1.33
@@ -86,7 +86,7 @@
              <string>.
 
            If assumeValid is true, don't bother to validate it.
-           
+
            If the (computed) digest of this descriptor is a key of the dict
               validatedDigests, assume we have already validated it, and
               pass it along.
@@ -101,7 +101,7 @@
 
     def validate(self, sections, entries, lines, contents):
         ####
-        # Check 'Server' section.               
+        # Check 'Server' section.
         server = sections['Server']
         if server['Descriptor-Version'] != '0.1':
             raise ConfigError("Unrecognized descriptor version %r",
@@ -143,7 +143,7 @@
             signedDigest = pk_check_signature(server['Signature'], identityKey)
         except CryptoError:
             raise ConfigError("Invalid signature")
-        
+
         if digest != signedDigest:
             raise ConfigError("Signed digest is incorrect")
 
@@ -177,7 +177,7 @@
         """Returns the declared (not computed) digest of this server
            descriptor."""
         return self['Server']['Digest']
-    
+
     def getAddr(self):
         """Returns this server's IP address"""
         return self['Server']['IP']
@@ -241,7 +241,7 @@
         assert startAt < endAt
         return (self['Server']['Valid-After'] <= startAt and
                 endAt <= self['Server']['Valid-Until'])
-    
+
     def isValidAtPartOf(self, startAt, endAt):
         """Return true iff this ServerInfo is valid at some time between
            'startAt' and 'endAt'."""
@@ -293,7 +293,7 @@
            If validatedDigests is provided, it must be a dict whose keys
            are the digests of already-validated descriptors.  Any descriptor
            whose (calculated) digest matches doesn't need to be validated
-           again.           
+           again.
         """
         if string:
             contents = string
@@ -304,7 +304,7 @@
 
         # First, get the digest.  Then we can break everything up.
         digest = _getDirectoryDigestImpl(contents)
-        
+
         # This isn't a good way to do this, but what the hey.
         sections = _server_header_re.split(contents)
         del contents
@@ -365,13 +365,13 @@
         identityBytes = identityKey.get_modulus_bytes()
         if not (MIN_IDENTITY_BYTES <= identityBytes <= MAX_IDENTITY_BYTES):
             raise ConfigError("Invalid length on identity key")
-        
+
         # Now, at last, we check the digest
         if self.expectedDigest != sig['DirectoryDigest']:
             raise ConfigError("Invalid digest")
 
         try:
-            signedDigest = pk_check_signature(sig['DirectorySignature'], 
+            signedDigest = pk_check_signature(sig['DirectorySignature'],
                                               identityKey)
         except CryptoError:
             raise ConfigError("Invalid signature")
@@ -427,7 +427,7 @@
 
     if rsa is None:
         return digest
-    
+
     signature = mixminion.Crypto.pk_sign(digest,rsa)
     digest = formatBase64(digest)
     signature = formatBase64(signature)
@@ -448,5 +448,5 @@
 
 _dir_special_line_re = re.compile(r'^Directory(?:Digest|Signature):.*$', re.M)
 def _getDirectoryDigestImpl(directory, rsa=None):
-    return _getDigestImpl(directory, _dir_special_line_re, 
+    return _getDigestImpl(directory, _dir_special_line_re,
                           "DirectoryDigest", "DirectorySignature", rsa)

Index: benchmark.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/benchmark.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- benchmark.py	5 Jan 2003 05:51:49 -0000	1.23
+++ benchmark.py	5 Jan 2003 06:49:25 -0000	1.24
@@ -260,7 +260,7 @@
     asn1 = rsa.encode_key(1)
     print "RSA from ASN1 (public)", \
           timeit(lambda asn1=asn1: pk_decode_public_key(asn1), 10000)
-          
+
     print "RSA generate (1024 bit,e=65535)", timeit((lambda: pk_generate(1024,
                                                                   65535)),10)
     rsa = pk_generate()
@@ -356,7 +356,7 @@
         size += os.stat(fname+suffix)[stat.ST_SIZE]
 
     print "File size (%s entries)"%load, spacestr(size)
-    
+
 #----------------------------------------------------------------------
 def directoryTiming():
     print "#========== DESCRIPTORS AND DIRECTORIES =============="
@@ -384,7 +384,7 @@
 ##     for _ in xrange(2000):
 ##         ServerInfo(string=desc, assumeValid=0)
 ##     if 1: return
-    
+
     print "Parse server descriptor (no validation)", \
           timeit(lambda desc=desc: ServerInfo(string=desc,assumeValid=1),
                  400)
@@ -398,7 +398,7 @@
     dtxt = cPickle.dumps(info, 0)
     print "Unpickle text-pickled descriptor (%s/%s)"%(len(dtxt),len(desc)), \
           timeit(lambda dtxt=dtxt: cPickle.loads(dtxt), 400)
-    
+
 #----------------------------------------------------------------------
 
 def buildMessageTiming():
@@ -423,7 +423,7 @@
     compressed = compressData("Hello!!!"*(128*28))
     print "Unompress (28K, 28K max)", \
           timeit(lambda c=compressed: uncompressData(c, 28<<10), 1000)
-    
+
     payload = ("Junky qoph flags vext crwd zimb."*1024)[:22*1024]
     serverinfo = [FakeServerInfo("127.0.0.1", 48099, pk,"x"*20)
                   ] * 16
@@ -458,7 +458,7 @@
     bm(8,1,40)
     bm(8,8,20)
     bm(16,16,10)
-    
+
 #----------------------------------------------------------------------
 class DummyLog:
     def seenHash(self,h): return 0

Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.60
retrieving revision 1.61
diff -u -d -r1.60 -r1.61
--- test.py	5 Jan 2003 04:29:11 -0000	1.60
+++ test.py	5 Jan 2003 06:49:25 -0000	1.61
@@ -282,7 +282,7 @@
                 [(1,4),(5,8),(9,21),(25,55)])
         checkEq(fromPrimeToPrime+fromFibToFib,
                 [(2,3),(5,8),(11,21),(23,29),(34,55)])
-        
+
         # Now, subtraction!
         #  1. Involving nil.
         checkEq(nil-nil, nil, [])
@@ -316,7 +316,7 @@
             for b in (fromPrimeToPrime, fromSquareToSquare, fromFibToFib, nil):
                 checkEq(a-b+b, a+b)
                 checkEq(a+b-b, a-b)
-        
+
         ## Test intersection
         # 1. With nil
         checkEq(nil*nil, nil*fromFibToFib, oneToTen*nil, nil, [])
@@ -333,7 +333,7 @@
         checkEq(oneToTen*oneToTwenty, oneToTwenty*oneToTen, oneToTen)
         checkEq(tenToTwenty*oneToTwenty, oneToTwenty*tenToTwenty, tenToTwenty)
         # 7. A and B overlap without containment.
-        checkEq(fifteenToFifty*oneToTwenty, oneToTwenty*fifteenToFifty, 
+        checkEq(fifteenToFifty*oneToTwenty, oneToTwenty*fifteenToFifty,
                 [(15,20)])
         # 8. Tricky cases
         checkEq(fromPrimeToPrime*fromSquareToSquare,
@@ -349,7 +349,7 @@
         for a in (fromPrimeToPrime, fromSquareToSquare, fromFibToFib, oneToTen,
                   fifteenToFifty, nil):
             self.assert_((not a) == a.isEmpty() == (a == nil))
-            for b in (fromPrimeToPrime, fromSquareToSquare, fromFibToFib, 
+            for b in (fromPrimeToPrime, fromSquareToSquare, fromFibToFib,
                       oneToTen, fifteenToFifty, nil):
                 checkEq(a*b,b*a)
                 checkEq(a-b, a*(a-b), (a-b)*a)
@@ -578,7 +578,7 @@
         self.assert_(pk_same_public_key(p, p))
         self.assert_(not pk_same_public_key(p, getRSAKey(2,1024)))
         self.assert_(len(pk_fingerprint(p))==40)
-        self.assertNotEquals(pk_fingerprint(p), 
+        self.assertNotEquals(pk_fingerprint(p),
                              pk_fingerprint(getRSAKey(2,1024)))
         ####
         # Test key encoding
@@ -1842,7 +1842,7 @@
         nils = "\x00"*(25*1024)
         overcompressed_payload = \
              BuildMessage._encodePayload(nils, 0, AESCounterPRNG())
-        self.failUnlessRaises(BuildMessage.CompressedDataTooLong, 
+        self.failUnlessRaises(BuildMessage.CompressedDataTooLong,
              BuildMessage.decodePayload, overcompressed_payload, "X"*20)
 
         # And now the cases that fail hard.  This can only happen on:
@@ -2632,7 +2632,7 @@
 
         for _ in xrange(3):
             server.process(0.1)
-        
+
         self.failUnless(messagesIn == messages)
 
         # Now, with bad keyid.
@@ -2672,8 +2672,8 @@
         t.start()
         while len(messagesIn) < 2:
             if c is None and len(server.readers) > 1:
-                c = [ c for c in server.readers.values() if 
-                      isinstance(c, tlscon) ] 
+                c = [ c for c in server.readers.values() if
+                      isinstance(c, tlscon) ]
             server.process(0.1)
         while t.isAlive():
             server.process(0.1)
@@ -2781,7 +2781,7 @@
         self.assert_(isinstance(excList[0][1], _ml.TLSClosed))
 
         for _ in xrange(3):
-            server.process(0.1)        
+            server.process(0.1)
 
 #----------------------------------------------------------------------
 # Config files
@@ -3007,7 +3007,7 @@
         self.assert_(floatEq(SC._parseFraction("0%"), 0))
         # Mix algorithms
         self.assertEquals(SC._parseMixRule(" Cottrell"), "CottrellMixQueue")
-        self.assertEquals(SC._parseMixRule("binomialCottrell"), 
+        self.assertEquals(SC._parseMixRule("binomialCottrell"),
                           "BinomialCottrellMixQueue")
         self.assertEquals(SC._parseMixRule("TIMED"), "TimedMixQueue")
 
@@ -3177,25 +3177,25 @@
         self.assert_(not info.isValidAt(time.time()+24*60*60*30))
 
         self.assert_(info.isValidFrom(time.time(), time.time()+60*60))
-        self.assert_(not info.isValidFrom(time.time()-25*60*60, 
+        self.assert_(not info.isValidFrom(time.time()-25*60*60,
                                           time.time()+60*60))
-        self.assert_(not info.isValidFrom(time.time()-25*60*60, 
+        self.assert_(not info.isValidFrom(time.time()-25*60*60,
                                           time.time()+24*60*60*30))
-        self.assert_(not info.isValidFrom(time.time(), 
+        self.assert_(not info.isValidFrom(time.time(),
                                           time.time()+24*60*60*30))
-        self.assert_(not info.isValidFrom(time.time()-25*60*60, 
+        self.assert_(not info.isValidFrom(time.time()-25*60*60,
                                           time.time()-23*60*60))
         self.assert_(not info.isValidFrom(time.time()+24*60*60*30,
                                           time.time()+24*60*60*31))
-        
+
         self.assert_(info.isValidAtPartOf(time.time(), time.time()+60*60))
-        self.assert_(info.isValidAtPartOf(time.time()-25*60*60, 
+        self.assert_(info.isValidAtPartOf(time.time()-25*60*60,
                                           time.time()+60*60))
-        self.assert_(info.isValidAtPartOf(time.time()-25*60*60, 
+        self.assert_(info.isValidAtPartOf(time.time()-25*60*60,
                                           time.time()+24*60*60*30))
-        self.assert_(info.isValidAtPartOf(time.time(), 
+        self.assert_(info.isValidAtPartOf(time.time(),
                                           time.time()+24*60*60*30))
-        self.assert_(not info.isValidAtPartOf(time.time()-40*60*60, 
+        self.assert_(not info.isValidAtPartOf(time.time()-40*60*60,
                                               time.time()-39*60*60))
         self.assert_(not info.isValidAtPartOf(time.time()+24*60*60*30,
                                               time.time()+24*60*60*31))
@@ -3211,7 +3211,7 @@
         inf2 = inf2.replace("b.c\n", "b.c\r\n")
         inf2 = inf2.replace("0.1\n", "0.1  \n")
         mixminion.ServerInfo.ServerInfo(string=inf2)
-        
+
         # Now make sure everything was saved properly
         keydir = os.path.join(d, "key_key1")
         eq(inf, readFile(os.path.join(keydir, "ServerDesc")))
@@ -3295,7 +3295,7 @@
         baseDir = mix_mktemp()
         dirArchiveDir = os.path.join(baseDir, "dirArchive")
         lst = ServerList(baseDir)
-        
+
         identity = Crypto.pk_generate(2048)
 
         now = time.time()
@@ -3367,12 +3367,12 @@
 
         # Now try cleaning servers.   First, make sure we can't insert
         # an expired server.
-        self.failUnlessRaises(MixError, 
+        self.failUnlessRaises(MixError,
                               lst.importServerInfo, examples["Fred"][0])
         # Now, make sure we can't insert a superseded server.
         lst.importServerInfo(examples["Bob"][3])
         lst.importServerInfo(examples["Bob"][4])
-        self.failUnlessRaises(MixError, 
+        self.failUnlessRaises(MixError,
                               lst.importServerInfo, examples["Bob"][1])
         # Now, start with a fresh list, so we can try superceding bob later.
         baseDir = mix_mktemp()
@@ -3402,7 +3402,7 @@
         self.failUnlessRaises(MixError, lst.importServerInfo,
                               examples["Bob"][0], 1)
 
-        ### Now test the removal of superceded servers.  
+        ### Now test the removal of superceded servers.
         # Clean out archiveDir first so we can see what gets removed.
         os.unlink(os.path.join(archiveDir, os.listdir(archiveDir)[0]))
         # Add a bunch of unconflicting Bobs.
@@ -3593,7 +3593,7 @@
         # (first, erase the pending message.)
         manager.queues[exampleMod.getName()].removeAll()
         manager.queues[exampleMod.getName()]._rescan()
-        
+
         p = "For whom is the funhouse fun?"*8192
         msg = mixminion.BuildMessage._encodePayload(
             p, 0, Crypto.getCommonPRNG())
@@ -3602,7 +3602,7 @@
         self.assertEquals(len(exampleMod.processedAll), 0)
         manager.sendReadyMessages()
         self.assertEquals(len(exampleMod.processedAll), 1)
-        self.assertEquals(exampleMod.processedAll[0], 
+        self.assertEquals(exampleMod.processedAll[0],
             (BuildMessage.compressData(p), 'long', 1234, "Buenas noches"))
 
         # Check serverinfo generation.
@@ -3744,7 +3744,7 @@
         def hasNo(set, item, self=self):
             self.assert_(isSMTPMailbox(item), "Invalid address "+item)
             self.failIf(set.contains(item), "Set should not contain "+item)
-            
+
         # Basic functionality: Match what we're supposed to match
         set = EmailAddressSet(string=EXAMPLE_ADDRESS_SET)
         for _ in 1,2:
@@ -3807,7 +3807,7 @@
         bad("user")
         bad("pattern")
         bad("subdomains")
-    
+
     def testMixmasterSMTP(self):
         """Check out the SMTP-Via-Mixmaster module.  (We temporarily relace
            os.spawnl with a stub function so that we don't actually send
@@ -3859,24 +3859,24 @@
            with a stub function so that we don't actually send anything.)"""
         blacklistFile = mix_mktemp()
         writeFile(blacklistFile, "Domain wangafu.net\nUser fred\n")
-        
+
         manager = self.getManager("""[Delivery/SMTP]
 Enabled: yes
 SMTPServer: nowhere
 BlacklistFile: %s
-Message: Avast ye mateys!  Prepare to be anonymized!  
+Message: Avast ye mateys!  Prepare to be anonymized!
 ReturnAddress: yo.ho.ho@bottle.of.rum
 SubjectLine: Arr! This be a Type-III Anonymous Message
         """ % blacklistFile)
-        
+
         module = manager.nameToModule["SMTP"]
         queue = manager.queues["SMTP"]
         queueMessage = queue.queueDeliveryMessage
-                        
+
 
         # Make sure blacklist got read.
         self.assert_(module.blacklist.contains("nobody@wangafu.net"))
-        
+
         # Stub out sendSMTPMessage.
         replaceFunction(mixminion.server.Modules, 'sendSMTPMessage',
                         lambda *args: mixminion.server.Modules.DELIVER_OK)
@@ -3884,7 +3884,7 @@
             haiku = ("Hidden, we are free\n"+
                      "Free to speak, to free ourselves\n"+
                      "Free to hide no more.")
-            
+
             # Try queueing a valild message and sending it.
             queueMessage((SMTP_TYPE, "users@everywhere", None), haiku)
             self.assertEquals(getReplacedFunctionCallLog(), [])
@@ -4207,12 +4207,12 @@
 
         # Test pool configuration
         pool = MixPool(configTimed, mixDir)
-        self.assert_(isinstance(pool.queue, 
+        self.assert_(isinstance(pool.queue,
                                 mixminion.server.Queue.TimedMixQueue))
         self.assertEquals(pool.getNextMixTime(100), 100+2*60*60)
 
         pool = MixPool(configCottrell, mixDir)
-        self.assert_(isinstance(pool.queue, 
+        self.assert_(isinstance(pool.queue,
                                 mixminion.server.Queue.CottrellMixQueue))
         self.assertEquals(pool.getNextMixTime(100), 100+12*60*60)
         self.assertEquals(pool.queue.minPool, 10)
@@ -4220,13 +4220,13 @@
         self.assert_(floatEq(pool.queue.sendRate, .4))
 
         pool = MixPool(configBCottrell, mixDir)
-        self.assert_(isinstance(pool.queue, 
+        self.assert_(isinstance(pool.queue,
                              mixminion.server.Queue.BinomialCottrellMixQueue))
         self.assertEquals(pool.getNextMixTime(100), 100+6*60*60)
         self.assertEquals(pool.queue.minPool, 10)
         self.assertEquals(pool.queue.minSend, 1)
         self.assert_(floatEq(pool.queue.sendRate, .4))
-        
+
         # FFFF test other mix pool behavior
 
 #----------------------------------------------------------------------
@@ -4416,7 +4416,7 @@
             [os.path.join(impdirname, s) for s in
              ("Fred1", "Fred2", "Lola2", "Alice0", "Alice1",
               "Bob3", "Bob4", "Lisa1") ], identity)
-        
+
         # Replace the real URL and fingerprint with the ones we have; for
         # unit testing purposes, we can't rely on an http server.
         mixminion.ClientMain.MIXMINION_DIRECTORY_URL = "file://%s"%fname
@@ -4542,7 +4542,7 @@
             ks2.importFromFile(os.path.join(impdirname, "Alice0"))
             ks2.importFromFile(os.path.join(impdirname, "Lisa1"))
             ks2.importFromFile(os.path.join(impdirname, "Bob0"))
-            
+
             p = ks2.getPath(length=9)
             eq(9, len(p))
             self.failIf(nRuns([s.getNickname() for s in p]))
@@ -4563,7 +4563,7 @@
             self.failIf(nRuns([s.getNickname() for s in p]))
             eq(7, len(p))
             self.assertSameSD(joe[0], p[-1])
-            
+
             # 2c. With 2 servers
             ks2.expungeByNickname("Alice")
             ks2.expungeByNickname("Bob")
@@ -4611,11 +4611,11 @@
         eq(5, len(p))
         self.assertSameSD(p[-1], lola[1]) # Only Lola has MBOX
         self.assertSameSD(p[0], alice[0])
-        
+
         p = ks.getPath(length=5, endCap="mbox", midCap="relay",
                        endServers=("Alice",))
         eq(5, len(p))
-        self.assertSameSD(p[-1], alice[0]) # We ignore endCap with endServers 
+        self.assertSameSD(p[-1], alice[0]) # We ignore endCap with endServers
 
         ### Now try parsePath.  This should exercise resolvePath as well.
         ppath = mixminion.ClientMain.parsePath
@@ -4623,7 +4623,7 @@
         email = paddr("smtp:lloyd@dobler.com")
         mboxWithServer = paddr("mbox:Granola@Lola")
         mboxWithoutServer = paddr("mbox:Granola")
-        
+
         alice = ks.getServerInfo("Alice")
         fred = ks.getServerInfo("Fred")
         bob = ks.getServerInfo("Bob")
@@ -4670,7 +4670,7 @@
         pathIs((p1,p2), ((alice,fred),(bob,lola)))
         p1,p2 = ppath(ks, None, "Alice,Fred,Bob", mboxWithServer, nSwap=0)
         pathIs((p1,p2), ((alice,),(fred,bob,lola)))
-                      
+
         # 1b. Colon, no star
         p1,p2 = ppath(ks, None, "Alice:Fred,Joe", email)
         pathIs((p1,p2), ((alice,),(fred,joe)))
@@ -4686,7 +4686,7 @@
         pathIs((p1,p2), ((alice,bob,fred),(joe,lola)))
         p1,p2 = ppath(ks, None, "Alice,Bob,Fred:Lola", mboxWithoutServer)
         pathIs((p1,p2), ((alice,bob,fred),(lola,)))
-        
+
         # 1c. Star, no colon
         p1,p2 = ppath(ks, None, 'Alice,*,Joe', email, nHops=5)
         self.assert_(allUnique([s.getNickname() for s in p1+p2]))
@@ -4702,7 +4702,7 @@
         self.assert_(allUnique([s.getNickname() for s in p1+p2]))
         pathIs((p1[0],p1[1],p2[-1]), (alice, bob, joe))
         eq((len(p1),len(p2)), (3,3))
-        
+
         p1,p2 = ppath(ks, None, '*,Bob,Joe', email) #default nHops=6
         self.assert_(allUnique([s.getNickname() for s in p1+p2]))
         pathIs((p2[-2],p2[-1]), (bob, joe))
@@ -4717,18 +4717,18 @@
         self.assert_(allUnique([s.getNickname() for s in p1+p2]))
         pathIs((p1[0],p2[-2],p2[-1]), (bob, alice, lola))
         eq((len(p1),len(p2)), (3,3))
-        
+
         # 1d. Star and colon
         p1,p2 = ppath(ks, None, 'Bob:*,Alice', mboxWithServer)
         self.assert_(allUnique([s.getNickname() for s in p1+p2]))
         pathIs((p1[0],p2[-2],p2[-1]), (bob, alice, lola))
         eq((len(p1),len(p2)), (1,5))
-        
+
         p1,p2 = ppath(ks, None, 'Bob,*:Alice', mboxWithServer)
         self.assert_(allUnique([s.getNickname() for s in p1+p2]))
         pathIs((p1[0],p2[-2],p2[-1]), (bob, alice, lola))
         eq((len(p1),len(p2)), (4,2))
-        
+
         p1,p2 = ppath(ks, None, 'Bob,*,Joe:Alice', mboxWithServer)
         self.assert_(allUnique([s.getNickname() for s in p1+p2]))
         pathIs((p1[0],p1[-1],p2[-2],p2[-1]), (bob, joe, alice, lola))
@@ -4772,7 +4772,7 @@
         raises(MixError, ppath, ks, None, "Alice:Bob,Joe", email, nHops=4)
         # Nonexistant file
         raises(MixError, ppath, ks, None, "./Pierre:Alice,*", email)
-        
+
         ## Try 'expungeByNickname'.
         # Zapping 'Lisa' does nothing, since she's in the directory...
         ks.expungeByNickname("Lisa")