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 --"
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)
def topic(self): conf = Config() conf.ENGINE = 'thumbor.engines.pil' imp = Importer(conf) imp.import_modules() imp.filters = [Filter] return Context(None, conf, imp)
def get_context(): conf = Config() conf.ENGINE = "thumbor.engines.pil" imp = Importer(conf) imp.import_modules() imp.filters = [Filter] return Context(None, conf, imp)
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
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
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 --"
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)
def main(arguments=None): """Runs thumbor server with the specified arguments.""" server_parameters = get_server_parameters(arguments) lookup_paths = [os.curdir, expanduser("~"), "/etc/", dirname(__file__)] config = Config.load( server_parameters.config_path, conf_name="thumbor.conf", lookup_paths=lookup_paths, ) logging.basicConfig( level=getattr(logging, server_parameters.log_level.upper()), format=config.THUMBOR_LOG_FORMAT, datefmt=config.THUMBOR_LOG_DATE_FORMAT, ) importer = Importer(config) importer.import_modules() if importer.error_handler_class is not None: importer.error_handler = importer.error_handler_class(config) 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 = importer.import_class(server_parameters.app_class)(context) server = HTTPServer(application) if context.server.fd is not None: fd_number = get_as_integer(context.server.fd) if fd_number is None: with open(context.server.fd, "r") as sock: fd_number = sock.fileno() sock = socket.fromfd(fd_number, socket.AF_UNIX, socket.SOCK_STREAM) server.add_socket(sock) else: 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("-- thumbor closed by user interruption --")
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
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
def get_context(self): cfg = Config() cfg.HEALTHCHECK_ROUTE = '/' importer = Importer(cfg) importer.import_modules() return Context(None, cfg, 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)
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)
def get_app(table): cfg = Config(HBASE_STORAGE_TABLE=table, HBASE_STORAGE_SERVER_PORT=9090, STORAGE="thumbor_hbase.storage") importer = Importer(cfg) importer.import_modules() server = ServerParameters(8888, "localhost", "thumbor.conf", None, "info", None) ctx = Context(server, cfg, importer) application = ThumborServiceApp(ctx) return application
def get_app(self): cfg = Config.load(fixture_for('encrypted_handler_conf.py')) server_params = ServerParameters(None, None, None, None, None, None) server_params.security_key = 'HandlerVows' importer = Importer(cfg) importer.import_modules() ctx = Context(server_params, cfg, importer) application = ThumborServiceApp(ctx) return application
def topic(self): conf = Config() conf.METRICS = 'tc_librato.metrics.librato_metrics' conf.LIBRATO_USER = '******' conf.LIBRATO_TOKEN = 'test' conf.LIBRATO_NAME_PREFIX = 'test' imp = Importer(conf) imp.import_modules() return Context(None, conf, imp)
def get_context(self): cfg = Config(SECURITY_KEY='ACME-SEC') cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = self.loader_path importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' return Context(server, cfg, importer)
def main(arguments=None): '''Runs thumbor server with the specified arguments.''' server_parameters = get_server_parameters(arguments) lookup_paths = [os.curdir, expanduser('~'), '/etc/', dirname(__file__)] config = Config.load(server_parameters.config_path, conf_name='thumbor.conf', lookup_paths=lookup_paths) logging.basicConfig( level=getattr(logging, server_parameters.log_level.upper()), format=config.THUMBOR_LOG_FORMAT, datefmt=config.THUMBOR_LOG_DATE_FORMAT ) importer = Importer(config) importer.import_modules() if importer.error_handler_class is not None: importer.error_handler = importer.error_handler_class(config) 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 = importer.import_class(server_parameters.app_class)(context) server = HTTPServer(application) if context.server.fd is not None: sock = socket.fromfd(context.server.fd, socket.AF_INET | socket.AF_INET6, socket.SOCK_STREAM) server.add_socket(sock) else: 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 --"
def get_context(self): cfg = Config(SECURITY_KEY="ACME-SEC") cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = self.loader_path cfg.ENABLE_ETAGS = False importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, "localhost", "thumbor.conf", None, "info", None) server.security_key = "ACME-SEC" return Context(server, cfg, importer)
def get_app(self): server_params = ServerParameters(None, None, None, None, None, None) cfg = self.get_config() importer = Importer(cfg) importer.import_modules() self.ctx = Context(server_params, cfg, importer) application = App(self.ctx) return application
def get_app(self): cfg = Config() cfg.UPLOAD_ENABLED = True cfg.UPLOAD_PHOTO_STORAGE = 'thumbor.storages.file_storage' cfg.FILE_STORAGE_ROOT_PATH = file_storage_root_path cfg.UPLOAD_DELETE_ALLOWED = False importer = Importer(cfg) importer.import_modules() ctx = Context(None, cfg, importer) application = ThumborServiceApp(ctx) return application
def get_app(self): cfg = Config() cfg.ENABLE_ORIGINAL_PHOTO_UPLOAD = True cfg.ORIGINAL_PHOTO_STORAGE = 'thumbor.storages.file_storage' cfg.FILE_STORAGE_ROOT_PATH = storage_path cfg.ALLOW_ORIGINAL_PHOTO_DELETION = False importer = Importer(cfg) importer.import_modules() ctx = Context(None, cfg, importer) application = ThumborServiceApp(ctx) return application
def get_app(self): cfg = Config(SECURITY_KEY='ACME-SEC') cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = storage_path importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' ctx = Context(server, cfg, importer) application = ThumborServiceApp(ctx) return application
def get_app(self): cfg = Config() cfg.UPLOAD_ENABLED = True cfg.UPLOAD_PUT_ALLOWED = True cfg.UPLOAD_PHOTO_STORAGE = 'thumbor.storages.file_storage' cfg.FILE_STORAGE_ROOT_PATH = storage_path cfg.MIN_WIDTH = 40 cfg.MIN_HEIGHT = 40 importer = Importer(cfg) importer.import_modules() ctx = Context(None, cfg, importer) application = ThumborServiceApp(ctx) return application
def get_context(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.file_storage" cfg.FILE_STORAGE_ROOT_PATH = self.root_path cfg.QUALITY = 'keep' cfg.SVG_DPI = 200 importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' return Context(server, cfg, importer)
def get_context(self): file_storage_root_path = '/tmp/thumbor/storage' if exists(file_storage_root_path): rmtree(file_storage_root_path) cfg = Config() cfg.USE_BLACKLIST = True cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = abspath(join(dirname(__file__), '../fixtures/images/')) cfg.STORAGE = 'thumbor.storages.file_storage' cfg.FILE_STORAGE_ROOT_PATH = file_storage_root_path importer = Importer(cfg) importer.import_modules() return Context(None, cfg, importer)
def get_context(self): cfg = Config(SECURITY_KEY='ACME-SEC') cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = self.loader_path cfg.AUTO_WEBP = True cfg.USE_GIFSICLE_ENGINE = True importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' ctx = Context(server, cfg, importer) ctx.server.gifsicle_path = which('gifsicle') return ctx
def get_app(self): cfg = Config(SECURITY_KEY="ACME-SEC") cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = storage_path cfg.ALLOW_UNSAFE_URL = False importer = Importer(cfg) importer.import_modules() server = ServerParameters(8890, "localhost", "thumbor.conf", None, "info", None) server.security_key = "ACME-SEC" ctx = Context(server, cfg, importer) application = ThumborServiceApp(ctx) return application
def get_context(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.RESPECT_ORIENTATION = True importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' self.context = Context(server, cfg, importer) self.context.server.gifsicle_path = which('gifsicle') return self.context
def get_context(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 cfg.USE_GIFSICLE_ENGINE = True importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' ctx = Context(server, cfg, importer) ctx.server.gifsicle_path = which('gifsicle') return ctx
def get_app(self): cfg = Config(SECURITY_KEY='ACME-SEC') cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = storage_path cfg.ALLOW_UNSAFE_URL = False cfg.ALLOW_OLD_URLS = True importer = Importer(cfg) importer.import_modules() server = ServerParameters(8890, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' ctx = Context(server, cfg, importer) application = ThumborServiceApp(ctx) return application
def main(arguments=None): '''Runs thumbor server with the specified arguments.''' server_parameters = get_server_parameters(arguments) lookup_paths = [os.curdir, expanduser('~'), '/etc/', dirname(__file__)] config = Config.load(server_parameters.config_path, conf_name='thumbor.conf', lookup_paths=lookup_paths) logging.basicConfig(level=getattr(logging, server_parameters.log_level.upper()), format=config.THUMBOR_LOG_FORMAT, datefmt=config.THUMBOR_LOG_DATE_FORMAT) importer = Importer(config) importer.import_modules() if importer.error_handler_class is not None: importer.error_handler = importer.error_handler_class(config) 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 = importer.import_class(server_parameters.app_class)(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 --"
def get_context(self): cfg = Config(SECURITY_KEY='MYKEY') cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = self.loader_path cfg.ALLOW_UNSAFE_URL = False cfg.ALLOW_OLD_URLS = True cfg.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = True cfg.STORAGE = 'thumbor.storages.file_storage' cfg.STORAGE_FILE_STORAGE_ROOT_PATH = self.root_path importer = Importer(cfg) importer.import_modules() server = ServerParameters(8891, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'MYKEY' return Context(server, cfg, importer)
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])
def get_context(self): cfg = Config(SECURITY_KEY='ACME-SEC') cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = self.loader_path cfg.RESULT_STORAGE = 'thumbor.result_storages.file_storage' cfg.RESULT_STORAGE_EXPIRATION_SECONDS = 60 cfg.RESULT_STORAGE_FILE_STORAGE_ROOT_PATH = self.root_path cfg.AUTO_WEBP = True importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' ctx = Context(server, cfg, importer) ctx.request = self.get_request() ctx.server.gifsicle_path = which('gifsicle') return ctx
def get_app(self): self.default_filename = 'image' cfg = Config() cfg.UPLOAD_ENABLED = True cfg.UPLOAD_PHOTO_STORAGE = 'thumbor.storages.file_storage' cfg.FILE_STORAGE_ROOT_PATH = file_storage_root_path cfg.UPLOAD_DELETE_ALLOWED = True cfg.UPLOAD_PUT_ALLOWED = False cfg.UPLOAD_DEFAULT_FILENAME = self.default_filename importer = Importer(cfg) importer.import_modules() ctx = Context(None, cfg, importer) application = ThumborServiceApp(ctx) return application
def get_context(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 cfg.USE_GIFSICLE_ENGINE = True cfg.RESPECT_ORIENTATION = True importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, "localhost", "thumbor.conf", None, "info", None) server.security_key = "ACME-SEC" ctx = Context(server, cfg, importer) ctx.server.gifsicle_path = which("gifsicle") return ctx
def get_context(self): cfg = Config(SECURITY_KEY='ACME-SEC') cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = self.loader_path cfg.JPEGTRAN_PATH = which('jpegtran') cfg.PROGRESSIVE_JPEG = True, cfg.RESULT_STORAGE_STORES_UNSAFE = True, cfg.OPTIMIZERS = [ 'thumbor.optimizers.jpegtran', ] importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' ctx = Context(server, cfg, importer) return ctx
def get_context(self): cfg = Config(SECURITY_KEY='ACME-SEC') cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = self.loader_path cfg.RESULT_STORAGE = 'thumbor.result_storages.file_storage' cfg.RESULT_STORAGE_EXPIRATION_SECONDS = 60 cfg.RESULT_STORAGE_FILE_STORAGE_ROOT_PATH = self.root_path cfg.SEND_IF_MODIFIED_LAST_MODIFIED_HEADERS = True importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' return Context(server, cfg, importer)
def get_context(self): cfg = Config(SECURITY_KEY='ACME-SEC') cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = self.loader_path cfg.FFMPEG_PATH = which('ffmpeg') cfg.OPTIMIZERS = [ 'thumbor.optimizers.gifv', ] importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' ctx = Context(server, cfg, importer) ctx.server.gifsicle_path = which('gifsicle') return ctx
def get_app(self): cfg = Config(SECURITY_KEY='ACME-SEC') cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = storage_path cfg.STORAGE = "thumbor.storages.file_storage" cfg.FILE_STORAGE_ROOT_PATH = FILE_STORAGE_ROOT_PATH if exists(FILE_STORAGE_ROOT_PATH): rmtree(FILE_STORAGE_ROOT_PATH) importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' ctx = Context(server, cfg, importer) application = ThumborServiceApp(ctx) return application
def get_app(self): cfg = Config(SECURITY_KEY='ACME-SEC') cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = storage_path cfg.AUTO_WEBP = True importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' ctx = Context(server, cfg, importer) ctx.server.gifsicle_path = which('gifsicle') application = ThumborServiceApp(ctx) self.engine = PILEngine(ctx) return application
def get_app(self): cfg = Config(SECURITY_KEY='ACME-SEC') cfg.LOADER = 'thumbor.loaders.file_loader' cfg.FILE_LOADER_ROOT_PATH = storage_path cfg.OPTIMIZERS = [ 'thumbor_plugins.optimizers.jp2', ] importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' ctx = Context(server, cfg, importer) application = ThumborServiceApp(ctx) self.engine = PILEngine(ctx) return application
def get_app(self): cfg = Config(SECURITY_KEY='ACME-SEC', LOADER='thumbor.loaders.file_loader', RESULT_STORAGE='thumbor.result_storages.file_storage', RESULT_STORAGE_STORES_UNSAFE=True, RESULT_STORAGE_EXPIRATION_SECONDS=2592000, FILE_LOADER_ROOT_PATH=storage_path, OPTIMIZERS=['thumbor.optimizers.jpegtran']) importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' ctx = Context(server, cfg, importer) application = ThumborServiceApp(ctx) return application
def get_context(self): cfg = Config(SECURITY_KEY="ACME-SEC") cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = self.loader_path cfg.FFMPEG_PATH = which("ffmpeg") cfg.OPTIMIZERS = [ "thumbor.optimizers.gifv", ] importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, "localhost", "thumbor.conf", None, "info", None) server.security_key = "ACME-SEC" ctx = Context(server, cfg, importer) ctx.server.gifsicle_path = which("gifsicle") return ctx
def get_context(self): cfg = Config(SECURITY_KEY="ACME-SEC") cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = self.loader_path cfg.JPEGTRAN_PATH = which("jpegtran") cfg.PROGRESSIVE_JPEG = (True,) cfg.RESULT_STORAGE_STORES_UNSAFE = (True,) cfg.OPTIMIZERS = [ "thumbor.optimizers.jpegtran", ] importer = Importer(cfg) importer.import_modules() server = ServerParameters( 8889, "localhost", "thumbor.conf", None, "info", None ) server.security_key = "ACME-SEC" ctx = Context(server, cfg, importer) return ctx
def get_context(self): cfg = Config(SECURITY_KEY="ACME-SEC") cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = self.loader_path cfg.RESULT_STORAGE = "thumbor.result_storages.file_storage" cfg.RESULT_STORAGE_EXPIRATION_SECONDS = 60 cfg.RESULT_STORAGE_FILE_STORAGE_ROOT_PATH = self.root_path cfg.AUTO_WEBP = True importer = Importer(cfg) importer.import_modules() server = ServerParameters( 8889, "localhost", "thumbor.conf", None, "info", None ) server.security_key = "ACME-SEC" ctx = Context(server, cfg, importer) return ctx
async def test_watermark_validate_allowed_source(self): config = Config( ALLOWED_SOURCES=[ "s.glbimg.com", ], LOADER="thumbor.loaders.http_loader", ) importer = Importer(config) importer.import_modules() context = Context(config=config, importer=importer) filter_instance = watermark.Filter("", context) expect( filter_instance.validate("https://s2.glbimg.com/logo.jpg") ).to_be_false() expect( filter_instance.validate("https://s.glbimg.com/logo.jpg") ).to_be_true()
def get_app(self): file_storage_root_path = '/tmp/thumbor-vows/storage' if exists(file_storage_root_path): rmtree(file_storage_root_path) cfg = Config() cfg.USE_BLACKLIST = True cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = abspath(join(dirname(__file__), 'fixtures/')) cfg.STORAGE = 'thumbor.storages.file_storage' cfg.FILE_STORAGE_ROOT_PATH = file_storage_root_path importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'debug', None) ctx = Context(server, cfg, importer) application = ThumborServiceApp(ctx) return application
def get_filter(self, filter_name, params_string="", config_context=None): config = Config(FILTERS=[filter_name], ) 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) fltr = importer.filters[0] fltr.pre_compile() context.transformer = Transformer(context) return fltr(params_string, context=context)
def get_app(self): cfg = Config( SECURITY_KEY='ACME-SEC', LOADER='thumbor.loaders.file_loader', RESULT_STORAGE_STORES_UNSAFE=False, RESULT_STORAGE_EXPIRATION_SECONDS=2592000, FILE_LOADER_ROOT_PATH=storage_path, OPTIMIZERS=[], USE_GIFSICLE_ENGINE=True, ) importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' server.gifsicle_path = which('gifsicle') ctx = Context(server, cfg, importer) application = ThumborServiceApp(ctx) return application
async def test_should_raise_for_invalid_compatibility_storage(self): config = Config( FILE_LOADER_ROOT_PATH=STORAGE_PATH, STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True, ) importer = Importer(config) importer.import_modules() server = ServerParameters(8889, "localhost", "thumbor.conf", None, "info", None) server.security_key = "ACME-SEC" ctx = Context(server, config=config, importer=importer) storage = Storage(ctx) with expect.error_to_happen( RuntimeError, message=( "The 'COMPATIBILITY_LEGACY_STORAGE' configuration should " "point to a valid storage when using compatibility storage." ), ): await storage.get("invalid-path")
def get_app(self): cfg = Config(SECURITY_KEY='MYKEY') cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = storage_path cfg.ALLOW_UNSAFE_URL = False cfg.ALLOW_OLD_URLS = True cfg.STORES_CRYPTO_KEY_FOR_EACH_IMAGE = True importer = Importer(cfg) importer.import_modules() server = ServerParameters(8891, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'MYKEY' ctx = Context(server, cfg, importer) application = ThumborServiceApp(ctx) storage = FileStorage(Context(config=cfg, server=server)) # Store fixtures (image.jpg and image.txt) into the file storage storage.put('image.jpg', open(join(storage_path, 'image.jpg')).read()) storage.put_crypto('image.jpg') # Write a file on the file storage containing the security key return application
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) fltr = importer.filters[0] fltr.pre_compile() context.transformer = Transformer(context) return fltr(params_string, context=context)
def context(config): config.ENGINE = 'thumbor_video_engine.engines.video' importer = Importer(config) importer.import_modules() server = ServerParameters(None, 'localhost', 'thumbor.conf', None, 'info', config.APP_CLASS, gifsicle_path=which('gifsicle')) server.security_key = config.SECURITY_KEY req = RequestParameters() configure_log(config, 'DEBUG') with Context(server=server, config=config, importer=importer) as context: context.request = req context.request.engine = context.modules.engine yield context
def test_can_create_context_importer(self): cfg = Config(RESULT_STORAGE='thumbor.result_storages.file_storage', ) importer = Importer(cfg) importer.import_modules() ctx = Context(config=cfg, importer=importer) ctx_importer = ContextImporter(ctx, importer) expect(ctx_importer.context).to_equal(ctx) expect(ctx_importer.importer).to_equal(importer) expect(ctx_importer.engine).to_be_instance_of(importer.engine) expect(ctx_importer.gif_engine).to_be_instance_of(importer.gif_engine) expect(ctx_importer.storage).to_be_instance_of(importer.storage) expect(ctx_importer.result_storage).to_be_instance_of( importer.result_storage) expect(ctx_importer.upload_photo_storage).to_be_instance_of( importer.upload_photo_storage) expect(ctx_importer.loader).to_equal(importer.loader) expect(ctx_importer.detectors).to_equal(importer.detectors) expect(ctx_importer.filters).to_equal(importer.filters) expect(ctx_importer.optimizers).to_equal(importer.optimizers) expect(ctx_importer.url_signer).to_equal(importer.url_signer)
def get_app(self): cfg = Config(SECURITY_KEY='ACME-SEC') 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', ] 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) if not cfg.ENGINE: return None importer = Importer(cfg) importer.import_modules() ctx = Context(server_params, cfg, importer) application = ThumborServiceApp(ctx) return application
def get_context(self): cfg = Config(SECURITY_KEY='ACME-SEC') cfg.LOADER = "tests.stub_file_loader" cfg.STORAGE = "thumbor.storages.file_storage" cfg.FILE_STORAGE_ROOT_PATH = self.root_path cfg.QUALITY = 'keep' cfg.SVG_DPI = 200 self.image = 'http://test.domain/image.jpg' self.quoted_image = quote(self.image, safe='') self.transform = '400x400/smart' self.signature = UrlSigner(security_key="ACME-SEC").signature( '%s/%s' % (self.transform, self.quoted_image)) self.signed_prefix = "/%s/%s" % (self.signature, self.transform) self.full_image = "/%s/%s/%s" % (self.signature, self.transform, self.quoted_image) importer = Importer(cfg) importer.import_modules() server = ServerParameters( 8889, 'localhost', 'thumbor.conf', None, 'info', 'thumbor_flexible_validation.app.ThumborServiceProxy') server.security_key = 'ACME-SEC' return Context(server, cfg, importer)
def get_context(self): cfg = Config(SECURITY_KEY='ACME-SEC') cfg.LOADER = "thumbor.loaders.file_loader" cfg.FILE_LOADER_ROOT_PATH = '/tmp/path/that/does/not/exist' cfg.RESULT_STORAGE = 'thumbor.result_storages.file_storage' cfg.RESULT_STORAGE_EXPIRATION_SECONDS = 60 cfg.RESULT_STORAGE_FILE_STORAGE_ROOT_PATH = self.root_path cfg.FFMPEG_PATH = which('ffmpeg') cfg.USE_GIFSICLE_ENGINE = True cfg.AUTO_WEBP = True cfg.OPTIMIZERS = [ 'thumbor.optimizers.gifv', ] importer = Importer(cfg) importer.import_modules() server = ServerParameters(8889, 'localhost', 'thumbor.conf', None, 'info', None) server.security_key = 'ACME-SEC' ctx = Context(server, cfg, importer) ctx.server.gifsicle_path = which('gifsicle') return ctx