當前位置: 首頁>>代碼示例>>Python>>正文


Python HTTPClientFactory.__init__方法代碼示例

本文整理匯總了Python中twisted.web.client.HTTPClientFactory.__init__方法的典型用法代碼示例。如果您正苦於以下問題:Python HTTPClientFactory.__init__方法的具體用法?Python HTTPClientFactory.__init__怎麽用?Python HTTPClientFactory.__init__使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在twisted.web.client.HTTPClientFactory的用法示例。


在下文中一共展示了HTTPClientFactory.__init__方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from twisted.web.client import HTTPClientFactory [as 別名]
# 或者: from twisted.web.client.HTTPClientFactory import __init__ [as 別名]
	def __init__(self, temp_token, log):
		self.temp_token = temp_token
		self.log = log
		self.url = "https://www.google.com/accounts/AuthSubSessionToken"
		"""
		self.keyfile = aztk_config.services.get('servers.httpserver', "google_ssl_priv_key")
		self.log.debug("keyfile: [%s]" % self.keyfile)
		self.passphrase = aztk_config.services.get('servers.httpserver', "google_ssl_priv_passphrase")
		self.time_stamp = int(time.time())
		self.rand_num = str(getrandbits(64))
		self.data = "GET %s %s %s" % (self.url, self.time_stamp, self.rand_num)
		"""
		#self.make_sig()
		header_dict = {
			'Accept': "*/*",
			#'Authorization': str("AuthSub token=\"%s\" data=\"%s\" sig=\"%s\" sigalg=\"rsa-sha1\"" % (self.temp_token, self.data, self.sig)),
			'Authorization': "AuthSub token=\"%s\"" % (self.temp_token),
			'Content-Type': "application/x-www-form-urlencoded"
		}
		self.log.debug("header_dict:\n%s" % pformat(header_dict))
		HTTPClientFactory.__init__(self, self.url, headers=header_dict, agent="Zoto/3.0.1")
		self.deferred.addCallback(self.handle_response)
		self.deferred.addErrback(self.handle_error)
		self.perm_token = ""
		self.expire_time = ""
開發者ID:BGCX261,項目名稱:zoto-server-svn-to-git,代碼行數:27,代碼來源:beta_blogger.py

示例2: __init__

# 需要導入模塊: from twisted.web.client import HTTPClientFactory [as 別名]
# 或者: from twisted.web.client.HTTPClientFactory import __init__ [as 別名]
    def __init__(self, url):
        HTTPClientFactory.__init__(self, url)
        self.deferred = defer.Deferred()
        self.waiting = 1

        self.on_page_part = Event()
        self.on_page_end = Event()
開發者ID:ceronman,項目名稱:pixtream,代碼行數:9,代碼來源:streamclient.py

示例3: __init__

# 需要導入模塊: from twisted.web.client import HTTPClientFactory [as 別名]
# 或者: from twisted.web.client.HTTPClientFactory import __init__ [as 別名]
	def __init__(self, url, contextFactory=None, retries=0):

		url = stripNoPrint(url)
		if retries > 0:
			print "Retrying: ", url
		else:
			print "Get: ", url
		self.retries = retries
		self.url = url
		self.charset = None
		scheme, host, port, path = _parse(url)
		HTTPClientFactory.__init__(self, url,
			method='GET', postdata=None, headers=None,
			agent='Mozilla/5.0 (Windows; U; Windows NT 6.1; en-US;' + 
				' rv:1.9.2.10) Gecko/20100914 Firefox/3.6.10')
		if scheme == 'https':
			from twisted.internet import ssl
			if contextFactory is None:
				contextFactory = ssl.ClientContextFactory()
			reactor.connectSSL(host, port, self, contextFactory)
		else:
			reactor.connectTCP(host, port, self)
		
		self.deferred.addCallbacks(self.getCharset, self.Err)
		self.deferred.addCallbacks(self.getTitle, self.Err)
開發者ID:kunwon1,項目名稱:Subtitle,代碼行數:27,代碼來源:TitleGetter2.py

示例4: __init__

# 需要導入模塊: from twisted.web.client import HTTPClientFactory [as 別名]
# 或者: from twisted.web.client.HTTPClientFactory import __init__ [as 別名]
 def __init__(self, user, password, callback, stream_type='spritzer', agent='TwitterHooks', query_params=None):
     url = 'http://stream.twitter.com/%s.json' % stream_type
     if query_params:
         url = '%s?%s' % (url, urllib.urlencode(query_params))
     self.auth = base64.b64encode('%s:%s' % (user, password))
     self.callback = callback
     self.last_retry = 0
     HTTPClientFactory.__init__(self, url=url, agent=agent)
開發者ID:progrium,項目名稱:twitterhooks,代碼行數:10,代碼來源:transformer.py

示例5: __init__

