Esempio n. 1
0
    def test_can_configure_log_from_dict_config(self, dict_config_mock):
        conf = Config(THUMBOR_LOG_CONFIG={"level": "INFO"})
        configure_log(conf, "DEBUG")

        params = dict(level="INFO", )

        dict_config_mock.assert_called_with(params)
Esempio n. 2
0
    def test_can_configure_log_from_config(self, basic_config_mock):
        conf = Config()
        configure_log(conf, 'DEBUG')

        params = dict(datefmt='%Y-%m-%d %H:%M:%S',
                      level=10,
                      format='%(asctime)s %(name)s:%(levelname)s %(message)s')

        basic_config_mock.assert_called_with(**params)
Esempio n. 3
0
    def test_can_configure_log_from_config(self, basic_config_mock):
        conf = Config()
        configure_log(conf, 'DEBUG')

        params = dict(
            datefmt='%Y-%m-%d %H:%M:%S',
            level=10,
            format='%(asctime)s %(name)s:%(levelname)s %(message)s'
        )

        basic_config_mock.assert_called_with(**params)
Esempio n. 4
0
    def test_can_configure_log_from_dict_config(self, dict_config_mock):
        conf = Config(
            THUMBOR_LOG_CONFIG={
                "level": "INFO"
            }
        )
        configure_log(conf, 'DEBUG')

        params = dict(
            level="INFO",
        )

        dict_config_mock.assert_called_with(params)
Esempio n. 5
0
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
Esempio n. 6
0
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
from thumbor.console import get_server_parameters
from thumbor.server import get_config, configure_log
from thumbor.server import get_importer, validate_config
from thumbor.server import get_context, get_application

thumbor_port = os.environ.get('THUMBOR_PORT') or '8000'
log_level = os.environ.get('LOG_LEVEL') or 'info'

arguments = [
    '--conf=/app/thumbor.conf', '--port=' + thumbor_port,
    '--log-level=' + log_level
]

server_parameters = get_server_parameters(arguments)

config = get_config(server_parameters.config_path)

configure_log(config, server_parameters.log_level.upper())

importer = get_importer(config)

validate_config(config, server_parameters)

context = get_context(server_parameters, config, importer)

application = get_application(context)