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


Python client._makeGetterFactory函数代码示例

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


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

示例1: downloadFile

def downloadFile(url, file, statusCallback=None, bucketFilter=None, contextFactory=None, *args, **kwargs):
    factoryFactory = lambda url, *a, **kw: HTTPManagedDownloader(url, file, statusCallback=statusCallback, bucketFilter=bucketFilter, *a, **kw)
    return _makeGetterFactory(
        url,
        factoryFactory,
        contextFactory=contextFactory,
        *args, **kwargs).deferred
开发者ID:jjongsma,项目名称:downpour,代码行数:7,代码来源:http.py

示例2: quiet_get_page

def quiet_get_page(url, contextFactory=None, *args, **kwargs):
    """A version of getPage that uses QuietHTTPClientFactory."""
    return _makeGetterFactory(
        url,
        QuietHTTPClientFactory,
        contextFactory=contextFactory,
        *args, **kwargs).deferred
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:7,代码来源:sentry.py

示例3: getPageAndHeaders

def getPageAndHeaders(url, contextFactory=None, *args, **kwargs):
    factory = client._makeGetterFactory(
        url,
        client.HTTPClientFactory,
        contextFactory=contextFactory,
        *args, **kwargs)
    return factory.deferred.addCallback(lambda page: (page, factory.response_headers))
开发者ID:forrestv,项目名称:bennu,代码行数:7,代码来源:jsonrpc.py

示例4: makeUpstreamGetter

	def makeUpstreamGetter(upstream):
		identifier, url, args, kwargs = upstream
		subfactory = client._makeGetterFactory(url,
						       factory,
						       context_factory,
						       *args, **kwargs)
		subfactory.deferred.addBoth(lambda x: (x, identifier, subfactory))
		return subfactory.deferred
开发者ID:bussiere,项目名称:couchdb-lounge,代码行数:8,代码来源:fetcher.py

示例5: fetch

def fetch(url, contextFactory=None, *args, **kwargs):
    def wrapper(error):
        return Page(error=error.getErrorMessage())

    d = client._makeGetterFactory(url, HTTPClientFactory,
        contextFactory=contextFactory, *args, **kwargs).deferred
    d.addErrback(wrapper)
    return d
开发者ID:ddgromit,项目名称:cyclone,代码行数:8,代码来源:httpclient.py

示例6: _request_cookies

	def _request_cookies(self, url, method="GET", data=None):
		factory = _makeGetterFactory(self.base_url + url, HTTPClientFactory,
		                             method=method, postdata=data,
		                             cookies=self.cookies)
		factory.deferred.addErrback(self._log_errback)
		def cookie_magic(data):
			return (data, factory.cookies)
		factory.deferred.addCallback(cookie_magic)
		return factory.deferred
开发者ID:minus7,项目名称:oneliner-tui,代码行数:9,代码来源:async.py

示例7: getTwitterStream

def getTwitterStream(url, username, password, contextFactory=None, *args, **kwargs):
    encoded_auth = base64.encodestring("%s:%s" % (username, password))
    authorization_header = "Basic %s" % encoded_auth
    kwargs.update({'headers' : {'authorization': authorization_header}})
    
    return _makeGetterFactory(
        url,
        StreamingTwitterClientFactory,
        contextFactory=contextFactory,
        *args, **kwargs).deferred    
开发者ID:thatmattbone,项目名称:lab,代码行数:10,代码来源:twitiwt.py

示例8: getPage

def getPage(url, contextFactory=None, *args, **kwargs):
    """Adapted version of twisted.web.client.getPage"""
    def _clientfactory(*args, **kwargs):
        timeout = kwargs.pop('timeout', 0)
        f = client.ScrapyHTTPClientFactory(Request(*args, **kwargs), timeout=timeout)
        f.deferred.addCallback(lambda r: r.body)
        return f

    from twisted.web.client import _makeGetterFactory
    return _makeGetterFactory(url, _clientfactory,
        contextFactory=contextFactory, *args, **kwargs).deferred
开发者ID:bihicheng,项目名称:scrapy,代码行数:11,代码来源:test_webclient.py

示例9: get_page

 def get_page(self, url, contextFactory=None, *args, **kwargs):
     '''Adapted version of twisted.web.client.getPage'''
     def _clientfactory(*args, **kwargs):
         timeout = kwargs.pop('timeout', 0)
         download_size = kwargs.pop('download_size', 0)
         f = CrawlmiHTPPClientFactory(Request(*args, **kwargs),
             timeout=timeout, download_size=download_size)
         f.deferred.addCallback(lambda r: r.body)
         return f
     from twisted.web.client import _makeGetterFactory
     return _makeGetterFactory(url, _clientfactory,
         contextFactory=contextFactory, *args, **kwargs).deferred
