]> git.mxchange.org Git - quix0rs-apt-p2p.git/blobdiff - xmlrpcclient.py
now we store and retrieve node information from our database...
[quix0rs-apt-p2p.git] / xmlrpcclient.py
index 230f3ad56762169eae6caa1f2955201fd22d4e70..f8d33b2fb05d7e5bdf1cf24572fa1595bb486be9 100644 (file)
@@ -3,6 +3,7 @@ from twisted.protocols.http import HTTPClient
 from twisted.internet.defer import Deferred
 
 from xmlrpclib import loads, dumps
+import socket
 
 USER_AGENT = 'Python/Twisted XMLRPC 0.1'
 class XMLRPCClient(HTTPClient):
@@ -17,9 +18,13 @@ class XMLRPCClient(HTTPClient):
         self.transport.write('\r\n')
        
     def handleResponse(self, buf):
-       args, name = loads(buf)
-       apply(self.d.callback, args)
-
+       try:
+           args, name = loads(buf)
+       except Exception, e:
+           print "response decode error: " + `e`
+           self.d.errback()
+       else:
+           apply(self.d.callback, args)
 
 class XMLRPCClientFactory(ClientFactory):
     def __init__(self, method, args, callback=None, errback=None):
@@ -30,10 +35,14 @@ class XMLRPCClientFactory(ClientFactory):
            self.d.addCallback(callback)
        if errback:
            self.d.addErrback(errback)
-           
+        self.noisy = 0
+        
     def buildProtocol(self, addr):
         prot =  XMLRPCClient()
        prot.method = self.method
        prot.args = self.args
        prot.d = self.d
        return prot
+
+    def clientConnectionFailed(self, connector, reason):
+       self.d.errback()
\ No newline at end of file