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


Python HTTPClientFactory.noisy方法代码示例

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


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

示例1: getPage

# 需要导入模块: from twisted.web.client import HTTPClientFactory [as 别名]
# 或者: from twisted.web.client.HTTPClientFactory import noisy [as 别名]
def getPage(url, bindAddress = None, *arg, **kw):
    # reimplemented here to insert bindAddress

    # _parse() deprecated in twisted 13.1.0 in favor of the _URI class
    if hasattr(client, '_parse'):
        scheme, host, port, path = client._parse(url)
    else:
        # _URI class renamed to URI in 15.0.0
        try:
            from twisted.web.client import _URI as URI
        except ImportError:
            from twisted.web.client import URI
        
        uri = URI.fromBytes(url)
        scheme = uri.scheme
        host = uri.host
        port = uri.port
        path = uri.path

    factory = HTTPClientFactory(url, *arg, **kw)
    factory.noisy = False
	
    if scheme == 'https':
        from twisted.internet import ssl
        context = ssl.ClientContextFactory()
        reactor.connectSSL(host, port, factory, context, 
            bindAddress = bindAddress)
    else:
        reactor.connectTCP(host, port, factory, bindAddress = bindAddress)
    return factory.deferred
开发者ID:Architektor,项目名称:PySnip,代码行数:32,代码来源:web.py

示例2: send_json

# 需要导入模块: from twisted.web.client import HTTPClientFactory [as 别名]
# 或者: from twisted.web.client.HTTPClientFactory import noisy [as 别名]
def send_json(url, **kw):
    qurl =url+'?'+urlencode(kw.get('postdata', {}))
    # debug(0,'URLSTATS: %s',qurl)
    factory = HTTPClientFactory(str(qurl))
    factory.noisy = False
    if url.startswith('http://'):
        reactor.connectTCP(factory.host, factory.port, factory)
    elif url.startswith('https://'):
        reactor.connectSSL(factory.host, factory.port, factory, 
            ssl.ClientContextFactory())
    else:
        raise Exception('Url error: %s' %url)
    return factory
开发者ID:hosle,项目名称:tapas,代码行数:15,代码来源:util.py

示例3: flush

# 需要导入模块: from twisted.web.client import HTTPClientFactory [as 别名]
# 或者: from twisted.web.client.HTTPClientFactory import noisy [as 别名]
 def flush(self):
     scheme, host, port, path = _parse(self.url)
     factory = HTTPClientFactory(self.url, method='POST', postdata=self._buffer.getvalue())
     factory.noisy = False
     
     if scheme == 'https':
         from twisted.internet import ssl
         contextFactory = ssl.ClientContextFactory()
         reactor.connectSSL(host, port, factory, contextFactory)
     else:
         reactor.connectTCP(host, port, factory)
     
     factory.deferred.addCallbacks(self._handle, self._error)
     self._buffer = StringIO()
开发者ID:SMAC,项目名称:corelib,代码行数:16,代码来源:protocol.py

示例4: _start

# 需要导入模块: from twisted.web.client import HTTPClientFactory [as 别名]
# 或者: from twisted.web.client.HTTPClientFactory import noisy [as 别名]
    def _start(self):
        self.saved['Request URL'] = self.request_url

        # Generate a request id if possible
        if uuid:
            request_id = str(uuid.uuid1())
            self.saved['Request ID'] = request_id
            self.headers['X-Request-Id'] = request_id

        factory = HTTPClientFactory(url=self.conf['path'],
                method=self.conf['method'], postdata=self.conf['data'],
                headers=self.headers, agent=self.agent,
                timeout=self.conf['timeout'], followRedirect=0)
        factory.host = self.headers_host
        factory.noisy = False
        factory.deferred.addErrback(self._failure_tcp)
        factory.deferred.addErrback(self._failure_http)
        self._connect(factory)
        return factory.deferred
开发者ID:jordane,项目名称:nagcat,代码行数:21,代码来源:query_http.py

示例5: get_json

# 需要导入模块: from twisted.web.client import HTTPClientFactory [as 别名]
# 或者: from twisted.web.client.HTTPClientFactory import noisy [as 别名]
def get_json(url, *args, **kwargs):
    """
    :param json: JSON data
    :param url:
    :param args:
    :param kwargs:
    :return:
    """
    j = kwargs.pop('json', None)
    if j:
        kwargs['postdata'] = as_json(j)
    kwargs.setdefault('agent', 'Twisted JSON Adapter')
    uri = URI.fromBytes(url)
    factory = HTTPClientFactory(url, *args, **kwargs)
    factory.noisy = 0
    if uri.scheme == b'https':
        from twisted.internet import ssl
        contextFactory = ssl.ClientContextFactory()
        reactor.connectSSL(
            nativeString(uri.host), uri.port, factory, contextFactory)
    else:
        reactor.connectTCP(nativeString(uri.host), uri.port, factory)
    return factory.deferred.addCallback(_json_loads)
开发者ID:hitsl,项目名称:bouser,代码行数:25,代码来源:api_helpers.py


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