[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/directory
In directory moria.mit.edu:/tmp/cvs-serv684/lib/mixminion/directory
Modified Files:
DirMain.py ServerList.py
Log Message:
Normalize EOL whitespace and add a target to do so for us in the future.
Index: DirMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/directory/DirMain.py,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- DirMain.py 5 Jan 2003 04:29:11 -0000 1.3
+++ DirMain.py 5 Jan 2003 06:49:25 -0000 1.4
@@ -19,7 +19,7 @@
pk_PEM_load, pk_PEM_save
from mixminion.directory.ServerList import ServerList
-USAGE = """%s -d <directory> command
+USAGE = """%s -d <directory> command
Where 'command' is one of:
import <serverinfo> [Import a descriptor for a known server]
import-new <serverinfo> [Import a descriptor for a new server]
@@ -41,7 +41,7 @@
return key
else:
return pk_PEM_load(fname)
-
+
def usageAndExit(cmd):
"""Print a usage message and exit"""
print >>sys.stderr, USAGE%cmd
@@ -63,7 +63,7 @@
if len(rest) != 0: usageAndExit(cmd)
lst = ServerList(base)
key = getIdentity(base)
- # XXXX Until we have support for automatic directory generation, we
+ # XXXX Until we have support for automatic directory generation, we
# XXXX set the validity time to be pretty long: 2 months.
now = time.time()
twoMonthsLater = now + 60*60*24*30*2
@@ -95,7 +95,7 @@
shutil.copy(fname, rest[0])
print >>sys.stderr, "Exported."
-def cmd_remove(cmd, base, rest):
+def cmd_remove(cmd, base, rest):
if len(rest) != 1: usageAndExit(cmd)
lst = ServerList(base)
lst.expungeServersByNickname(rest[0])
Index: ServerList.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/directory/ServerList.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ServerList.py 4 Jan 2003 04:12:51 -0000 1.5
+++ ServerList.py 5 Jan 2003 06:49:25 -0000 1.6
@@ -4,7 +4,7 @@
"""mixminion.directory.ServerList
Implements a store of sererinfos for a diectory.
-
+
FFFF Right now, this is about maximally slow. There are a lot of tricks
FFFF we could do to speed it up: not revalidating servers in our cache;
FFFF pickling serverinfo objects for easy access, and so on. But
@@ -21,7 +21,7 @@
from mixminion.Crypto import pk_encode_public_key, pk_same_public_key
from mixminion.Common import IntervalSet, LOG, MixError, createPrivateDir, \
formatBase64, formatDate, formatFnameTime, formatTime, openUnique, \
- previousMidnight, readPossiblyGzippedFile, stringContains
+ previousMidnight, readPossiblyGzippedFile, stringContains
from mixminion.Config import ConfigError
from mixminion.ServerInfo import ServerDirectory, ServerInfo, \
_getDirectoryDigestImpl
@@ -36,7 +36,7 @@
-- it is inconsistent (We already know a descriptor for this
nickname, with a different identity key.)
[FFFF This check will become stricter in the future.]
-
+
This implementation isn't terribly optimized, but there's no need to
optimize it until we have far more descriptors to worry about.
"""
@@ -76,17 +76,17 @@
createPrivateDir(self.archiveDir)
createPrivateDir(self.dirArchiveDir)
self.rescan()
-
+
def importServerInfo(self, server, knownOnly=0):
"""Insert a ServerInfo into the list. If the server is expired, or
- superseded, or inconsistent, raise a MixError.
-
+ superseded, or inconsistent, raise a MixError.
+
server -- a string containing the descriptor, or the name of a
file containing the descriptor (possibly gzip'd)
knownOnly -- if true, raise MixError is we don't already have
a descriptor with this nickname.
"""
- # Raises ConfigError, MixError,
+ # Raises ConfigError, MixError,
if stringContains(server, "[Server]"):
contents = server
else:
@@ -119,7 +119,7 @@
if server.isSupersededBy(
[ self.servers[fn] for fn in self.serversByNickname[nickname]]):
raise MixError("Server descriptor is superseded")
-
+
newFile = nickname+"-"+formatFnameTime()
f, newFile = openUnique(os.path.join(self.serverDir, newFile))
newFile = os.path.split(newFile)[1]
@@ -172,7 +172,7 @@
f = open(os.path.join(self.serverDir, fn), 'r')
contents.append(f.read())
f.close()
-
+
#FFFF Support for multiple signatures
header = """\
[Directory]
@@ -184,8 +184,8 @@
DirectoryIdentity: %s
DirectoryDigest:
DirectorySignature:
- """ % (formatTime(publicationTime),
- formatDate(startAt),
+ """ % (formatTime(publicationTime),
+ formatDate(startAt),
formatDate(endAt),
formatBase64(pk_encode_public_key(identityKey)))
@@ -203,7 +203,7 @@
for s in parsed.getServers():
foundDigests[s['Server']['Digest']] = 1
assert foundDigests == includedDigests
-
+
f = open(os.path.join(self.baseDir, "directory"), 'w')
f.write(directory)
f.close()
@@ -228,7 +228,7 @@
removed = {} # Map from filename->whyRemoved
# Find all superseded servers
for name, servers in self.serversByNickname.items():
- servers = [ (self.servers[fn]['Server']['Published'],
+ servers = [ (self.servers[fn]['Server']['Published'],
fn, self.servers[fn]) for fn in servers ]
servers.sort()
fns = [ fn for _, fn, _ in servers]
@@ -245,7 +245,7 @@
# The descriptor is expired.
name = s.getNickname()
removed[fn] = "expired"
-
+
# This is a kinda nasty hack: we never remove the last descriptor for
# a given nickname. If we did, we would lose track of the server's
# identity key.
@@ -253,16 +253,16 @@
nRemoved = len([fn for fn in fns if removed.has_key(fn)])
if nRemoved < len(fns):
continue
- # We're about to remove all the descriptors--that's bad!
- # We find the most recent one, and remove it from but
- servers = [ (self.servers[fn]['Server']['Published'],
+ # We're about to remove all the descriptors--that's bad!
+ # We find the most recent one, and remove it from but
+ servers = [ (self.servers[fn]['Server']['Published'],
fn, self.servers[fn]) for fn in fns ]
servers.sort()
fn = servers[-1][1]
LOG.info("Retaining %s descriptor %s -- it's the last one for %s",
removed[fn], fn, name)
del removed[fn]
-
+
# Now, do the actual removing.
for fn, why in removed.items():
LOG.info("Removing %s descriptor %s", why, fn)
@@ -271,8 +271,8 @@
del self.servers[fn]
- self.__buildNicknameMap()
-
+ self.__buildNicknameMap()
+
def rescan(self):
"""Reconstruct this ServerList object's internal state."""
self.servers = {}