]> git.mxchange.org Git - quix0rs-apt-p2p.git/blobdiff - apt_dht/PeerManager.py
Update all tests to add the deferred as both errback and callback.
[quix0rs-apt-p2p.git] / apt_dht / PeerManager.py
index e372f694d432a3d8d63713d156defb419b098358..115edad8cc694931691b33b618a3f6baf1148bd7 100644 (file)
@@ -11,22 +11,22 @@ class PeerManager:
     def __init__(self):
         self.clients = {}
         
-    def get(self, location_list, method="GET"):
+    def get(self, location_list, method="GET", modtime=None):
         """Download from a list of peers.
         
         @type location_list: C{list} of (C{string}, C{int}, C{string})
         @var location_list: a list of the locations where the file can be found
         """
         host, port, path = choice(location_list)
-        return self.getPeer(host, port, path, method)
+        return self.getPeer(host, port, path, method, modtime)
         
-    def getPeer(self, host, port, path, method="GET"):
+    def getPeer(self, host, port, path, method="GET", modtime=None):
         if not port:
             port = 80
         site = host + ":" + str(port)
         if site not in self.clients:
             self.clients[site] = HTTPClientManager(host, port)
-        return self.clients[site].get(path, method)
+        return self.clients[site].get(path, method, modtime)
     
     def close(self):
         for site in self.clients:
@@ -76,7 +76,7 @@ class TestPeerManager(unittest.TestCase):
             d = self.manager.get([(host, 80, path)])
             d.addCallback(self.gotResp, num, expect)
             if last:
-                d.addCallback(lastDefer.callback)
+                d.addBoth(lastDefer.callback)
                 
         newRequest('www.camrdale.org', "/", 1, 3433)
         newRequest('www.camrdale.org', "/blog/", 2, 37121)