Ejemplo n.º 1
0
Archivo: base.py Proyecto: uah/thumbor
    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)
Ejemplo n.º 2
0
    async def test_should_raise_for_invalid_compatibility_storage(self):
        request = RequestParameters(url="/image.jpg", )
        config = Config(
            FILE_LOADER_ROOT_PATH=STORAGE_PATH,
            STORES_CRYPTO_KEY_FOR_EACH_IMAGE=True,
        )
        importer = Importer(config)
        importer.import_modules()
        image_bytes = self.get_image_bytes("image.jpg")
        ctx = Context(self.context.server, config, importer)
        ctx.request = request
        storage = Storage(ctx)

        with expect.error_to_happen(
                RuntimeError,
                message=
            ("The 'COMPATIBILITY_LEGACY_RESULT_STORAGE' configuration should point "
             "to a valid result storage when using compatibility result storage."
             ),
        ):
            await storage.get()

        with expect.error_to_happen(
                RuntimeError,
                message=
            ("The 'COMPATIBILITY_LEGACY_RESULT_STORAGE' configuration should point "
             "to a valid result storage when using compatibility result storage."
             ),
        ):
            await storage.put(image_bytes)
Ejemplo n.º 3
0
Archivo: base.py Proyecto: GDxU/thumbor
    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):
     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)
Ejemplo n.º 5
0
    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
Ejemplo n.º 6
0
 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
Ejemplo n.º 7
0
 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
    def get_context(self):
        conf = Config()
        conf.STATSD_HOST = ''
        ctx = Context(config=conf)
        ctx.request = RequestParameters()

        return ctx
Ejemplo n.º 9
0
    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()

        srv = ServerParameters(8888, "localhost", "./tests/test.conf", None,
                               "DEBUG", None)
        srv._security_key = "MY_SECURE_KEY"

        context = Context(config=config, importer=importer, server=srv)
        context.request = req
        context.request.engine = context.modules.engine
        context.request_handler = mock.MagicMock(request=mock.MagicMock(
            protocol="http",
            host="localhost:8888",
        ))

        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)
Ejemplo n.º 10
0
        def topic(self):
            config = Config()
            context = Context(None, config, Importer(config))
            context.request = RequestParameters()

            engine = MockInvalidResultEngine(context=context)
            return engine.read()
Ejemplo n.º 11
0
 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)
Ejemplo n.º 12
0
    def get_context(self):
        conf = Config()
        conf.STATSD_HOST = ''
        ctx = Context(config=conf)
        ctx.request = RequestParameters()

        return ctx
Ejemplo n.º 13
0
    def get_context(self):
        conf = Config()
        conf.STATSD_HOST = ''
        ctx = Context(config=conf)
        ctx.request = RequestParameters()
        ctx.request.filters.append('auto')

        return ctx
Ejemplo n.º 14
0
    def get_context(self):
        conf = Config()
        conf.STATSD_HOST = ''
        ctx = Context(config=conf)
        ctx.request = RequestParameters()
        ctx.request.filters.append('auto')

        return ctx
Ejemplo n.º 15
0
    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
Ejemplo n.º 16
0
    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
Ejemplo n.º 17
0
    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
Ejemplo n.º 18
0
        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()
Ejemplo n.º 19
0
    def to_context(self, detectors=None, ignore_detector_error=False):
        if detectors is None:
            detectors = []
        ThreadPool.reset()
        self.engine = MockEngine((self.source_width, self.source_height))

        flip_horizontally = flip_vertically = False

        if self.target_width != "orig":
            flip_horizontally = self.target_width < 0
            self.target_width = abs(self.target_width)

        if self.target_height != "orig":
            flip_vertically = self.target_height < 0
            self.target_height = abs(self.target_height)

        importer = Importer(None)
        importer.detectors = detectors
        importer.storage = NoStorage
        config = Config()
        config.IGNORE_SMART_ERRORS = ignore_detector_error
        ctx = Context(server=None, config=config, importer=importer)
        ctx.modules.engine = self.engine

        ctx.request = RequestParameters(
            buffer=None,
            debug=False,
            meta=self.meta,
            crop={
                "left": self.crop_left,
                "top": self.crop_top,
                "right": self.crop_right,
                "bottom": self.crop_bottom,
            },
            adaptive=self.adaptive,
            full=self.full,
            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",
            stretch=self.stretch,
        )
        ctx.request.engine = self.engine
        ctx.request.engine.extension = ".jpeg"

        return ctx
Ejemplo n.º 20
0
    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
