Python xmlrpclib.SafeTransport() Examples
The following are 8
code examples of xmlrpclib.SafeTransport().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
xmlrpclib
, or try the search function
.
Example #1
Source File: brpclib.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
def __init__(self, uri, transport=None, encoding=None, verbose=0, allow_none=0): # establish a "logical" server connection # get the url import urllib type, uri = urllib.splittype(uri) if type not in ("http", "https"): raise IOError, "unsupported B-RPC protocol" self.__host, self.__handler = urllib.splithost(uri) if not self.__handler: self.__handler = "/RPC2" if transport is None: if type == "https": transport = xmlrpclib.SafeTransport() else: transport = xmlrpclib.Transport() self.__transport = transport self.__encoding = encoding self.__verbose = verbose self.__allow_none = allow_none
Example #2
Source File: ebrpclib.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
def __init__(self, uri, transport=None, encoding=None, verbose=0, allow_none=0): # establish a "logical" server connection # get the url import urllib type, uri = urllib.splittype(uri) if type not in ("http", "https"): raise IOError, "unsupported EB-RPC protocol" self.__host, self.__handler = urllib.splithost(uri) if not self.__handler: self.__handler = "/RPC2" if transport is None: if type == "https": transport = xmlrpclib.SafeTransport() else: transport = xmlrpclib.Transport() self.__transport = transport self.__encoding = encoding self.__verbose = verbose self.__allow_none = allow_none
Example #3
Source File: brpclib.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
def __init__(self, uri, transport=None, encoding=None, verbose=0, allow_none=0): # establish a "logical" server connection # get the url import urllib type, uri = urllib.splittype(uri) if type not in ("http", "https"): raise IOError, "unsupported B-RPC protocol" self.__host, self.__handler = urllib.splithost(uri) if not self.__handler: self.__handler = "/RPC2" if transport is None: if type == "https": transport = xmlrpclib.SafeTransport() else: transport = xmlrpclib.Transport() self.__transport = transport self.__encoding = encoding self.__verbose = verbose self.__allow_none = allow_none
Example #4
Source File: ebrpclib.py From BitTorrent with GNU General Public License v3.0 | 6 votes |
def __init__(self, uri, transport=None, encoding=None, verbose=0, allow_none=0): # establish a "logical" server connection # get the url import urllib type, uri = urllib.splittype(uri) if type not in ("http", "https"): raise IOError, "unsupported EB-RPC protocol" self.__host, self.__handler = urllib.splithost(uri) if not self.__handler: self.__handler = "/RPC2" if transport is None: if type == "https": transport = xmlrpclib.SafeTransport() else: transport = xmlrpclib.Transport() self.__transport = transport self.__encoding = encoding self.__verbose = verbose self.__allow_none = allow_none
Example #5
Source File: xmlrpclib_custom.py From oerplib with GNU Lesser General Public License v3.0 | 5 votes |
def make_connection(self, host): host, extra_headers, x509 = self.get_host_info(host) conn = TimeoutHTTPPy26(host, timeout=self.timeout) return conn # -- xmlrpclib.SafeTransport with timeout support --
Example #6
Source File: xmlrpclib_custom.py From oerplib with GNU Lesser General Public License v3.0 | 5 votes |
def make_connection(self, host): if self._connection and host == self._connection[0]: return self._connection[1] chost, self._extra_headers, x509 = self.get_host_info(host) self._connection = host, TimeoutHTTPConnectionPy27( self.timeout, chost) return self._connection[1] # -- xmlrpclib.SafeTransport with timeout support --
Example #7
Source File: xmlrpclib_custom.py From oerplib with GNU Lesser General Public License v3.0 | 5 votes |
def __init__(self, timeout=socket._GLOBAL_DEFAULT_TIMEOUT, *args, **kwargs): xmlrpclib.SafeTransport.__init__(self, *args, **kwargs) self.timeout = timeout
Example #8
Source File: beaker_provisioner.py From infrared with Apache License 2.0 | 4 votes |
def _xml_rpc_auth(self): """ Authenticates with the server using XML-RPC and returns the cookie's name and ID. """ # TODO: This method should be replaced with SafeCookieTransfer class!!! import re import ssl import tempfile import xmlrpclib try: ssl_context = ssl.create_default_context(cafile=self.ca_cert) transport = xmlrpclib.SafeTransport(context=ssl_context) except TypeError: # py < 2.7.9 transport = xmlrpclib.SafeTransport() hub = xmlrpclib.ServerProxy( urljoin(self.base_url, 'client'), allow_none=True, transport=transport, verbose=True) stdout = sys.stdout tmp_file = tempfile.TemporaryFile() try: sys.stdout = tmp_file hub.auth.login_password(self.auth.username, self.auth.password) tmp_file.seek(0) stdout_content = tmp_file.read() except xmlrpclib.Fault: raise RuntimeError('Failed to authenticate with the server') finally: sys.stdout = stdout tmp_file.close() pattern = re.compile('beaker_auth_token=[\w.-]*') results = pattern.findall(stdout_content) if not results: raise RuntimeError("Cookie not found") return {'beaker_auth_token': results[0].split('=')[1]}