Ticket #652: bcfg2-py26.diff

File bcfg2-py26.diff, 1.4 KB (added by Torsten Rehn <torsten.rehn@…>, 13 years ago)

quick and dirty patch to fix the issue

  • src/lib/Proxy.py

     
    1616import logging 
    1717import socket 
    1818import ssl 
     19import string 
     20import sys 
    1921import time 
    2022import urlparse 
    2123import xmlrpclib 
    2224 
     25version = string.split(string.split(sys.version)[0], ".") 
     26has_py26 = map(int, version) >= [2, 6] 
     27 
    2328__all__ = ["ComponentProxy", "RetryMethod", "SSLHTTPConnection", "XMLRPCTransport"] 
    2429 
    2530class RetryMethod(_Method): 
     
    5257class SSLHTTPConnection(httplib.HTTPConnection): 
    5358    def __init__(self, host, port=None, strict=None, timeout=90, key=None, 
    5459                 cert=None, ca=None): 
    55         httplib.HTTPConnection.__init__(self, host, port, strict, timeout) 
     60        if not has_py26: 
     61                httplib.HTTPConnection.__init__(self, host, port, strict) 
     62        else: 
     63                httplib.HTTPConnection.__init__(self, host, port, strict, timeout) 
    5664        self.key = key 
    5765        self.cert = cert 
    5866        self.ca = ca 
     
    6371 
    6472    def connect(self): 
    6573        rawsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) 
    66         rawsock.settimeout(self.timeout) 
     74        if has_py26: 
     75                rawsock.settimeout(self.timeout) 
    6776        self.sock = ssl.SSLSocket(rawsock, cert_reqs=self.ca_mode, 
    6877                                  ca_certs=self.ca, suppress_ragged_eofs=True, 
    6978                                  keyfile=self.key, certfile=self.cert)