[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[minion-cvs] Make pychecker happier
Update of /home/minion/cvsroot/src/minion/lib/mixminion
In directory moria.seul.org:/tmp/cvs-serv27237/lib/mixminion
Modified Files:
ClientMain.py Common.py Config.py Main.py Modules.py Packet.py
ServerInfo.py ServerMain.py test.py
Log Message:
Make pychecker happier
Index: ClientMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ClientMain.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- ClientMain.py 30 Oct 2002 02:19:39 -0000 1.5
+++ ClientMain.py 21 Nov 2002 16:55:48 -0000 1.6
@@ -29,9 +29,9 @@
import getopt
import sys
import time
-import bisect
-from mixminion.Common import getLog, floorDiv, createPrivateDir, MixError
+from mixminion.Common import getLog, floorDiv, createPrivateDir, MixError, \
+ MixFatalError
import mixminion.Crypto
import mixminion.BuildMessage
import mixminion.MMTPClient
@@ -42,6 +42,9 @@
class DirectoryCache:
"""Holds a set of directories and serverinfo objects persistently.
+ XXXX THIS CLASS IS NOT USED YET. It's a bad design choice, since
+ the first version of the directory code will mostly obsolete it.
+
FFFF This should actually cache the nickname and liveness information
FFFF rather than parsing and reparsing it each time. Of course, we'll
FFFF want to re-do it entirely once we have directory support, so it
@@ -81,7 +84,7 @@
if info['Server']['Valid-Until'] < now:
getLog().info("Removing expired descriptor for %s",
nickname)
- os.unlink(os.path.join(dirname, fn))
+ os.unlink(os.path.join(self.dirname, fn))
continue
self.allServers.append(info)
if self.servers.has_key(nickname):
@@ -106,7 +109,7 @@
else:
try:
serverList = self.servers[nickname]
- except KeyError, e:
+ except KeyError, _:
raise MixError("Nothing known about server %s"%nickname)
for info in serverList:
#XXXX fail on DNE
@@ -232,7 +235,7 @@
createPrivateDir(userdir)
createPrivateDir(os.path.join(userdir, 'surbs'))
- # Get directory cache
+ # Get directory cache FFFF (not used yet!)
self.dirCache = DirectoryCache(os.path.join(userdir,
'directory', 'servers'))
self.dirCache.load()
@@ -260,7 +263,7 @@
getLog().warn("I only know about %s servers; That's not enough to use distinct servers on your path.", len(servers))
result = []
while len(result) < length:
- result.extend(prng.shuffle(servers))
+ result.extend(self.prng.shuffle(servers))
return result[:length]
else:
return self.prng.shuffle(servers, length)
@@ -280,7 +283,7 @@
return serverList
- def sendForwardMessage(self, routingType, routingInfo, payload,
+ def sendForwardMessage(self, address, payload,
serverList=None):
message, firstHop = self.generateForwardMessage(address,
payload,
@@ -299,7 +302,7 @@
time.time(), time.time()+24*60*60,
serverList)
- firstPathlen = floorDiv(len(serverList), 2)
+ firstPathLen = floorDiv(len(serverList), 2)
servers1,servers2 = serverList[:firstPathLen],serverList[firstPathLen:]
routingType, routingInfo, lastHop = address.getRouting()
@@ -331,13 +334,13 @@
# XXXX Out of sync with spec.
raise MixFatalError("Not implemented")
- handle = Crypto.getBytes(16)
+ handle = mixminion.Crypto.getBytes(16)
rt, ri, lastHop = address.getRouting("RTRN"+handle)
if lastHop is not None:
path.append(lastHop)
- block, secrets = mixminion.BuildMesssage.buildReplyBlock(path, rt, ri,
- endAt,
- self.prng)
+ block, secrets = mixminion.BuildMessage.buildReplyBlock(path, rt, ri,
+ endAt,
+ self.prng)
# XXXX Store secrets and expiry time
return block
@@ -421,7 +424,6 @@
sys.exit(1)
config = readConfigFile(os.path.expanduser(configFile))
- getLog().setMinSeverity("INFO")
mixminion.Crypto.init_crypto(config)
if len(args) < 2:
print >> sys.stderr, "I need at least 2 servers"
Index: Common.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Common.py,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- Common.py 30 Oct 2002 02:19:39 -0000 1.23
+++ Common.py 21 Nov 2002 16:55:49 -0000 1.24
@@ -214,7 +214,7 @@
if not os.path.exists(parent):
createPrivateDir(parent)
self.file = open(self.fname, 'a')
- except OSError, e:
+ except OSError, _:
self.file = None
raise MixError("Unable to open log file %r"%self.fname)
def close(self):
Index: Config.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Config.py,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- Config.py 30 Oct 2002 02:19:39 -0000 1.18
+++ Config.py 21 Nov 2002 16:55:49 -0000 1.19
@@ -147,7 +147,7 @@
if not _ip_re.match(i):
raise ConfigError("Invalid IP %r" % i)
try:
- f = socket.inet_aton(i)
+ socket.inet_aton(i)
except socket.error, _:
raise ConfigError("Invalid IP %r" % i)
Index: Main.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Main.py,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- Main.py 16 Oct 2002 23:12:12 -0000 1.5
+++ Main.py 21 Nov 2002 16:55:49 -0000 1.6
@@ -28,7 +28,6 @@
wind up somewhere appropriate on pythonpath. This isn't good enough,
however: we want to run even when sysadmins don't understand distutils.)
"""
- import os
orig_cmd = myself
# First, resolve all links.
Index: Modules.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Modules.py,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -d -r1.14 -r1.15
--- Modules.py 21 Oct 2002 02:30:14 -0000 1.14
+++ Modules.py 21 Nov 2002 16:55:49 -0000 1.15
@@ -348,7 +348,7 @@
self.nickname = socket.gethostname()
self.addr = config['Server'].get('IP', "<Unknown host>")
- f = open(self.addressfile)
+ f = open(self.addressFile)
addresses = f.read()
f.close()
@@ -459,7 +459,7 @@
"""
try:
message = mixminion.BuildMessage.decodePayload(payload, tag)
- except MixError, e:
+ except MixError, _:
return None
if message is None:
Index: Packet.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/Packet.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- Packet.py 16 Oct 2002 23:12:12 -0000 1.13
+++ Packet.py 21 Nov 2002 16:55:49 -0000 1.14
@@ -287,7 +287,10 @@
# a 20-byte message ID, and 4 bytes of message size.
FRAGMENT_UNPACK_PATTERN = "!H%ds%dsL" % (DIGEST_LEN, FRAGMENT_MESSAGEID_LEN)
-class SingletonPayload:
+class _Payload:
+ pass
+
+class SingletonPayload(_Payload):
"""Represents the payload for a standalone mixminion message.
Fields: size, hash, data. (Note that data is padded.)"""
def __init__(self, size, hash, data):
@@ -314,7 +317,7 @@
header = struct.pack(SINGLETON_UNPACK_PATTERN, self.size, self.hash)
return "%s%s" % (header, self.data)
-class FragmentPayload:
+class FragmentPayload(_Payload):
"""Represents the fields of a decoded fragment payload."""
def __init__(self, index, hash, msgID, msgLen, data):
self.index = index
Index: ServerInfo.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ServerInfo.py,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- ServerInfo.py 30 Oct 2002 02:40:13 -0000 1.17
+++ ServerInfo.py 21 Nov 2002 16:55:49 -0000 1.18
@@ -239,6 +239,7 @@
serverKeys.mmtpKey = mmtpKey
serverKeys.save()
+ # XXXX unused
allowIncoming = config['Incoming/MMTP'].get('Enabled', 0)
nickname = config['Server']['Nickname']
@@ -421,9 +422,9 @@
ip_set = {}
try:
ip_set[ socket.gethostbyname(socket.gethostname()) ] = 1
- except socket.error, host_error:
+ except socket.error, _:
try:
- ip_by_host = socket.gethostbyname(socket.getfqdn())
+ ip_set[ socket.gethostbyname(socket.getfqdn()) ] = 1
except socket.error, _:
pass
Index: ServerMain.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/ServerMain.py,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -d -r1.11 -r1.12
--- ServerMain.py 30 Oct 2002 02:19:39 -0000 1.11
+++ ServerMain.py 21 Nov 2002 16:55:49 -0000 1.12
@@ -128,7 +128,7 @@
def getIdentityKey(self):
"""Return this server's identity key. Generate one if it doesn't
exist."""
- password = None # FFFF
+ password = None # FFFF unused
fn = os.path.join(self.keyDir, "identity.key")
bits = self.config['Server']['IdentityKeyBits']
if os.path.exists(fn):
@@ -163,9 +163,9 @@
firstKey, lastKey = self.keyRange
- for i in xrange(num):
+ for _ in xrange(num):
if firstKey == sys.maxint:
- keynum = firstkey = lastkey = 1
+ keynum = firstKey = lastKey = 1
elif firstKey > 1:
firstKey -= 1
keynum = firstKey
@@ -479,7 +479,7 @@
def usageAndExit(cmd):
executable = sys.argv[0]
# XXXX show versioning info
- print >>sys.stderr, "Usage: %s [-h] [-f configfile]" % cmd
+ print >>sys.stderr, "Usage: %s %s [-h] [-f configfile]" % (executable, cmd)
sys.exit(0)
def configFromServerArgs(cmd, args):
Index: test.py
===================================================================
RCS file: /home/minion/cvsroot/src/minion/lib/mixminion/test.py,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- test.py 30 Oct 2002 02:25:19 -0000 1.35
+++ test.py 21 Nov 2002 16:55:49 -0000 1.36
@@ -17,7 +17,6 @@
import sys
import threading
import time
-import types
import re
import base64
import stat
@@ -241,7 +240,6 @@
_ml.openssl_seed("")
def test_oaep(self):
- import mixminion.Crypto as Crypto
_add = Crypto._add_oaep_padding
_check = Crypto._check_oaep_padding
for add,check in ((_ml.add_oaep_padding, _ml.check_oaep_padding),