Example #1
0
def run_manager(config='udata.settings.Defaults'):
    app = create_app(config)
    app = standalone(app)
    set_logging(app)
    manager.app = app
    register_commands(manager)
    manager.run()
Example #2
0
def run_manager(config='udata.settings.Defaults'):
    app = create_app(config)
    app = standalone(app)
    set_logging(app)
    manager.app = app
    register_commands(manager)
    manager.run()
Example #3
0
def app(request):
    app = create_app(settings.Defaults, override=PiwikSettings)
    with app.app_context():
        drop_db(app)
    frontend.init_app(app, MODULES)
    with app.app_context():
        yield app
        drop_db(app)
def app(request):
    '''Create an udata app once for the module. '''
    app = create_app(Defaults, override=CkanSettings)
    with app.app_context():
        drop_db(app)
    yield app
    with app.app_context():
        drop_db(app)
Example #5
0
def run_manager(config='udata.settings.Defaults'):
    app = create_app(config, init_logging=set_logging)
    app = standalone(app)
    manager.app = app
    register_commands(manager)
    try:
        manager.run()
    except InvalidCommand as err:
        print(err, file=sys.stderr)
        sys.exit(1)
Example #6
0
def app(request):
    test_settings = get_settings(request)
    app = create_app(settings.Defaults, override=test_settings)
    app.test_client_class = TestClient

    if request.cls and hasattr(request.cls, 'modules'):
        from udata import frontend, api
        api.init_app(app)
        frontend.init_app(app, request.cls.modules)
    return app
Example #7
0
 def create_app(self):
     app = create_app(self.settings)
     # Override some local config
     app.config['DEBUG_TOOLBAR'] = False
     app.config['SERVER_NAME'] = 'localhost'
     app.config['DEFAULT_LANGUAGE'] = 'en'
     if not app.config.get('TEST_WITH_PLUGINS', False):
         app.config['PLUGINS'] = []
     if not app.config.get('TEST_WITH_THEME', False):
         app.config['THEME'] = 'default'
     return app
Example #8
0
 def create_app(self):
     app = create_app(self.settings)
     # Override some local config
     app.config['DEBUG_TOOLBAR'] = False
     app.config['ASSETS_DEBUG'] = True
     app.config['ASSETS_AUTO_BUILD'] = False
     app.config['ASSETS_VERSIONS'] = False
     app.config['ASSETS_URL_EXPIRE'] = False
     app.config['SERVER_NAME'] = 'localhost'
     if not app.config.get('TEST_WITH_PLUGINS', False):
         app.config['PLUGINS'] = []
     if not app.config.get('TEST_WITH_THEME', False):
         app.config['THEME'] = 'default'
     return app
Example #9
0
    def create_app(self):
        '''Create an application a test application.

        - load settings in this order: Default > local > Testing
        - create a minimal application
        - plugins and themes are disabled
        - server name is forced to localhost
        - defaut language is set to EN
        - cache is disabled
        - celery is synchronous
        - CSRF is disabled
        - automatic indexing is disabled
        '''
        app = create_app(settings.Defaults, override=self.settings)
        return app
Example #10
0
    def create_app(self):
        '''Create an application a test application.

        - load settings in this order: Default > local > Testing
        - create a minimal application
        - plugins and themes are disabled
        - server name is forced to localhost
        - defaut language is set to EN
        - cache is disabled
        - celery is synchronous
        - CSRF is disabled
        - automatic indexing is disabled
        '''
        app = create_app(settings.Defaults, override=self.settings)
        return app
Example #11
0
 def create_app(self):
     app = create_app(self.settings)
     # Override some local config
     app.config['DEBUG_TOOLBAR'] = False
     app.config['ASSETS_DEBUG'] = False
     app.config['ASSETS_AUTO_BUILD'] = False
     app.config['ASSETS_VERSIONS'] = False
     app.config['ASSETS_URL_EXPIRE'] = False
     app.config['SERVER_NAME'] = 'localhost'
     app.config['DEFAULT_LANGUAGE'] = 'en'
     if not app.config.get('TEST_WITH_PLUGINS', False):
         app.config['PLUGINS'] = []
     if not app.config.get('TEST_WITH_THEME', False):
         app.config['THEME'] = 'default'
     theme.assets._named_bundles = {}  # Clear webassets bundles
     return app
Example #12
0
 def create_app(self):
     app = create_app(self.settings)
     # Override some local config
     app.config['DEBUG_TOOLBAR'] = False
     app.config['ASSETS_DEBUG'] = False
     app.config['ASSETS_AUTO_BUILD'] = False
     app.config['ASSETS_VERSIONS'] = False
     app.config['ASSETS_URL_EXPIRE'] = False
     app.config['SERVER_NAME'] = 'localhost'
     app.config['DEFAULT_LANGUAGE'] = 'en'
     if not app.config.get('TEST_WITH_PLUGINS', False):
         app.config['PLUGINS'] = []
     if not app.config.get('TEST_WITH_THEME', False):
         app.config['THEME'] = 'default'
     theme.assets._named_bundles = {}  # Clear webassets bundles
     return app
Example #13
0
def app(request):
    test_settings = get_settings(request)
    app = create_app(settings.Defaults, override=test_settings)
    app.test_client_class = TestClient
    return app
Example #14
0
def app(request):
    test_settings = get_settings(request)
    app = create_app(settings.Defaults, override=test_settings)
    app.test_client_class = TestClient
    return app
Example #15
0
def create_cli_app(info):
    app = create_app(info.settings, init_logging=init_logging)
    return standalone(app)
Example #16
0
# -*- coding: utf-8 -*-
from __future__ import unicode_literals

import logging
import os

from PIL import Image

from udata.app import standalone, create_app

log = logging.getLogger(__name__)

app = standalone(create_app())


DEFAULT_SIZES = [128]  # , 25]
MAX = 10


def make_thumbnail(filename, size, crop=None):
    base, ext = os.path.splitext(filename)
    image = Image.open(filename)
    if crop:
        pass
    else:
        thumbnail = center_thumbnail(image, size)
    thumbnail.save(base + '-' + str(size) + ext)


def center_thumbnail(image, size):
    result = Image.new('RGBA', (size, size), (255, 255, 255, 0))
Example #17
0
import logging
import os

from PIL import Image

from udata.app import standalone, create_app

log = logging.getLogger(__name__)

app = standalone(create_app())

DEFAULT_SIZES = [128]  # , 25]
MAX = 10


def make_thumbnail(filename, size, crop=None):
    base, ext = os.path.splitext(filename)
    image = Image.open(filename)
    if crop:
        pass
    else:
        thumbnail = center_thumbnail(image, size)
    thumbnail.save(base + '-' + str(size) + ext)


def center_thumbnail(image, size):
    result = Image.new('RGBA', (size, size), (255, 255, 255, 0))
    if image.size[0] > image.size[1]:
        new_size = (size, image.size[1] * size / image.size[0])
    else:
        new_size = (image.size[0] * size / image.size[1], size)
Example #18
0
def app():
    app = create_app(settings.Defaults, override=settings.Testing)
    return app