[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[minion-cvs] Finish implementation and tests for directories and pat...
Update of /home/minion/cvsroot/src/minion/lib/mixminion/directory
In directory moria.mit.edu:/tmp/cvs-serv16537/src/minion/lib/mixminion/directory
Modified Files:
ServerList.py
Log Message:
Finish implementation and tests for directories and path selection.
BuildMessage:
- Raise an error if either leg of the path is empty
ClientMain:
- Debug client-side directory and path code.
- Add a magic string to cache files so we can update later.
- Add code to actually *call* downloadDirectory.
- Remove last vestiges of 'TrivialKeystore'.
Common:
- Add 'start' and 'end' to IntervalSet
Common, ServerList:
- Move openUnique from ServerList to Common
ClientMain, ServerInfo, ServerDirectory:
- Keep a dict of the digests we've already validated, so we
don't need to do N RSA-checks every time we download a directory.
test:
- Tests for client path selection logic
- Tests for client keystore
- Tests for formatFnameTime
- Tests for openUnique
- Adapt tests for MixminionClient to use new interface.
Index: ServerList.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/directory/ServerList.py,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- ServerList.py 3 Jan 2003 08:47:28 -0000 1.4
+++ ServerList.py 4 Jan 2003 04:12:51 -0000 1.5
@@ -20,8 +20,8 @@
from mixminion.Crypto import pk_encode_public_key, pk_same_public_key
from mixminion.Common import IntervalSet, LOG, MixError, createPrivateDir, \
- formatBase64, formatDate, formatFnameTime, formatTime, previousMidnight, \
- readPossiblyGzippedFile, stringContains
+ formatBase64, formatDate, formatFnameTime, formatTime, openUnique, \
+ previousMidnight, readPossiblyGzippedFile, stringContains
from mixminion.Config import ConfigError
from mixminion.ServerInfo import ServerDirectory, ServerInfo, \
_getDirectoryDigestImpl
@@ -121,7 +121,7 @@
raise MixError("Server descriptor is superseded")
newFile = nickname+"-"+formatFnameTime()
- f, newFile = _openUnique(os.path.join(self.serverDir, newFile))
+ f, newFile = openUnique(os.path.join(self.serverDir, newFile))
newFile = os.path.split(newFile)[1]
f.write(contents)
f.close()
@@ -208,7 +208,7 @@
f.write(directory)
f.close()
- f, _ = _openUnique(os.path.join(self.dirArchiveDir,
+ f, _ = openUnique(os.path.join(self.dirArchiveDir,
"dir-"+formatFnameTime()))
f.write(directory)
f.close()
@@ -297,21 +297,3 @@
for fn, server in self.servers.items():
nickname = server.getNickname()
self.serversByNickname.setdefault(nickname, []).append(fn)
-
-def _openUnique(fname, mode='w'):
- """Helper function. Returns a file open for writing into the file named
- 'fname'. If fname already exists, opens 'fname.1' or 'fname.2' or
- 'fname.3' or so on."""
- # ???? Should this go into common?
- base, rest = os.path.split(fname)
- idx = 0
- while 1:
- try:
- fd = os.open(fname, os.O_WRONLY|os.O_CREAT|os.O_EXCL, 0600)
- return os.fdopen(fd, mode), fname
- except OSError:
- pass
- idx += 1
- fname = os.path.join(base, "%s.%s"%(rest,idx))
-
-