本文整理汇总了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)
示例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)
示例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))
示例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)
示例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