當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。