本文整理汇总了Python中thumbor.config.Config类的典型用法代码示例。如果您正苦于以下问题:Python Config类的具体用法?Python Config怎么用?Python Config使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Config类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: get_app
def get_app(self):
cfg = Config(SECURITY_KEY='ACME-SEC')
server_params = ServerParameters(None, None, None, None, None, None)
server_params.gifsicle_path = which('gifsicle')
cfg.DETECTORS = [
'thumbor.detectors.face_detector',
'thumbor.detectors.profile_detector',
'thumbor.detectors.glasses_detector',
'thumbor.detectors.feature_detector',
]
cfg.STORAGE = 'thumbor.storages.no_storage'
cfg.LOADER = 'thumbor.loaders.file_loader'
cfg.FILE_LOADER_ROOT_PATH = os.path.join(os.path.dirname(__file__), 'imgs')
cfg.ENGINE = getattr(self, 'engine', None)
cfg.USE_GIFSICLE_ENGINE = True
cfg.FFMPEG_PATH = which('ffmpeg')
cfg.ENGINE_THREADPOOL_SIZE = 10
cfg.OPTIMIZERS = [
'thumbor.optimizers.gifv',
]
if not cfg.ENGINE:
return None
importer = Importer(cfg)
importer.import_modules()
ctx = Context(server_params, cfg, importer)
application = ThumborServiceApp(ctx)
return application
示例2: test_with_aliased_aliases
def test_with_aliased_aliases(self):
Config.alias('STORAGE_ALIAS', 'STORAGE')
Config.alias('STORAGE_ALIAS_ALIAS', 'STORAGE_ALIAS')
cfg = Config(STORAGE_ALIAS_ALIAS='z')
expect(cfg.STORAGE).to_equal('z')
expect(cfg.STORAGE_ALIAS).to_equal('z')
expect(cfg.STORAGE_ALIAS_ALIAS).to_equal('z')
示例3: topic
def topic(self):
conf = Config()
conf.ENGINE = 'thumbor.engines.pil'
imp = Importer(conf)
imp.import_modules()
imp.filters = [Filter]
return Context(None, conf, imp)
示例4: test_with_allowed_sources
def test_with_allowed_sources(self):
config = Config()
config.ALLOWED_SOURCES = [
's.glbimg.com',
re.compile(r'https://www\.google\.com/img/.*')
]
ctx = Context(None, config, None)
expect(
loader.validate(
ctx,
'http://www.google.com/logo.jpg'
)
).to_be_false()
expect(
loader.validate(
ctx,
'http://s2.glbimg.com/logo.jpg'
)
).to_be_false()
expect(
loader.validate(
ctx,
'/glob=:sfoir%20%20%3Co-pmb%20%20%20%20_%20%20%20%200%20%20g.-%3E%3Ca%20hplass='
)
).to_be_false()
expect(
loader.validate(
ctx,
'https://www.google.com/img/logo.jpg'
)
).to_be_true()
expect(
loader.validate(ctx, 'http://s.glbimg.com/logo.jpg')).to_be_true()
示例5: get_context
def get_context():
conf = Config()
conf.ENGINE = "thumbor.engines.pil"
imp = Importer(conf)
imp.import_modules()
imp.filters = [Filter]
return Context(None, conf, imp)
示例6: get_context
def get_context(self):
cfg = Config(SECURITY_KEY="ACME-SEC", ENGINE="thumbor.engines.pil", IMAGE_METADATA_READ_FORMATS="exif,xmp")
cfg.LOADER = "thumbor.loaders.file_loader"
cfg.FILE_LOADER_ROOT_PATH = STORAGE_PATH
cfg.STORAGE = "thumbor.storages.no_storage"
return Context(config=cfg)
示例7: get_app
def get_app(self):
storage_path = '/tmp/thumbor-engines-test/'
if exists(storage_path):
rmtree(storage_path)
self.timeout_handle = None
cfg = Config(SECURITY_KEY='ACME-SEC', FILE_STORAGE_ROOT_PATH=storage_path)
server_params = ServerParameters(None, None, None, None, None, None)
cfg.DETECTORS = [
'thumbor.detectors.face_detector',
'thumbor.detectors.profile_detector',
'thumbor.detectors.glasses_detector',
'thumbor.detectors.feature_detector',
]
conf_key = self._testMethodName.split('__')[1]
conf = CONFS.get(conf_key, None)
if conf:
for key, value in conf.items():
setattr(cfg, key, value)
importer = Importer(cfg)
importer.import_modules()
ctx = Context(server_params, cfg, importer)
application = ThumborServiceApp(ctx)
return application
示例8: get_config
def get_config(self):
cfg = Config(SECURITY_KEY='ACME-SEC')
cfg.LOADER = "thumbor.loaders.file_loader"
cfg.FILE_LOADER_ROOT_PATH = self.loader_path
cfg.STORAGE = "thumbor.storages.no_storage"
cfg.AUTO_WEBP = True
return cfg
示例9: test_with_aliased_aliases_with_default_values
def test_with_aliased_aliases_with_default_values(self):
Config.alias('STORAGE_ALIAS', 'STORAGE')
Config.alias('STORAGE_ALIAS_ALIAS', 'STORAGE_ALIAS')
cfg = Config()
expect(cfg.STORAGE).to_equal(self.get_default_storage())
expect(cfg.STORAGE_ALIAS).to_equal(self.get_default_storage())
expect(cfg.STORAGE_ALIAS_ALIAS).to_equal(self.get_default_storage())
expect(cfg.__class__.__module__).to_equal('derpconf.config')
示例10: get_context
def get_context(self):
cfg = Config()
cfg.HEALTHCHECK_ROUTE = '/'
importer = Importer(cfg)
importer.import_modules()
return Context(None, cfg, importer)
示例11: topic
def topic(self):
conf = Config(MONGO_STORAGE_SERVER_PORT=7777, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=False)
server = get_server('')
storage = MongoStorage(Context(config=conf, server=server))
storage.put(IMAGE_URL % 13, IMAGE_BYTES)
conf.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = True
storage.put_crypto(IMAGE_URL % 13)
示例12: get_config
def get_config(self):
cfg = Config(SECURITY_KEY='ACME-SEC')
cfg.COMMUNITY_EXTENSIONS = [
'wikimedia_thumbor.handler.healthcheck'
]
return cfg
开发者ID:wikimedia,项目名称:operations-debs-python-thumbor-wikimedia,代码行数:8,代码来源:test_healthcheck_handler.py
示例13: get_context
def get_context(self):
cfg = Config(
SECURITY_KEY='ACME-SEC',
ENGINE='thumbor.engines',
)
cfg.STORAGE = 'thumbor.storages.no_storage'
return Context(config=cfg)
示例14: get_optimizer
def get_optimizer(self):
conf = Config()
conf.STATSD_HOST = ''
conf.JPEGTRAN_PATH = which('jpegtran')
ctx = Context(config=conf)
optimizer = Optimizer(ctx)
return optimizer
示例15: topic
def topic(self):
conf = Config()
conf.METRICS = 'tc_librato.metrics.librato_metrics'
conf.LIBRATO_USER = 'test'
conf.LIBRATO_TOKEN = 'test'
conf.LIBRATO_NAME_PREFIX = 'test'
imp = Importer(conf)
imp.import_modules()
return Context(None, conf, imp)