# 需要導入模塊: from twisted.web.client import HTTPClientFactory [as 別名]
# 或者: from twisted.web.client.HTTPClientFactory import __init__ [as 別名]
 def __init__(self, cacheDir, url, method='GET', postdata=None, headers={}, agent="Gazouilleur with Twisted ConditionalPageGetter", timeout=0, cookies=None, followRedirect=True, redirectLimit=5):
     self.cachefile = path.join(cacheDir, get_hash(url))
     self.last_modified = None
     if path.exists(self.cachefile):
         with open(self.cachefile) as cache:
             self.last_modified = cache.readline().strip()
             headers['If-Modified-Since'] = self.last_modified
     HTTPClientFactory.__init__(self, url, method=method, postdata=postdata, headers=headers, agent=agent, timeout=timeout, cookies=cookies, followRedirect=followRedirect, redirectLimit=redirectLimit)
開發者ID:Psycojoker,項目名稱:gazouilleur,代碼行數:10,代碼來源:httpget.py

示例6: __init__

# 需要導入模塊: from twisted.web.client import HTTPClientFactory [as 別名]
# 或者: from twisted.web.client.HTTPClientFactory import __init__ [as 別名]
 def __init__(self, url, proxy_host, proxy_port, *args, **kwargs):
     """
     Strips out proxy_host and proxy_port, then passes the rest of the
     arguments to base class (HTTPClientFactory)
     """
     self.proxy_host = proxy_host
     self.proxy_port = proxy_port
     HTTPClientFactory.__init__(self, url, *args, **kwargs)
開發者ID:shawnchin,項目名稱:goanna,代碼行數:10,代碼來源:webclient.py

示例7: __init__

# 需要導入模塊: from twisted.web.client import HTTPClientFactory [as 別名]
# 或者: from twisted.web.client.HTTPClientFactory import __init__ [as 別名]
    def __init__(self, *args, **kwds):
        HTTPClientFactory.__init__(self, *args, **kwds)

        if self.url in self.cache:
            if 'etag' in self.cache[self.url]:
                self.headers['etag'] = self.cache[self.url]['etag']
            elif 'last-modified' in self.cache[self.url]:
                self.headers['if-modified-since'] = self.cache[self.url]['last-modified']
            elif 'date' in self.cache[self.url]:
                self.headers['if-modified-since'] = self.cache[self.url]['date']
開發者ID:laudarch,項目名稱:Tor2web,代碼行數:12,代碼來源:lists.py

示例8: __init__

# 需要導入模塊: from twisted.web.client import HTTPClientFactory [as 別名]
# 或者: from twisted.web.client.HTTPClientFactory import __init__ [as 別名]
 def __init__(self, **kwargs):
     self.reqs = kwargs.pop('requests')
     self.report = kwargs.pop('report')
     self.ip = kwargs.pop('ip')
     self.host_port = kwargs.pop('port')
     if 'auth' in kwargs:
         self.protocol.auth = kwargs.pop('auth')
     self.activecons = 0
     self.total_reqs = len(self.reqs)
     HTTPClientFactory.__init__(self, timeout=15, **kwargs)
開發者ID:jasonthomas,項目名稱:logreplay,代碼行數:12,代碼來源:tworkers.py

示例9: __init__

# 需要導入模塊: from twisted.web.client import HTTPClientFactory [as 別名]
# 或者: from twisted.web.client.HTTPClientFactory import __init__ [as 別名]
	def __init__(self, frob, log):
		self.frob = frob
		self.log = log
		self.sig = md5.md5("%sapi_key%sfrob%smethodflickr.auth.getToken" % (SECRET, API_KEY, self.frob)).hexdigest()
		url = "http://api.flickr.com/services/rest/?method=flickr.auth.getToken&api_key=%s&frob=%s&api_sig=%s" % (API_KEY, self.frob, self.sig)
		self.log.debug("url: %s" % url)
		HTTPClientFactory.__init__(self, url, agent="Zoto/3.0.1")
		self.deferred.addCallback(self.handle_response)
		self.deferred.addErrback(self.handle_error)
		self.token = None
開發者ID:BGCX261,項目名稱:zoto-server-svn-to-git,代碼行數:12,代碼來源:flickr.py

示例10: __call__

# 需要導入模塊: from twisted.web.client import HTTPClientFactory [as 別名]
# 或者: from twisted.web.client.HTTPClientFactory import __init__ [as 別名]
 def __call__(self):
     HTTPClientFactory.__init__(self, self.page_url,
         method=self.method, agent=self.agent,
         timeout=self.defaults.interval)
     BaseMonitor.__call__(self)
     # this deferred is created above when
     # HTTPClientFactory.__init__() is called.
     d = self.deferred
     d.addCallback(self.logStatus)
     d.addErrback(self.errorHandlerPartialPage)
     d.addErrback(self.errorHandlerTimeout)
開發者ID:Darkpaw95,項目名稱:pymon,代碼行數:13,代碼來源:monitor.py

