diff options
author | Narayan Desai <desai@mcs.anl.gov> | 2009-05-07 11:58:22 +0000 |
---|---|---|
committer | Narayan Desai <desai@mcs.anl.gov> | 2009-05-07 11:58:22 +0000 |
commit | 61ae42bb686b3abde33f80591992e3adff0f155c (patch) | |
tree | 38dd75868fb3d8687b7eb9ed6e3bb01b2b0bc2bf | |
parent | dbadec29a4305ae406160f379eb5bb0b92c53f50 (diff) | |
download | bcfg2-61ae42bb686b3abde33f80591992e3adff0f155c.tar.gz bcfg2-61ae42bb686b3abde33f80591992e3adff0f155c.tar.bz2 bcfg2-61ae42bb686b3abde33f80591992e3adff0f155c.zip |
SSL Proxy: only use timeout parm with py2.6+ (patch from Torsten Rehn) (Resolves Ticket #652)
git-svn-id: https://svn.mcs.anl.gov/repos/bcfg/trunk/bcfg2@5209 ce84e21b-d406-0410-9b95-82705330c041
-rw-r--r-- | src/lib/Proxy.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/src/lib/Proxy.py b/src/lib/Proxy.py index 432f32bd3..864756f49 100644 --- a/src/lib/Proxy.py +++ b/src/lib/Proxy.py @@ -16,10 +16,15 @@ import httplib import logging import socket import ssl +import string +import sys import time import urlparse import xmlrpclib +version = string.split(string.split(sys.version)[0], ".") +has_py26 = map(int, version) >= [2, 6] + __all__ = ["ComponentProxy", "RetryMethod", "SSLHTTPConnection", "XMLRPCTransport"] class RetryMethod(_Method): @@ -52,7 +57,10 @@ xmlrpclib._Method = RetryMethod class SSLHTTPConnection(httplib.HTTPConnection): def __init__(self, host, port=None, strict=None, timeout=90, key=None, cert=None, ca=None): - httplib.HTTPConnection.__init__(self, host, port, strict, timeout) + if not has_py26: + httplib.HTTPConnection.__init__(self, host, port, strict) + else: + httplib.HTTPConnection.__init__(self, host, port, strict, timeout) self.key = key self.cert = cert self.ca = ca @@ -63,7 +71,8 @@ class SSLHTTPConnection(httplib.HTTPConnection): def connect(self): rawsock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) - rawsock.settimeout(self.timeout) + if has_py26: + rawsock.settimeout(self.timeout) self.sock = ssl.SSLSocket(rawsock, cert_reqs=self.ca_mode, ca_certs=self.ca, suppress_ragged_eofs=True, keyfile=self.key, certfile=self.cert) |