X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FPyCurl.py;h=4ae2fdc9a4a7d9663c67214146ff08328933c537;hb=79d959a7decd4af5b0b15e660bb3bd5bb5edfcaf;hp=8352fd0cd5e0956af794752219ec9641bd489204;hpb=a862007a170dc19ebe1079c61e9b4f1c4aba9206;p=plcapi.git diff --git a/PLC/PyCurl.py b/PLC/PyCurl.py index 8352fd0..4ae2fdc 100644 --- a/PLC/PyCurl.py +++ b/PLC/PyCurl.py @@ -5,8 +5,6 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id$ -# import os import xmlrpclib @@ -15,6 +13,8 @@ from tempfile import NamedTemporaryFile class PyCurlTransport(xmlrpclib.Transport): def __init__(self, uri, cert = None, timeout = 300): + if hasattr(xmlrpclib.Transport,'__init__'): + xmlrpclib.Transport.__init__(self) self.curl = pycurl.Curl() # Suppress signals @@ -49,7 +49,7 @@ class PyCurlTransport(xmlrpclib.Transport): self.body = "" def body(buf): self.body += buf - self.curl.setopt(pycurl.WRITEFUNCTION, body) + self.curl.setopt(pycurl.WRITEFUNCTION, body) def request(self, host, handler, request_body, verbose = 1): # Set verbosity @@ -64,13 +64,14 @@ class PyCurlTransport(xmlrpclib.Transport): errcode = self.curl.getinfo(pycurl.HTTP_CODE) response = self.body self.body = "" + errmsg="" except pycurl.error, err: (errcode, errmsg) = err if errcode == 60: - raise Exception, "SSL certificate validation failed" + raise Exception, "PyCurl: SSL certificate validation failed" elif errcode != 200: - raise Exception, "HTTP error %d" % errcode + raise Exception, "PyCurl: HTTP error %d -- %r" % (errcode,errmsg) # Parse response p, u = self.getparser()