示例11: __init__

# 需要導入模塊: from twisted.web.client import HTTPClientFactory [as 別名]
# 或者: from twisted.web.client.HTTPClientFactory import __init__ [as 別名]
    def __init__(self, url, method='GET', postdata=None, headers=None,
                 agent="Tor2Web (https://github.com/globaleaks/tor2web-3.0)", timeout=0, cookies=None,
                 followRedirect=1):

        headers = {}

        if url in self.cache:
            if 'last-modified' in self.cache[url]:
                headers['if-modified-since'] = self.cache[url]['last-modified']
            elif 'date' in self.cache[url]:
                headers['if-modified-since'] = self.cache[url]['date']

        HTTPClientFactory.__init__(self, url=url, method=method,
                postdata=postdata, headers=headers, agent=agent,
                timeout=timeout, cookies=cookies, followRedirect=followRedirect)
        self.deferred = Deferred()
開發者ID:Syd,項目名稱:Tor2web-3.0,代碼行數:18,代碼來源:torExitNodes.py

示例12: __init__

# 需要導入模塊: from twisted.web.client import HTTPClientFactory [as 別名]
# 或者: from twisted.web.client.HTTPClientFactory import __init__ [as 別名]
 def __init__(self, ctx, *p, **k):
     """
     @param url
     @param method
     @param postdata
     @param headers
     @param timeout
     @param cookies
     @param followRedirect
     @param redirectLimit
     """
     HTTPClientFactory.__init__(self, *p, agent=self.agent, **k)
     self.finished=False
     self._ctx=ctx
     (self._amethod, self._cdic, _) = ctx
     self.eback=self._cdic["e"]
開發者ID:jldupont,項目名稱:dbus_lastfm,代碼行數:18,代碼來源:ws.py

示例13: __init__

# 需要導入模塊: from twisted.web.client import HTTPClientFactory [as 別名]
# 或者: from twisted.web.client.HTTPClientFactory import __init__ [as 別名]
    def __init__(self, url, method='GET', postdata=None, headers=None,
                 agent=None, timeout=0, cookies=None, followRedirect=1):

        self.url = url

        if url in feed_storage:
            lastModified = time.ctime(feed_storage[url][0])
            if headers is not None:
                headers['last-modified'] = lastModified
            else:
                headers = {'last-modified': lastModified}

        HTTPClientFactory.__init__(self, url, method=method, postdata=postdata,
                headers=headers, agent=agent, timeout=timeout, cookies=cookies,
                followRedirect=followRedirect)

        self.waiting = True
        self.deferred = defer.Deferred()
開發者ID:lmacken,項目名稱:moksha,代碼行數:20,代碼來源:feedstream.py

示例14: __init__

# 需要導入模塊: from twisted.web.client import HTTPClientFactory [as 別名]
# 或者: from twisted.web.client.HTTPClientFactory import __init__ [as 別名]
    def __init__(self, request):
        HTTPClientFactory.__init__(self, request)
        
        self.method = request.method
        self.body = request.body or None
        self.headers = request.headers
        self.cookies = request.cookies
        
        self.start_time = time()
        self.status = None
        #self.deferred.addCallback(
        #        lambda data: (data, self.status, self.response_headers))
        self._set_connection_attributes(request)
        self.deferred = defer.Deferred().addCallback(self._build_response, request)

        if self.body is not None:
            self.headers['Content-length'] = [len(self.body)]
            # just in case a broken http/1.1 decides to keep connection alive
            self.headers.setdefault("Connection", "close")
開發者ID:llazzaro,項目名稱:v12,代碼行數:21,代碼來源:client.py

示例15: __init__

# 需要導入模塊: from twisted.web.client import HTTPClientFactory [as 別名]
# 或者: from twisted.web.client.HTTPClientFactory import __init__ [as 別名]
    def __init__(self, *args, **kwargs):
        self.authMechanism = None

        self.contextFactory = kwargs['factory_contextFactory']
        del kwargs['factory_contextFactory']

        self.digestMgr = typed(kwargs['digestMgr'], AbstractHTTPDigestMgr)
        logger.debug('USING DIGEST MANAGER %r', self.digestMgr)
        del kwargs['digestMgr']

        self.goodSSLCertHandler = kwargs['goodSSLCertHandler']
        del kwargs['goodSSLCertHandler']

        self.realm = kwargs['realm']
        del kwargs['realm']

        self.session = kwargs['session']
        del kwargs['session']

        # In fact, C{HTTPClientFactory.__init__} sets or erases
        # C{self.postdata}, so we rewrite it after calling the base class.
        HTTPClientFactory.__init__(self, *args, **kwargs)
開發者ID:shvar,項目名稱:redfs,代碼行數:24,代碼來源:client.py


注:本文中的twisted.web.client.HTTPClientFactory.__init__方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。