本文整理汇总了Python中thumbor.context.Context.request方法的典型用法代码示例。如果您正苦于以下问题:Python Context.request方法的具体用法?Python Context.request怎么用?Python Context.request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thumbor.context.Context
的用法示例。
在下文中一共展示了Context.request方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: topic
# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
def topic(self):
config = Config(
AUTO_WEBP=False,
RESULT_STORAGE_FILE_STORAGE_ROOT_PATH="/tmp/thumbor/result_storages%s" % (random.choice(['', '/'])))
context = Context(config=config)
context.request = RequestParameters(accepts_webp=False)
return FileStorage(context)
示例2: get_context
# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
def get_context(self):
cfg = self.get_config()
ctx = Context(None, cfg, None)
ctx.request = self.get_request()
self.context = ctx
self.file_storage = FileStorage(self.context)
return ctx
示例3: get_context
# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
def get_context(self):
conf = Config()
conf.STATSD_HOST = ''
ctx = Context(config=conf)
ctx.request = RequestParameters()
return ctx
示例4: topic
# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
def topic(self):
config = Config()
context = Context(None, config, Importer(config))
context.request = RequestParameters()
engine = MockInvalidResultEngine(context=context)
return engine.read()
示例5: to_context
# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
def to_context(self):
self.engine = MockEngine((self.source_width, self.source_height))
flip_horizontally = self.target_width < 0
flip_vertically = self.target_height < 0
self.target_width = self.target_width == "orig" and "orig" or abs(self.target_width)
self.target_height = self.target_height == "orig" and "orig" or abs(self.target_height)
importer = Importer(None)
ctx = Context(server=None, config=Config(), importer=importer)
ctx.modules.engine = self.engine
ctx.request = RequestParameters(
buffer=None,
debug=False,
meta=False,
crop={"left": self.crop_left, "top": self.crop_top, "right": self.crop_right, "bottom": self.crop_bottom},
adaptive=self.adaptive,
fit_in=self.fit_in,
horizontal_flip=flip_horizontally,
vertical_flip=flip_vertically,
width=self.target_width,
height=self.target_height,
halign=self.halign,
valign=self.valign,
focal_points=self.focal_points,
smart=True,
extension="JPEG",
filters=[],
quality=80,
image="some.jpeg",
)
return ctx
示例6: get_filter
# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
def get_filter(self, filter_name, params_string="", config_context=None):
config = Config(
FILTERS=[filter_name],
LOADER='thumbor.loaders.file_loader',
FILE_LOADER_ROOT_PATH=join(dirname(realpath(__file__)), 'fixtures', 'filters')
)
importer = Importer(config)
importer.import_modules()
req = RequestParameters()
context = Context(config=config, importer=importer)
context.request = req
context.request.engine = context.modules.engine
if config_context is not None:
config_context(context)
self.context = context
fltr = importer.filters[0]
fltr.pre_compile()
context.transformer = Transformer(context)
return fltr(params_string, context=context)
示例7: get_context
# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
def get_context(self):
conf = Config()
conf.STATSD_HOST = ''
conf.FFMPEG_PATH = which('ffmpeg')
ctx = Context(config=conf)
ctx.request = RequestParameters()
ctx.request.filters.append('gifv')
return ctx
示例8: topic
# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
def topic(self):
conf = Config()
imp = Importer(conf)
imp.filters = [Filter]
ctx = Context(None, conf, imp)
ctx.request = RequestParameters()
filter_instances = ctx.filters_factory.create_instances(ctx, "format(invalid)")
filter_instances[0].run()
示例9: topic
# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
def topic(self):
conf = Config()
imp = Importer(conf)
imp.filters = [Filter]
ctx = Context(None, conf, imp)
ctx.request = RequestParameters()
runner = ctx.filters_factory.create_instances(ctx, "format(invalid)")
filter_instances = runner.filter_instances[thumbor.filters.PHASE_POST_TRANSFORM]
filter_instances[0].run()
示例10: get_optimizer
# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
def get_optimizer(self, filters=None, progressive=False):
conf = Config()
conf.STATSD_HOST = ''
conf.JPEGTRAN_PATH = '/somewhere/jpegtran'
conf.PROGRESSIVE_JPEG = progressive
req = RequestParameters(filters=filters)
ctx = Context(config=conf)
ctx.request = req
optimizer = Optimizer(ctx)
return optimizer
示例11: topic
# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
def topic(self):
conf = Config()
req = RequestParameters(quality=100)
ctx = Context(None, conf, None)
ctx.request = req
filters = [Filter]
compile_filters(filters)
filter_instances = create_instances(ctx, filters, "quality(10)")
filter_instances[0].run_filter()
return ctx.request.quality
示例12: topic
# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
def topic(self, callback):
self.conn = S3Connection()
self.conn.create_bucket(s3_bucket)
config = Config(TC_AWS_RESULT_STORAGE_BUCKET=s3_bucket)
ctx = Context(config=config, server=get_server('ACME-SEC'))
ctx.request = Request
ctx.request.url = 'my-image.jpg'
storage = Storage(ctx)
storage.put(IMAGE_BYTES, callback=callback)
示例13: topic
# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
def topic(self):
self.conn = S3Connection()
self.conn.create_bucket(s3_bucket)
config = Config(RESULT_STORAGE_BUCKET=s3_bucket)
ctx = Context(config=config, server=get_server('ACME-SEC'))
ctx.request = Request
ctx.request.url = 'my-image.jpg'
storage = Storage(ctx)
path = storage.put(IMAGE_BYTES)
return path
示例14: topic
# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
def topic(self):
conf = Config()
imp = Importer(conf)
imp.filters = [Filter]
ctx = Context(None, conf, imp)
ctx.request = RequestParameters()
runner = ctx.filters_factory.create_instances(ctx, "rotate(540)")
filter_instances = runner.filter_instances[thumbor.filters.PHASE_POST_TRANSFORM]
filter_instances[0].engine = RotateEngine()
filter_instances[0].run()
return filter_instances[0].engine.rotate_val
示例15: topic
# 需要导入模块: from thumbor.context import Context [as 别名]
# 或者: from thumbor.context.Context import request [as 别名]
def topic(self):
conf = Config()
conf.ENGINE = 'thumbor.engines.pil'
imp = Importer(conf)
imp.import_modules()
imp.filters = [Filter]
ctx = Context(None, conf, imp)
for item in DATA:
ctx.modules.engine.image = ctx.modules.engine.gen_image(item[1],'#fff')
req = RequestParameters(fit_in=True,width=item[0][0],height=item[0][1])
ctx.request = req
filter_instances = ctx.filters_factory.create_instances(ctx, "fill(blue)")
filter_instances[0].run()
yield (filter_instances[0].engine.image.size,item[2])