X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=PLC%2FPyCurl.py;h=c8a3911c33d1ccddf72c1f87bdb814ea9e271489;hb=1d3540bd2ece27d91a2ec5843628c5fa38a25024;hp=e43efe62af33ed3fe856c6d8f2fa550d24cb53e5;hpb=db15e87507a9dcc02bfa5637f7195c82d12e7e49;p=plcapi.git diff --git a/PLC/PyCurl.py b/PLC/PyCurl.py index e43efe6..c8a3911 100644 --- a/PLC/PyCurl.py +++ b/PLC/PyCurl.py @@ -5,16 +5,16 @@ # Mark Huang # Copyright (C) 2006 The Trustees of Princeton University # -# $Id: PyCurl.py,v 1.2 2007/09/12 17:52:27 tmack Exp $ -# import os -import xmlrpclib +import xmlrpc.client import pycurl from tempfile import NamedTemporaryFile -class PyCurlTransport(xmlrpclib.Transport): +class PyCurlTransport(xmlrpc.client.Transport): def __init__(self, uri, cert = None, timeout = 300): + if hasattr(xmlrpc.client.Transport,'__init__'): + xmlrpc.client.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 = "" - except pycurl.error, err: + errmsg="" + except pycurl.error as err: (errcode, errmsg) = err if errcode == 60: - raise Exception, "PyCurl: SSL certificate validation failed" + raise Exception("PyCurl: SSL certificate validation failed") elif errcode != 200: - raise Exception, "PyCurl: HTTP error %d -- %r" % (errcode,errmsg) + raise Exception("PyCurl: HTTP error %d -- %r" % (errcode,errmsg)) # Parse response p, u = self.getparser()