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


Python URLGrabber.__init__方法代碼示例

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


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

示例1: __init__

# 需要導入模塊: from urlgrabber.grabber import URLGrabber [as 別名]
# 或者: from urlgrabber.grabber.URLGrabber import __init__ [as 別名]
		def __init__(self, awsAccessKey, awsSecretKey, baseurl):
			self.logger = logging.getLogger("yum.verbose.main")
			self.logger.log(logginglevels.DEBUG_4, "s3: creating empty URLGrabber instance")
			URLGrabber.__init__(self)
			self.logger.log(logginglevels.DEBUG_4, "s3: BotoGrabber init BASE_URL=%s" % baseurl)
			if not baseurl:
				raise Exception("s3: BotoGrabberInit got blank baseurl")
			try:
				baseurl = baseurl[0]
			except:
				pass
			self.s3 = boto.connect_s3(awsAccessKey, awsSecretKey)
			self.baseurl = urlparse(baseurl)
			if hasattr(self.baseurl, 'netloc'):
				self.bucket_name = self.baseurl.netloc
				self.key_prefix = self.baseurl.path[1:]
			else:
				self.bucket_name = self.baseurl[1]
				self.key_prefix = self.baseurl[2]
			if self.key_prefix.startswith("/"):
				self.key_prefix = self.key_prefix[1:]
			m = re.match('(.*)\.s3.*\.amazonaws\.com', self.bucket_name)
			if (m):
				self.bucket_name = m.group(1)
			if sys.stdout.isatty():
				print "%s - %s" % (self.bucket_name, self.key_prefix)
開發者ID:aripringle,項目名稱:yum-s3-plugin,代碼行數:28,代碼來源:s3.py

示例2: __init__

# 需要導入模塊: from urlgrabber.grabber import URLGrabber [as 別名]
# 或者: from urlgrabber.grabber.URLGrabber import __init__ [as 別名]
	def __init__(self, pakfire, *args, **kwargs):
		kwargs.update({
			"quote" : 0,
			"user_agent" : "pakfire/%s" % PAKFIRE_VERSION,

			"ssl_verify_host" : False,
			"ssl_verify_peer" : False,
		})

		if isinstance(pakfire, _Config):
			config = pakfire
		else:
			config = pakfire.config
		self.config = config

		# Set throttle setting.
		bandwidth_throttle = config.get("downloader", "bandwidth_throttle")
		if bandwidth_throttle:
			try:
				bandwidth_throttle = int(bandwidth_throttle)
			except ValueError:
				log.error("Configuration value for bandwidth_throttle is invalid.")
				bandwidth_throttle = 0

			kwargs.update({ "throttle" : bandwidth_throttle })

		# Configure HTTP proxy.
		http_proxy = config.get("downloader", "http_proxy")
		if http_proxy:
			kwargs.update({ "proxies" : { "http" : http_proxy, "https" : http_proxy }})

		URLGrabber.__init__(self, *args, **kwargs)
開發者ID:ipfire,項目名稱:pakfire,代碼行數:34,代碼來源:downloader.py

示例3: __init__

# 需要導入模塊: from urlgrabber.grabber import URLGrabber [as 別名]
# 或者: from urlgrabber.grabber.URLGrabber import __init__ [as 別名]
        def __init__(self, awsAccessKey, awsSecretKey, baseurl):
            self.logger.debug("BotoGrabber init BASE_URL=%s" % baseurl)

            URLGrabber.__init__(self)
            self._handle_baseurl(baseurl)
            self._handle_s3(awsAccessKey, awsSecretKey)
            self._dump_attributes()
            interactive_notify("%s - %s" % (self.bucket_name, self.key_prefix))
開發者ID:toxsick,項目名稱:yum-s3-plugin,代碼行數:10,代碼來源:s3.py

示例4: __init__

# 需要導入模塊: from urlgrabber.grabber import URLGrabber [as 別名]
# 或者: from urlgrabber.grabber.URLGrabber import __init__ [as 別名]
		def __init__(self, awsAccessKey, awsSecretKey, baseurl):
			if self.DEBUG:
				print "creating empty URLGrabber instance"
			URLGrabber.__init__(self)
			if self.DEBUG:
				print "BotoGrabber init BASE_URL=%s" % baseurl
			if not baseurl: raise Exception("BotoGrabberInit got blank baseurl")
			try: baseurl = baseurl[0]
			except: pass
			self.s3 = boto.connect_s3(awsAccessKey, awsSecretKey)
			self.baseurl = urlparse(baseurl)
			if hasattr(self.baseurl, 'netloc'):
				self.bucket_name = self.baseurl.netloc
				self.key_prefix = self.baseurl.path[1:]
			else:
				self.bucket_name = self.baseurl[1]
				self.key_prefix = self.baseurl[2]
			m = re.match('(.*)\.s3.*\.amazonaws\.com', self.bucket_name)
			if (m):
				self.bucket_name = m.group(1)
			if sys.stdout.isatty():
				print "%s - %s" % (self.bucket_name, self.key_prefix)
開發者ID:NumberFour,項目名稱:yum-s3-plugin,代碼行數:24,代碼來源:s3.py

示例5: __init__

# 需要導入模塊: from urlgrabber.grabber import URLGrabber [as 別名]
# 或者: from urlgrabber.grabber.URLGrabber import __init__ [as 別名]
 def __init__(self, progress_obj=None):
     # we cannot use super because we still have to support
     # older urlgrabber versions where URLGrabber is an old-style class
     URLGrabber.__init__(self)
     self.progress_obj = progress_obj
開發者ID:d4s,項目名稱:osc,代碼行數:7,代碼來源:fetch.py


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