Ejemplo n.º 21
0
        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()
Ejemplo n.º 22
0
        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()
Ejemplo n.º 23
0
    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
Ejemplo n.º 24
0
    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
        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)
Ejemplo n.º 26
0
    def test_can_get_image(self):
        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-2.jpg'

        storage = Storage(ctx)
        yield storage.put(IMAGE_BYTES)

        topic = yield storage.get()

        self.assertEqual(topic.buffer, IMAGE_BYTES)
Ejemplo n.º 27
0
    def get_optimizer(filters=None, progressive=False, scans_file=""):
        conf = Config()
        conf.STATSD_HOST = ""
        conf.JPEGTRAN_PATH = "/somewhere/jpegtran"
        conf.PROGRESSIVE_JPEG = progressive
        conf.JPEGTRAN_SCANS_FILE = scans_file
        req = RequestParameters(filters=filters)
        ctx = Context(config=conf)
        ctx.request = req
        optimizer = Optimizer(ctx)

        return optimizer
Ejemplo n.º 28
0
        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(webp)")
            filter_instances = runner.filter_instances[
                thumbor.filters.PHASE_POST_TRANSFORM]

            filter_instances[0].run()
            return ctx.request.format
Ejemplo n.º 29
0
        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
Ejemplo n.º 30
0
        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
Ejemplo n.º 31
0
    def test_can_store_image(self):
        config = Config(TC_AWS_RESULT_STORAGE_BUCKET=s3_bucket)
        ctx = Context(config=config, server=get_server('ACME-SEC'))
        ctx.request = Request
        ctx.request.url = 'foo/my-image.jpg'

        storage = Storage(ctx)

        yield storage.put(IMAGE_BYTES)

        client = botocore.session.get_session().create_client('s3')
        response = client.get_object(Bucket=s3_bucket, Key="foo/my-image.jpg")

        self.assertEqual(response['Body'].read(), IMAGE_BYTES)
Ejemplo n.º 32
0
    async def test_should_put_and_get(self):
        request = RequestParameters(url="/image.jpg", )
        image_bytes = self.get_image_bytes("image.jpg")
        ctx = Context(self.context.server, self.context.config, self.importer)
        ctx.request = request
        storage = Storage(ctx)

        await storage.put(image_bytes)

        result = await storage.get()
        expect(result).not_to_be_null()
        expect(result).not_to_be_an_error()
        expect(result.successful).to_be_true()
        expect(result.buffer).to_equal(image_bytes)
Ejemplo n.º 33
0
        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
        def topic(self, callback):
            self.conn = S3Connection()
            self.conn.create_bucket(s3_bucket)

            config = Config(TC_AWS_RESULT_STORAGE_BUCKET=s3_bucket, TC_AWS_STORE_METADATA=True)
            ctx = Context(config=config, server=get_server('ACME-SEC'))
            ctx.headers = {'Content-Type': 'image/webp', 'Some-Other-Header': 'doge-header'}
            ctx.request = Request
            ctx.request.url = 'my-image-meta.jpg'

            storage = Storage(ctx)
            storage.put(IMAGE_BYTES)

            file_abspath = storage._normalize_path(ctx.request.url)
            storage.storage.get(file_abspath, callback=callback)
Ejemplo n.º 35
0
        def topic(self):
            self.conn = S3Connection()
            self.conn.create_bucket(s3_bucket)

            config = Config(RESULT_STORAGE_BUCKET=s3_bucket, RESULT_STORAGE_S3_STORE_METADATA=True)
            ctx = Context(config=config, server=get_server('ACME-SEC'))
            ctx.request_handler = RequestHandler()
            ctx.request = Request
            ctx.request.url = 'my-image-meta.jpg'

            storage = Storage(ctx)
            storage.put(IMAGE_BYTES)

            file_abspath = storage.normalize_path(ctx.request.url)
            file_key = storage.storage.get_key(file_abspath)
            return file_key.content_type, file_key.metadata, file_key.read()
