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


Python client.Transport方法代码示例

本文整理汇总了Python中xmlrpc.client.Transport方法的典型用法代码示例。如果您正苦于以下问题:Python client.Transport方法的具体用法?Python client.Transport怎么用?Python client.Transport使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在xmlrpc.client的用法示例。


在下文中一共展示了client.Transport方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __init__

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Transport [as 别名]
def __init__(self, index_url, session, use_datetime=False):
        xmlrpc_client.Transport.__init__(self, use_datetime)
        index_parts = urllib_parse.urlparse(index_url)
        self._scheme = index_parts.scheme
        self._session = session 
开发者ID:frostming,项目名称:pdm,代码行数:7,代码来源:xmlrpc.py

示例2: test_get_host_info

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Transport [as 别名]
def test_get_host_info(self):
        # see bug #3613, this raised a TypeError
        transp = xmlrpc.client.Transport()
        self.assertEqual(transp.get_host_info("user@host.tld"),
                          ('host.tld',
                           [('Authorization', 'Basic dXNlcg==')], {})) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:8,代码来源:test_xmlrpc.py

示例3: parse_response

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Transport [as 别名]
def parse_response(self, response):
            self.response_length=int(response.getheader("content-length", 0))
            return xmlrpclib.Transport.parse_response(self, response) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:5,代码来源:test_xmlrpc.py

示例4: send_content

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Transport [as 别名]
def send_content(self, connection, body):
            if self.fake_gzip:
                #add a lone gzip header to induce decode error remotely
                connection.putheader("Content-Encoding", "gzip")
            return xmlrpclib.Transport.send_content(self, connection, body) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:7,代码来源:test_xmlrpc.py

示例5: test_gzip_request

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Transport [as 别名]
def test_gzip_request(self):
        t = self.Transport()
        t.encode_threshold = None
        p = xmlrpclib.ServerProxy(URL, transport=t)
        self.assertEqual(p.pow(6,8), 6**8)
        a = self.RequestHandler.content_length
        t.encode_threshold = 0 #turn on request encoding
        self.assertEqual(p.pow(6,8), 6**8)
        b = self.RequestHandler.content_length
        self.assertTrue(a>b)
        p("close")() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:13,代码来源:test_xmlrpc.py

示例6: test_bad_gzip_request

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Transport [as 别名]
def test_bad_gzip_request(self):
        t = self.Transport()
        t.encode_threshold = None
        t.fake_gzip = True
        p = xmlrpclib.ServerProxy(URL, transport=t)
        cm = self.assertRaisesRegex(xmlrpclib.ProtocolError,
                                    re.compile(r"\b400\b"))
        with cm:
            p.pow(6, 8)
        p("close")() 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:12,代码来源:test_xmlrpc.py

示例7: test_transport

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Transport [as 别名]
def test_transport(self):
        t = xmlrpclib.Transport()
        p = xmlrpclib.ServerProxy(self.url, transport=t)
        self.assertEqual(p('transport'), t)


# This is a contrived way to make a failure occur on the server side
# in order to test the _send_traceback_header flag on the server 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:10,代码来源:test_xmlrpc.py

示例8: test_transport

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Transport [as 别名]
def test_transport(self):
        t = xmlrpclib.Transport()
        p = xmlrpclib.ServerProxy(self.url, transport=t)
        self.assertEqual(p('transport'), t)

# This is a contrived way to make a failure occur on the server side
# in order to test the _send_traceback_header flag on the server 
开发者ID:IronLanguages,项目名称:ironpython3,代码行数:9,代码来源:test_xmlrpc.py

示例9: __init__

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Transport [as 别名]
def __init__(self, *args, **kwargs):
        self.session = None
        self.timeout = None
        if 'session' in kwargs:
            self.session = kwargs['session']
            del kwargs['session']
        if 'timeout' in kwargs:
            self.timeout = kwargs['timeout']
            del kwargs['timeout']
        return xmlrpc.Transport.__init__(self, *args, **kwargs) 
开发者ID:ip-tools,项目名称:patzilla,代码行数:12,代码来源:requests_xmlrpclib.py

示例10: __init__

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Transport [as 别名]
def __init__(self, use_datetime=0, host=None):
        xmlrpclib.Transport.__init__(self, use_datetime)
        if host:
            self.use_https = 'https' in host 
开发者ID:Gandi,项目名称:gandi.cli,代码行数:6,代码来源:xmlrpc.py

示例11: CookiesTransport

# 需要导入模块: from xmlrpc import client [as 别名]
# 或者: from xmlrpc.client import Transport [as 别名]
def CookiesTransport(proto='https'):
    """Generate transport class when using cookie based authentication."""
    _TransportClass_ = Transport if proto == 'http' else SafeTransport

    class CookiesTransport(_TransportClass_):
        """A Python3 xmlrpc.client.Transport subclass that retains cookies."""
        def __init__(self):
            _TransportClass_.__init__(self)
            self._cookies = dict()

        def send_headers(self, connection, headers):
            if self._cookies:
                cookies = map(lambda x: x[0] + '=' + x[1], self._cookies.items())
                connection.putheader('Cookie', '; '.join(cookies))
            _TransportClass_.send_headers(self, connection, headers)

        def parse_response(self, response):
            """parse and store cookie"""
            try:
                for header in response.msg.get_all("Set-Cookie"):
                    cookie = header.split(";", 1)[0]
                    cookieKey, cookieValue = cookie.split("=", 1)
                    self._cookies[cookieKey] = cookieValue
            finally:
                return _TransportClass_.parse_response(self, response)

    class CookiesTransport2(_TransportClass_):
        """A Python2 xmlrpclib.Transport subclass that retains cookies."""
        def __init__(self):
            _TransportClass_.__init__(self)
            self._cookies = dict()

        def send_request(self, connection, handler, request_body):
            _TransportClass_.send_request(self, connection, handler, request_body)
            # set cookie below handler
            if self._cookies:
                cookies = map(lambda x: x[0] + '=' + x[1], self._cookies.items())
                connection.putheader("Cookie", "; ".join(cookies))

        def parse_response(self, response):
            """parse and store cookie"""
            try:
                for header in response.getheader("set-cookie").split(", "):
                    # filter 'expire' information
                    if not header.startswith("D"):
                        continue
                    cookie = header.split(";", 1)[0]
                    cookieKey, cookieValue = cookie.split("=", 1)
                    self._cookies[cookieKey] = cookieValue
            finally:
                return _TransportClass_.parse_response(self, response)

    return CookiesTransport2() if PY_VERSION == 2 else CookiesTransport() 
开发者ID:fmenabe,项目名称:python-dokuwiki,代码行数:55,代码来源:dokuwiki.py


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