[or-cvs] r12852: Appease pychecker, mostly. (in bridgedb/trunk: . lib/bridgedb)

nickm at seul.org nickm at seul.org
Tue Dec 18 05:44:46 UTC 2007


Author: nickm
Date: 2007-12-18 00:44:46 -0500 (Tue, 18 Dec 2007)
New Revision: 12852

Modified:
   bridgedb/trunk/
   bridgedb/trunk/lib/bridgedb/Bridges.py
   bridgedb/trunk/lib/bridgedb/Dist.py
   bridgedb/trunk/lib/bridgedb/Server.py
   bridgedb/trunk/lib/bridgedb/Time.py
Log:
 r17224 at catbus:  nickm | 2007-12-18 00:44:30 -0500
 Appease pychecker, mostly.



Property changes on: bridgedb/trunk
___________________________________________________________________
 svk:merge ticket from /bridgedb/trunk [r17224] on 8246c3cf-6607-4228-993b-4d95d33730f1

Modified: bridgedb/trunk/lib/bridgedb/Bridges.py
===================================================================
--- bridgedb/trunk/lib/bridgedb/Bridges.py	2007-12-18 05:36:16 UTC (rev 12851)
+++ bridgedb/trunk/lib/bridgedb/Bridges.py	2007-12-18 05:44:46 UTC (rev 12852)
@@ -9,7 +9,6 @@
 import re
 import sha
 import socket
-import struct
 import time
 
 HEX_FP_LEN = 40
@@ -142,7 +141,7 @@
 
 class BridgeHolder:
     def insert(self, bridge):
-        raise NotImplemented
+        raise NotImplemented()
 
     def assignmentsArePersistent(self):
         return True
@@ -157,11 +156,11 @@
         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,10 +195,7 @@
     def getBridgeByID(self, fp):
         return self.bridgesByID.get(fp)
 
-    def __len__(self):
-        return len(self.bridges)
 
-
 class LogDB:
     def __init__(self, kwd, db, logfile):
         self._kwd = kwd

Modified: bridgedb/trunk/lib/bridgedb/Dist.py
===================================================================
--- bridgedb/trunk/lib/bridgedb/Dist.py	2007-12-18 05:36:16 UTC (rev 12851)
+++ bridgedb/trunk/lib/bridgedb/Dist.py	2007-12-18 05:44:46 UTC (rev 12852)
@@ -6,7 +6,6 @@
 
 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 @@
             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

Modified: bridgedb/trunk/lib/bridgedb/Server.py
===================================================================
--- bridgedb/trunk/lib/bridgedb/Server.py	2007-12-18 05:36:16 UTC (rev 12851)
+++ bridgedb/trunk/lib/bridgedb/Server.py	2007-12-18 05:44:46 UTC (rev 12852)
@@ -69,6 +69,7 @@
     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 @@
         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 @@
         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)

Modified: bridgedb/trunk/lib/bridgedb/Time.py
===================================================================
--- bridgedb/trunk/lib/bridgedb/Time.py	2007-12-18 05:36:16 UTC (rev 12851)
+++ bridgedb/trunk/lib/bridgedb/Time.py	2007-12-18 05:44:46 UTC (rev 12852)
@@ -61,8 +61,8 @@
         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 @@
             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
 



More information about the tor-commits mailing list