开发者ID:Mimino666,项目名称:crawlmi,代码行数:12,代码来源:test_webclient.py

示例10: start

 def start(self):
     self.original_mimetype = self.download.mime_type
     self.download.status = Status.STARTING
     bucketFilter = ThrottledBucketFilter(0, self.manager.get_download_rate_filter())
     factoryFactory = lambda url, *a, **kw: HTTPManagedDownloader(str(self.download.url),
                                 os.path.join(self.directory, self.download.filename),
                                 statusCallback=DownloadStatus(self.download),
                                 bucketFilter=bucketFilter, *a, **kw)
     self.factory = _makeGetterFactory(str(self.download.url), factoryFactory)
     self.factory.deferred.addCallback(self.check_mimetype);
     self.factory.deferred.addErrback(self.errback);
     return True
开发者ID:jjongsma,项目名称:downpour,代码行数:12,代码来源:http.py

示例11: getPage

def getPage(url, contextFactory=None, response_transform=None, *args, **kwargs):
    """Adapted version of twisted.web.client.getPage"""
    def _clientfactory(url, *args, **kwargs):
        url = to_unicode(url)
        timeout = kwargs.pop('timeout', 0)
        f = client.ScrapyHTTPClientFactory(
            Request(url, *args, **kwargs), timeout=timeout)
        f.deferred.addCallback(response_transform or (lambda r: r.body))
        return f

    from twisted.web.client import _makeGetterFactory
    return _makeGetterFactory(to_bytes(url), _clientfactory,
        contextFactory=contextFactory, *args, **kwargs).deferred
开发者ID:01-,项目名称:scrapy,代码行数:13,代码来源:test_webclient.py

示例12: test_infiniteRedirection

    def test_infiniteRedirection(self):
        """
        When more than C{redirectLimit} HTTP redirects are encountered, the
        page request fails with L{InfiniteRedirection}.
        """

        def checkRedirectCount(*a):
            self.assertEqual(f._redirectCount, 13)
            self.assertEqual(self.infiniteRedirectResource.count, 13)

        f = client._makeGetterFactory(self.getURL("infiniteRedirect"), client.HTTPClientFactory, redirectLimit=13)
        d = self.assertFailure(f.deferred, error.InfiniteRedirection)
        d.addCallback(checkRedirectCount)
        return d
开发者ID:ragercool,项目名称:twisted,代码行数:14,代码来源:test_webclient.py

示例13: getPage

def getPage(url, contextFactory=None, *args, **kwargs):
    """
    Download a web page as a string.

    Download a page. Return a deferred, which will callback with a
    page (as a string) or errback with a description of the error.

    See HTTPClientFactory to see what extra args can be passed.
    """
    kwargs['agent'] = "Coherence PageGetter"
    return client._makeGetterFactory(
        url,
        HeaderAwareHTTPClientFactory,
        contextFactory=contextFactory,
        *args, **kwargs).deferred
开发者ID:BlackHole,项目名称:coherence,代码行数:15,代码来源:utils.py

示例14: subgen

	def subgen():
		lastError = None
		for (identifier, url, args, kwargs) in upstreams:
			subfactory = client._makeGetterFactory(url,
							       factory,
							       context_factory,
							       *args, **kwargs)
			wait = defer.waitForDeferred(subfactory.deferred)
			yield wait
			try:
				yield (wait.getResult(), identifier, subfactory)
				return
			except ConnectError:
				lastError = sys.exc_info()[1]
		raise lastError and lastError or error.Error(http.INTERNAL_SERVER_ERROR)
开发者ID:bussiere,项目名称:couchdb-lounge,代码行数:15,代码来源:fetcher.py

示例15: getPageAndHeaders

def getPageAndHeaders(url, contextFactory=None, *args, **kwargs):
    """Return deferred with a (body, headers) success result.

    This is a small modification to twisted.web.client.getPage that
    allows the caller access to the response headers.

    """
    factory = txwebclient._makeGetterFactory(
        url,
        txwebclient.HTTPClientFactory,
        contextFactory=contextFactory,
        *args, **kwargs)

    return factory.deferred.addCallback(
        lambda page: (page, factory.response_headers))
开发者ID:tomatoXu,项目名称:ZenPacks.zenoss.OpenStackInfrastructure,代码行数:15,代码来源:novaapiclient.py


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