Commit 1f8c2b4c authored by Nick Mathewson's avatar Nick Mathewson 🎨
Browse files

r17224@catbus: nickm | 2007-12-18 00:44:30 -0500

 Appease pychecker, mostly.


svn:r12852
parent c71d03fe
......@@ -9,7 +9,6 @@ import logging
import re
import sha
import socket
import struct
import time
HEX_FP_LEN = 40
......@@ -142,7 +141,7 @@ def parseDescFile(f, bridge_purpose='bridge'):
class BridgeHolder:
def insert(self, bridge):
raise NotImplemented
raise NotImplemented()
def assignmentsArePersistent(self):
return True
......@@ -157,11 +156,11 @@ class BridgeRing(BridgeHolder):
self.name = "Ring"
def __len__(self):
return len(self.bridgesByID)
return len(self.bridges)
def insert(self, bridge):
id = bridge.getID()
pos = self.hmac(id)
ident = bridge.getID()
pos = self.hmac(ident)
if not self.bridges.has_key(pos):
self.sortedKeys.append(pos)
self.isSorted = False
......@@ -196,9 +195,6 @@ class BridgeRing(BridgeHolder):
def getBridgeByID(self, fp):
return self.bridgesByID.get(fp)
def __len__(self):
return len(self.bridges)
class LogDB:
def __init__(self, kwd, db, logfile):
......
......@@ -6,7 +6,6 @@ import bridgedb.Bridges
import logging
import re
import socket
def uniformMap(ip):
"""Map an IP to an arbitrary 'area' string, such that any two /24 addresses
......@@ -153,8 +152,8 @@ class EmailBasedDistributor(bridgedb.Bridges.BridgeHolder):
ids = bridgedb.Bridges.chopString(ids_str, bridgedb.Bridges.ID_LEN)
logging.info("We've seen %r before. Sending the same %d bridges"
" as last time", emailaddress, len(ids))
for id in ids:
b = self.ring.getBridgeByID(id)
for ident in ids:
b = self.ring.getBridgeByID(ident)
if b != None:
result.append(b)
return result
......
......@@ -69,6 +69,7 @@ class WebResource(twisted.web.resource.Resource):
isLeaf = True
def __init__(self, distributor, schedule, N=1):
twisted.web.resource.Resource.__init__(self)
self.distributor = distributor
self.schedule = schedule
self.nBridgesToGive = N
......@@ -87,7 +88,7 @@ class WebResource(twisted.web.resource.Resource):
return HTML_MESSAGE_TEMPLATE % answer
def addWebServer(cfg, dist, sched):
from twisted.web.server import Site
Site = twisted.web.server.Site
resource = WebResource(dist, sched, cfg.HTTPS_N_BRIDGES_PER_ANSWER)
site = Site(resource)
if cfg.HTTP_UNENCRYPTED_PORT:
......@@ -95,7 +96,7 @@ def addWebServer(cfg, dist, sched):
reactor.listenTCP(cfg.HTTP_UNENCRYPTED_PORT, site, interface=ip)
if cfg.HTTPS_PORT:
from twisted.internet.ssl import DefaultOpenSSLContextFactory
from OpenSSL.SSL import SSLv3_METHOD
#from OpenSSL.SSL import SSLv3_METHOD
ip = cfg.HTTP_UNENCRYPTED_BIND_IP or ""
factory = DefaultOpenSSLContextFactory(cfg.HTTPS_KEY_FILE,
cfg.HTTPS_CERT_FILE)
......
......@@ -61,8 +61,8 @@ class IntervalSchedule:
elif self.itype == 'hour':
when = self._intervalStart(when) + 120 #slop
tm = time.gmtime(when)
return "%04d-%02d-%02 %02d" % (tm.tm_year, tm.tm_mon, tm.tm_mday,
tm.tm_hour)
return "%04d-%02d-%02d %02d" % (tm.tm_year, tm.tm_mon, tm.tm_mday,
tm.tm_hour)
else:
assert False
......@@ -75,7 +75,7 @@ class IntervalSchedule:
tm = (n // 12, month+self.count, 1, 0,0,0)
return calendar.timegm(tm)
elif self.itype == 'day':
return self._intervalStart(when) + 86400 * self.coont
return self._intervalStart(when) + 86400 * self.count
elif self.itype == 'hour':
return self._intervalStart(when) + 3600 * self.coont
return self._intervalStart(when) + 3600 * self.count
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment