本文整理汇总了Python中xmlrpclib.SafeTransport方法的典型用法代码示例。如果您正苦于以下问题:Python xmlrpclib.SafeTransport方法的具体用法?Python xmlrpclib.SafeTransport怎么用?Python xmlrpclib.SafeTransport使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xmlrpclib
的用法示例。
在下文中一共展示了xmlrpclib.SafeTransport方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import SafeTransport [as 别名]
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
示例2: __init__
# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import SafeTransport [as 别名]
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
示例3: make_connection
# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import SafeTransport [as 别名]
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 --
示例4: __init__
# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import SafeTransport [as 别名]
def __init__(self, timeout=socket._GLOBAL_DEFAULT_TIMEOUT,
*args, **kwargs):
xmlrpclib.SafeTransport.__init__(self, *args, **kwargs)
self.timeout = timeout
示例5: _xml_rpc_auth
# 需要导入模块: import xmlrpclib [as 别名]
# 或者: from xmlrpclib import SafeTransport [as 别名]
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]}