~bigkevmcd/offspring/master-dont-scan-slaves

« back to all changes in this revision

Viewing changes to lib/offspring/networking.py

  • Committer: Cody A.W. Somerville
  • Date: 2012-07-30 01:48:49 UTC
  • mfrom: (151.1.5 fix-offspring-on-python2.7)
  • Revision ID: cody.somerville@canonical.com-20120730014849-tzssditldxcnq0c9
Fixed Offspring running on python > 2.6 [r=timrc].

Show diffs side-by-side

added added

removed removed

Lines of Context:
4
4
from base64 import decodestring
5
5
import httplib
6
6
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
 
7
import sys
7
8
import xmlrpclib
 
9
 
8
10
from offspring.config import get_configuration
9
11
 
10
12
### Slave Components
11
13
 
12
 
 
13
14
class BasicAuthXMLRPCRequestHandler(SimpleXMLRPCRequestHandler):
14
15
    """XMLRPC Request Handler that supports basic digest authentication."""
15
16
 
35
36
 
36
37
### Master Components
37
38
 
38
 
 
39
39
class TimeoutHTTPConnection(httplib.HTTPConnection):
40
40
 
41
41
    def __init__(self, *args, **kwargs):
58
58
    """XMLRPC Transport to setup a socket with defined timeout"""
59
59
 
60
60
    def make_connection(self, host):
61
 
        host, extra_headers, x509 = self.get_host_info(host)
62
 
        return TimeoutHTTP(host)
 
61
        host, self._extra_headers, x509 = self.get_host_info(host)
 
62
        # Before python 2.7 xmlrpclib continued to use python 1.5 httplib API
 
63
        if sys.version_info < (2, 7):
 
64
            connection = TimeoutHTTP(host)
 
65
        else:
 
66
            connection = TimeoutHTTPConnection(host)
 
67
            # self._connection[1] is used by 'close' method in parent class
 
68
            self._connection = host, connection
 
69
        return connection