本文整理汇总了Python中thumbor.loaders.http_loader.load函数的典型用法代码示例。如果您正苦于以下问题:Python load函数的具体用法?Python load怎么用?Python load使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了load函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: test_load_with_utf8_url
def test_load_with_utf8_url(self):
url = self.get_url(quote(u'/maracujá.jpg'.encode('utf-8')))
config = Config()
ctx = Context(None, config, None)
with expect.error_not_to_happen(UnicodeDecodeError):
loader.load(ctx, url, self.stop)
self.wait()
开发者ID:caeugusmao,项目名称:thumbor,代码行数:8,代码来源:test_http_loader.py
示例2: topic
def topic(self, callback):
url = self.get_url('/')
loader.http_client = self._http_client
config = Config()
config.HTTP_LOADER_FORWARD_USER_AGENT = True
ctx = Context(None, config, None, HandlerMock({"User-Agent": "test-user-agent"}))
loader.load(ctx, url, callback)
开发者ID:xialisun,项目名称:thumbor,代码行数:9,代码来源:http_loader_vows.py
示例3: topic
def topic(self, callback):
url = self.get_url('/')
loader.http_client = self._http_client
config = Config()
config.ALLOWED_SOURCES = ['s.glbimg.com']
ctx = Context(None, config, None)
loader.load(ctx, url, callback)
开发者ID:achellies,项目名称:thumbor,代码行数:9,代码来源:http_loader_vows.py
示例4: test_load_with_user_agent
def test_load_with_user_agent(self):
url = self.get_url('/')
config = Config()
config.HTTP_LOADER_FORWARD_USER_AGENT = True
ctx = Context(None, config, None, HandlerMock({"User-Agent": "test-user-agent"}))
loader.load(ctx, url, self.stop)
result = self.wait()
expect(result).to_be_instance_of(LoaderResult)
expect(result.buffer).to_equal('test-user-agent')
开发者ID:expertise-com,项目名称:thumbor,代码行数:10,代码来源:test_http_loader.py
示例5: topic
def topic(self):
self.async_topic = ""
def get_contents(contents):
self.async_topic = contents
url = self._get_url("/")
loader.load(url, get_contents)
return self.async_topic
开发者ID:douglas,项目名称:thumbor,代码行数:10,代码来源:http_loader_vows.py
示例6: test_load_with_callback
def test_load_with_callback(self):
url = self.get_url('/')
config = Config()
ctx = Context(None, config, None)
loader.load(ctx, url, self.stop)
result = self.wait()
expect(result).to_be_instance_of(LoaderResult)
expect(result.buffer).to_equal('Hello')
expect(result.successful).to_be_true()
开发者ID:expertise-com,项目名称:thumbor,代码行数:10,代码来源:test_http_loader.py
示例7: test_load_with_curl
def test_load_with_curl(self):
url = self.get_url('/')
config = Config()
config.HTTP_LOADER_CURL_ASYNC_HTTP_CLIENT = True
ctx = Context(None, config, None)
loader.load(ctx, url, self.stop)
result = self.wait()
expect(result).to_be_instance_of(LoaderResult)
expect(result.buffer).to_equal('Hello')
expect(result.successful).to_be_true()
开发者ID:expertise-com,项目名称:thumbor,代码行数:11,代码来源:test_http_loader.py
示例8: test_load_with_default_user_agent
def test_load_with_default_user_agent(self):
url = self.get_url("/")
config = Config()
config.HTTP_LOADER_FORWARD_USER_AGENT = True
config.HTTP_LOADER_DEFAULT_USER_AGENT = "DEFAULT_USER_AGENT"
ctx = Context(None, config, None, HandlerMock({}))
loader.load(ctx, url, self.stop)
result = self.wait()
expect(result).to_be_instance_of(LoaderResult)
expect(result.buffer).to_equal("DEFAULT_USER_AGENT")
开发者ID:fun-alex-alex2006hw,项目名称:thumbor,代码行数:11,代码来源:test_http_loader.py
示例9: test_load_without_curl_but_speed_timeout
def test_load_without_curl_but_speed_timeout(self):
url = self.get_url('/')
config = Config()
config.HTTP_LOADER_CURL_LOW_SPEED_TIME = 1
config.HTTP_LOADER_CURL_LOW_SPEED_LIMIT = 1000000000000
ctx = Context(None, config, None)
loader.load(ctx, url, self.stop)
result = self.wait()
expect(result).to_be_instance_of(LoaderResult)
expect(result.buffer).to_equal('Hello')
expect(result.successful).to_be_true()
开发者ID:caeugusmao,项目名称:thumbor,代码行数:12,代码来源:test_http_loader.py
示例10: test_load_with_timeout
def test_load_with_timeout(self):
url = self.get_url('/')
config = Config()
config.HTTP_LOADER_CURL_ASYNC_HTTP_CLIENT = True
config.HTTP_LOADER_REQUEST_TIMEOUT = 1
ctx = Context(None, config, None)
loader.load(ctx, url, self.stop)
result = self.wait()
expect(result).to_be_instance_of(LoaderResult)
expect(result.buffer).to_be_null()
expect(result.successful).to_be_false()
开发者ID:caeugusmao,项目名称:thumbor,代码行数:12,代码来源:test_http_loader.py
示例11: test_load_with_all_headers
def test_load_with_all_headers(self):
url = self.get_url('/')
config = Config()
config.HTTP_LOADER_FORWARD_ALL_HEADERS = True
handler_mock_options = {"X-Test": "123", "DNT": "1", "X-Server": "thumbor"}
ctx = Context(None, config, None, HandlerMock(handler_mock_options))
loader.load(ctx, url, self.stop)
result = self.wait()
expect(result).to_be_instance_of(LoaderResult)
expect(result.buffer).to_include("Dnt:1\n")
expect(result.buffer).to_include("X-Server:thumbor\n")
expect(result.buffer).to_include("X-Test:123\n")
开发者ID:caeugusmao,项目名称:thumbor,代码行数:13,代码来源:test_http_loader.py
示例12: load
def load(context, url, callback):
logger.debug("*** LOADER.load" )
start = datetime.datetime.now()
if HTTP_RE.match(url):
method = 'http'
HttpLoader.load(context, url, callback)
else:
method = 's3'
logger.debug("*** s3")
S3Loader.load(context, url, callback)
finish = datetime.datetime.now()
metric_name = "thumbor.loader.%s.request_time" % method
logger.debug("*** librato submit")
LIBRATO_API.submit(metric_name, (finish - start).total_seconds() * 1000, description="original file request time (ms)")
开发者ID:Jimdo,项目名称:thumbor_botornado,代码行数:14,代码来源:s3_http_loader.py
示例13: test_load_with_some_excluded_headers
def test_load_with_some_excluded_headers(self):
url = self.get_url('/')
config = Config()
handler_mock_options = {
"Accept-Encoding": "gzip",
"User-Agent": "Thumbor",
"Host": "localhost",
"Accept": "*/*",
"X-Server": "thumbor"
}
ctx = Context(None, config, None, HandlerMock(handler_mock_options))
loader.load(ctx, url, self.stop)
result = self.wait()
expect(result).to_be_instance_of(LoaderResult)
expect(result.buffer).Not.to_include("X-Server:thumbor")
开发者ID:caeugusmao,项目名称:thumbor,代码行数:16,代码来源:test_http_loader.py
示例14: test_should_return_a_future
def test_should_return_a_future(self):
url = self.get_url('/')
config = Config()
ctx = Context(None, config, None)
future = loader.load(ctx, url)
expect(isinstance(future, Future)).to_be_true()
开发者ID:expertise-com,项目名称:thumbor,代码行数:7,代码来源:test_http_loader.py
示例15: load
def load(context, url, callback):
enable_http_loader = context.config.get('AWS_ENABLE_HTTP_LOADER', default=False)
if enable_http_loader and 'http' in url:
return http_loader.load(context, url, callback)
url = urllib2.unquote(url)
if context.config.S3_LOADER_BUCKET:
bucket = context.config.S3_LOADER_BUCKET
else:
bucket, url = _get_bucket(url)
if not _validate_bucket(context, bucket):
return callback(None)
bucket_loader = Bucket(
connection=thumbor_aws.connection.get_connection(context),
name=bucket
)
file_key = bucket_loader.get_key(url)
if not file_key:
return callback(None)
return callback(file_key.read())
开发者ID:seanlin0324,项目名称:thumbor_aws,代码行数:26,代码来源:s3_loader.py
示例16: test_load_with_empty_accept
def test_load_with_empty_accept(self):
url = self.get_url('/')
config = Config()
handler_mock_options = {
"Accept-Encoding": "gzip",
"User-Agent": "Thumbor",
"Host": "localhost",
"Accept": "",
"X-Server": "thumbor"
}
ctx = Context(None, config, None, HandlerMock(handler_mock_options))
loader.load(ctx, url, self.stop)
result = self.wait()
expect(result).to_be_instance_of(LoaderResult)
expect(result.buffer).to_include("Accept:image/*;q=0.9,*/*;q=0.1\n")
开发者ID:caeugusmao,项目名称:thumbor,代码行数:16,代码来源:test_http_loader.py
示例17: test_before_expiration_returns_something
def test_before_expiration_returns_something(self):
options.STORAGE_EXPIRATION_SECONDS = 1000
image_url = 'www.globo.com/media/globocom/img/sprite1.png?8'
http_loaded = http.load(image_url)
storage = Storage()
storage.put(image_url, http_loaded)
assert storage.get(image_url)
开发者ID:cezarsa,项目名称:thumbor,代码行数:7,代码来源:test_mysql_storage.py
示例18: test_stores_image_does_not_store_crypt_key_if_not_in_options
def test_stores_image_does_not_store_crypt_key_if_not_in_options(self):
rm_storage()
options.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = False
image_url = 'www.globo.com/media/globocom/img/sprite1.png'
http_loaded = http.load(image_url)
storage = file_storage.Storage()
storage.put(image_url, http_loaded)
assert not exists('/tmp/thumbor/storage/www.globo.com/media/globocom/img/sprite1.txt'), 'crypto key was found into the storage'
开发者ID:cezarsa,项目名称:thumbor,代码行数:8,代码来源:test_file_storage.py
示例19: test_stores_image
def test_stores_image(self):
rm_storage()
options.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = False
image_url = 'www.globo.com/media/globocom/img/sprite1.png'
http_loaded = http.load(image_url)
storage = Storage()
storage.put(image_url, http_loaded)
assert collection.find_one({'path': image_url}), 'image not found into the storage'
开发者ID:cezarsa,项目名称:thumbor,代码行数:8,代码来源:test_mongo_storage.py
示例20: test_get_crypto_for_url
def test_get_crypto_for_url(self):
image_url = 'www.globo.com/media/globocom/img/sprite1.png?6'
http_loaded = http.load(image_url)
storage = Storage()
storage.put(image_url, http_loaded)
assert storage.get_crypto(image_url) == options.SECURITY_KEY
开发者ID:cezarsa,项目名称:thumbor,代码行数:8,代码来源:test_mysql_storage.py
注:本文中的thumbor.loaders.http_loader.load函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论