当前位置: 首页>>代码示例>>Python>>正文


Python xmlrpclib.SafeTransport方法代码示例

本文整理汇总了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 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:25,代码来源:brpclib.py

示例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 
开发者ID:kenorb-contrib,项目名称:BitTorrent,代码行数:25,代码来源:ebrpclib.py

示例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 -- 
开发者ID:osiell,项目名称:oerplib,代码行数:8,代码来源:xmlrpclib_custom.py

示例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 
开发者ID:osiell,项目名称:oerplib,代码行数:6,代码来源:xmlrpclib_custom.py

示例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]} 
开发者ID:redhat-openstack,项目名称:infrared,代码行数:46,代码来源:beaker_provisioner.py


注:本文中的xmlrpclib.SafeTransport方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。