[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[minion-cvs] Appease pychecker
Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.mit.edu:/tmp/cvs-serv15281/lib/mixminion
Modified Files:
BuildMessage.py ClientMain.py test.py
Log Message:
Appease pychecker
Index: BuildMessage.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/BuildMessage.py,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -d -r1.27 -r1.28
--- BuildMessage.py 31 Dec 2002 17:47:41 -0000 1.27
+++ BuildMessage.py 3 Jan 2003 08:47:27 -0000 1.28
@@ -664,7 +664,7 @@
except zlibutil.TooBigError:
raise CompressedDataTooLong()
except zlibutil.DecompressError, e:
- raise ParseError("Error in compressed data")
+ raise ParseError("Error in compressed data: %s"%e)
try:
# We can't just call zlib.decompress(payload), since we may
Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -d -r1.19 -r1.20
--- ClientMain.py 3 Jan 2003 08:25:47 -0000 1.19
+++ ClientMain.py 3 Jan 2003 08:47:27 -0000 1.20
@@ -25,7 +25,6 @@
import stat
import sys
import time
-import types
import urllib
import mixminion.BuildMessage
@@ -33,7 +32,7 @@
import mixminion.MMTPClient
from mixminion.Common import IntervalSet, LOG, floorDiv, MixError, \
MixFatalError, ceilDiv, createPrivateDir, isSMTPMailbox, formatDate, \
- formatFnameTime
+ formatFnameTime, readPossiblyGzippedFile
from mixminion.Config import ClientConfig, ConfigError
from mixminion.ServerInfo import ServerInfo, ServerDirectory
from mixminion.Packet import ParseError, parseMBOXInfo, parseSMTPInfo, \
@@ -74,10 +73,9 @@
"""Download a new directory from the network, validate it, and
rescan its servers."""
# Start downloading the directory.
- opener = URLopener()
url = MIXMINION_DIRECTORY_URL
LOG.info("Downloading directory from %s", url)
- infile = FancyURLopener().open(url)
+ infile = urllib.FancyURLopener().open(url)
# Open a temporary output file.
if url.endswith(".gz"):
fname = os.path.join(self.dir, "dir_new.gz")
@@ -105,7 +103,7 @@
# Make sure that the identity is as expected.
identity = directory['Signature']['DirectoryIdentity']
fp = MIXMINION_DIRECTORY_FINGERPRINT
- if fp and pk_fingerprint(identity) != fp:
+ if fp and mixminion.Crypto.pk_fingerprint(identity) != fp:
raise MixFatalError("Bad identity key on directory")
try:
@@ -133,7 +131,6 @@
# Read the servers from the directory.
gzipFile = os.path.join(self.dir, "dir.gz")
dirFile = os.path.join(self.dir, "dir")
- f = None
for fname in gzipFile, dirFile:
if not os.path.exists(fname): continue
self.lastDownload = self.lastModified = \
@@ -143,7 +140,7 @@
except ConfigError:
LOG.warn("Ignoring invalid directory (!)")
continue
- f.close()
+
for s in directory.getServers():
self.serverList.append((s, 'D'))
break
@@ -153,7 +150,7 @@
createPrivateDir(serverDir)
for fn in os.listdir(serverDir):
# Try to read a file: is it a server descriptor?
- p = os.path.join(self.directory, fn)
+ p = os.path.join(serverDir, fn)
try:
info = ServerInfo(fname=p, assumeValid=0)
except ConfigError:
@@ -208,7 +205,8 @@
# Make sure that the identity key is consistent with what we know.
for s, _ in self.serverList:
if s.getNickname() == nickname:
- if not pk_same_public_key(identity, s.getIdentity()):
+ if not mixminion.Crypto.pk_same_public_key(identity,
+ s.getIdentity()):
raise MixError("Identity key changed for server %s in %s",
nickname, filename)
@@ -236,9 +234,10 @@
continue
n += 1
try:
+ fn = source[2:]
os.unlink(os.path.join(self.dir, "servers", fn))
except OSError, e:
- Log.error("Couldn't remove %s", fn)
+ LOG.error("Couldn't remove %s: %s", fn, e)
self.serverList = newList
# Recreate cache if needed.
@@ -441,7 +440,7 @@
# ... and pick one.
LOG.info("Choosing from among %s %s servers",
len(endList), endCap)
- endServers = [ self.prng.pick(endList) ]
+ endServers = [ prng.pick(endList) ]
LOG.debug("Chose %s", endServers[0].getNickname())
nNeeded -= 1
@@ -508,9 +507,9 @@
raise MixError("No relays known")
LOG.info("Chose path: [%s][%s][%s]",
- " ".join([s.getNickname() for n in startServers]),
- " ".join([s.getNickname() for n in midServers]),
- " ".join([s.getNickname() for n in endServers]))
+ " ".join([s.getNickname() for s in startServers]),
+ " ".join([s.getNickname() for s in midServers]),
+ " ".join([s.getNickname() for s in endServers]))
return startServers + midServers + endServers
@@ -998,7 +997,7 @@
def usageAndExit(cmd, error=None):
#XXXX002 correct this.
if error:
- print >>stderr, "ERROR: %s"%error
+ print >>sys.stderr, "ERROR: %s"%error
print >>sys.stderr, """\
Usage: %s [-h] [-v] [-f configfile] [-i inputfile]
[--path1=server1,server2,...]
@@ -1014,7 +1013,6 @@
"to=", "hops=", "swap-at=", "path",
])
configFile = '~/.mixminionrc'
- usage = 0
inFile = "-"
verbose = 0
path = None
@@ -1045,7 +1043,7 @@
elif opt in ('-t', '--to'):
address = parseAddress(val)
if args:
- usageEndExit(cmd,"Unexpected options")
+ usageAndExit(cmd,"Unexpected options")
if address is None:
usageAndExit(cmd,"No recipient specified")
@@ -1091,7 +1089,7 @@
userdir = os.path.expanduser(config['User']['UserDir'])
createPrivateDir(os.path.join(userdir, 'servers'))
- keystore = TrivialKeystore(os.path.join(userdir,"servers"))
+ keystore = ClientKeystore(os.path.expanduser(config['User']['UserDir']))
for line in keystore.listServers():
print line
Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- test.py 3 Jan 2003 08:25:47 -0000 1.54
+++ test.py 3 Jan 2003 08:47:27 -0000 1.55
@@ -3274,9 +3274,6 @@
identity = Crypto.pk_generate(2048)
now = time.time()
- hourLater = now + 60*60
- oneDay = 60*60*24
- hours23 = 60*60*23
dayLater = now + 60*60*24
# Try a couple of simple inserts
lst.importServerInfo(examples["Fred"][1]) # from day -9 through day 0.