本文整理汇总了Python中thumbor.importer.Importer类的典型用法代码示例。如果您正苦于以下问题:Python Importer类的具体用法?Python Importer怎么用?Python Importer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Importer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_import_item_should_be_proper_item
def test_import_item_should_be_proper_item(self):
importer = Importer(self.get_config())
importer.import_modules()
data = {
'ENGINE': pil_engine,
'GIF_ENGINE': gif_engine,
'LOADER': http_loader,
'STORAGE': file_storage,
'UPLOAD_PHOTO_STORAGE': file_storage,
'RESULT_STORAGE': result_file_storage,
'DETECTORS': (face_detector,),
'FILTERS': (rgb_filter,),
}
for key, value in data.iteritems():
prop, default_value = (None, None)
if hasattr(importer, key.lower()):
prop, default_value = (getattr(importer, key.lower()), value)
if prop is tuple:
for index, item in enumerate(prop):
expect(item).not_to_be_null()
expect(item).to_equal(default_value[index])
else:
expect(prop).not_to_be_null()
expect(prop).to_equal(default_value)
示例2: 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)
示例3: main
def main(arguments=None):
"""Runs thumbor server with the specified arguments."""
server_parameters = get_server_parameters(arguments)
logging.basicConfig(level=getattr(logging, server_parameters.log_level.upper()))
lookup_paths = [os.curdir, expanduser("~"), "/etc/", dirname(__file__)]
config = Config.load(server_parameters.config_path, conf_name="thumbor.conf", lookup_paths=lookup_paths)
importer = Importer(config)
importer.import_modules()
if server_parameters.security_key is None:
server_parameters.security_key = config.SECURITY_KEY
if not isinstance(server_parameters.security_key, basestring):
raise RuntimeError(
"No security key was found for this instance of thumbor. Please provide one using the conf file or a security key file."
)
context = Context(server=server_parameters, config=config, importer=importer)
application = ThumborServiceApp(context)
server = HTTPServer(application)
server.bind(context.server.port, context.server.ip)
server.start(1)
try:
logging.debug("thumbor running at %s:%d" % (context.server.ip, context.server.port))
tornado.ioloop.IOLoop.instance().start()
except KeyboardInterrupt:
print
print "-- thumbor closed by user interruption --"
示例4: setUp
def setUp(self, *args, **kwargs):
super(FakeRotateEngineRotateFilterTestCase, self).setUp(*args, **kwargs)
conf = Config()
imp = Importer(conf)
imp.filters = [Filter]
self.context = Context(None, conf, imp)
self.context.request = RequestParameters()
示例5: get_app
def get_app(self):
cfg = Config.load(fixture_for("encrypted_handler_conf.py"))
importer = Importer(cfg)
importer.import_modules()
ctx = Context(None, cfg, importer)
application = ThumborServiceApp(ctx)
return application
示例6: 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
示例7: 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)
示例8: 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
示例9: main
def main(arguments=None):
'''Runs thumbor server with the specified arguments.'''
server_parameters = get_server_parameters(arguments)
logging.basicConfig(level=getattr(logging, server_parameters.log_level.upper()))
config = Config.load(server_parameters.config_path)
importer = Importer(config)
importer.import_modules()
if server_parameters.security_key is not None:
config.SECURITY_KEY = server_parameters.security_key
if not isinstance(config.SECURITY_KEY, basestring):
raise RuntimeError('No security key was found for this instance of thumbor. Please provide one using the conf file or a security key file.')
context = Context(server=server_parameters, config=config, importer=importer)
application = ThumborServiceApp(context)
server = HTTPServer(application)
server.bind(context.server.port, context.server.ip)
server.start(1)
try:
tornado.ioloop.IOLoop.instance().start()
except KeyboardInterrupt:
print
print "-- thumbor closed by user interruption --"
示例10: get_filter
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)
示例11: test_can_create_context_with_importer
def test_can_create_context_with_importer(self):
cfg = Config()
importer = Importer(cfg)
importer.import_modules()
ctx = Context(config=cfg, importer=importer)
expect(ctx.modules).not_to_be_null()
expect(ctx.modules.importer).to_equal(importer)
示例12: get_context
def get_context(self):
cfg = Config()
cfg.HEALTHCHECK_ROUTE = '/'
importer = Importer(cfg)
importer.import_modules()
return Context(None, cfg, importer)
示例13: get_importer
def get_importer(config):
importer = Importer(config)
importer.import_modules()
if importer.error_handler_class is not None:
importer.error_handler = importer.error_handler_class(config)
return importer
示例14: test_single_item_should_equal_file_storage
def test_single_item_should_equal_file_storage(self):
importer = Importer(None)
importer.import_item(
config_key='file_storage',
item_value='thumbor.storages.file_storage',
class_name='Storage'
)
expect(importer.file_storage).to_equal(file_storage)
示例15: topic
def topic(self, test_item):
test_data, config = test_item
importer = Importer(config)
importer.import_modules()
if hasattr(importer, test_data[0].lower()):
return (getattr(importer, test_data[0].lower()), test_data[1])
return (None, None)