Ejemplo n.º 36
0
    def to_context(self, detectors=[], ignore_detector_error=False):
        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)
        importer.detectors = detectors
        importer.storage = NoStorage
        config = Config()
        config.IGNORE_SMART_ERRORS = ignore_detector_error
        ctx = Context(server=None, config=config, importer=importer)
        ctx.modules.engine = self.engine

        ctx.request = RequestParameters(buffer=None,
                                        debug=False,
                                        meta=self.meta,
                                        crop={
                                            'left': self.crop_left,
                                            'top': self.crop_top,
                                            'right': self.crop_right,
                                            'bottom': self.crop_bottom
                                        },
                                        adaptive=self.adaptive,
                                        full=self.full,
                                        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")
        ctx.request.engine = self.engine
        ctx.request.engine.extension = ".jpeg"

        return ctx
Ejemplo n.º 37
0
    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
Ejemplo n.º 38
0
    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
Ejemplo n.º 39
0
    def to_context(self, detectors=[], ignore_detector_error=False):
        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)
        importer.detectors = detectors
        importer.storage = NoStorage
        config = Config()
        config.IGNORE_SMART_ERRORS = ignore_detector_error
        ctx = Context(server=None, config=config, importer=importer)
        ctx.modules.engine = self.engine

        ctx.request = RequestParameters(
            buffer=None,
            debug=False,
            meta=self.meta,
            crop={
                'left': self.crop_left,
                'top': self.crop_top,
                'right': self.crop_right,
                'bottom': self.crop_bottom
            },
            adaptive=self.adaptive,
            full=self.full,
            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"
        )
        ctx.request.engine = self.engine
        ctx.request.engine.extension = ".jpeg"

        return ctx
Ejemplo n.º 40
0
    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])
Ejemplo n.º 41
0
        def topic(self):
            config = Config()
            server = ServerParameters(
                8889, 'localhost', 'thumbor.conf', None, 'info', None
            )

            context = Context(server, config, Importer(config))
            context.server.gifsicle_path = which('gifsicle')

            context.request = RequestParameters()

            with open("%s/animated_image.gif" % FIXTURES_FOLDER, "rb") as f:
                buffer = f.read()

            engine = GifEngine(context=context)
            engine.load(buffer, '.gif')

            return engine.read()
Ejemplo n.º 42
0
    def test_can_store_image_randomly(self):
        config = Config(TC_AWS_RESULT_STORAGE_BUCKET=s3_bucket,
                        TC_AWS_RANDOMIZE_KEYS=True)
        ctx = Context(config=config, server=get_server('ACME-SEC'))
        ctx.request = Request
        ctx.request.url = 'foo/my-image.jpg'

        storage = Storage(ctx)

        yield storage.put(IMAGE_BYTES)

        expected_path = '/'.join([
            sha1("foo/my-image.jpg".encode('utf-8')).hexdigest(),
            'foo/my-image.jpg'
        ])

        client = botocore.session.get_session().create_client('s3')
        response = client.get_object(Bucket=s3_bucket, Key=expected_path)

        self.assertEqual(response['Body'].read(), IMAGE_BYTES)
Ejemplo n.º 43
0
        def topic(self):
            self.conn = S3Connection()
            self.conn.create_bucket(s3_bucket)

            config = Config(RESULT_STORAGE_BUCKET=s3_bucket,
                            RESULT_STORAGE_S3_STORE_METADATA=True)
            ctx = Context(config=config, server=get_server('ACME-SEC'))
            ctx.headers = {
                'Content-Type': 'image/webp',
                'Some-Other-Header': 'doge-header'
            }
            ctx.request = Request
            ctx.request.url = 'my-image-meta.jpg'

            storage = Storage(ctx)
            storage.put(IMAGE_BYTES)

            file_abspath = storage.normalize_path(ctx.request.url)
            file_key = storage.storage.get_key(file_abspath)
            return file_key.content_type, file_key.metadata, file_key.read()
Ejemplo n.º 44
0
    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)
Ejemplo n.º 45
0
    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)
Ejemplo n.º 46
0
 def get_context(self):
     cfg = Config()
     ctx = Context(None, cfg, None)
     ctx.request = RequestParameters(url='image.jpg')
     self.context = ctx
     return ctx
 def topic(self):
     config = Config()
     context = Context(config=config)
     context.request = RequestParameters(url="image.jpg")
     fs = NoStorage(context)
     return fs.put(100)
 def topic(self, callback):
     config = Config()
     context = Context(config=config)
     context.request = RequestParameters(url="image.jpg")
     fs = NoStorage(context)
     fs.get(callback=callback)
 def topic(self, callback):
     config = Config(RESULT_STORAGE_FILE_STORAGE_ROOT_PATH=STORAGE_PATH)
     context = Context(config=config)
     context.request = RequestParameters(url='image.jpg')
     fs = FileStorage(context)
     fs.get(callback=callback)
Ejemplo n.º 50
0
 def topic(self):
     config  = Config(AUTO_WEBP=False)
     context = Context(config=config)
     context.request = RequestParameters(accepts_webp=True)
     return Storage(context)