Exemplo n.º 1
0
def main():
    logging.info("Generating sample images...")

    app = create_app(ProdConfig)

    with app.app_context():

        for template in app.template_service.all():
            app.image_service.create(template, Text("_"))
            app.image_service.create(template, Text("_/_"))
            app.image_service.create(template, template.sample_text)
Exemplo n.º 2
0
def main():
    log.info("Generating sample images...")

    app = create_app(ProdConfig)

    with app.app_context():

        for template in app.template_service.all():
            for text in [Text("_"), template.sample_text]:
                for watermark in ["", "memegen.link"]:
                    app.image_service.create(template, text,
                                             watermark=watermark)
Exemplo n.º 3
0
def main():
    log.info("Generating sample images...")

    app = create_app(ProductionConfig)

    with app.app_context():

        for template in app.template_service.all():
            for text in [Text("_"), template.sample_text]:
                for watermark in ["", "memegen.link"]:
                    app.image_service.create(template, text,
                                             watermark=watermark)
Exemplo n.º 4
0
def run():
    app = create_app(ProductionConfig)
    with app.app_context():

        options = []
        for template in app.template_service.all():
            for text in [Text("_"), template.sample_text]:
                for watermark in ["", "memegen.link"]:
                    options.append((template, text, watermark))

        print(f"Generating {len(options)} sample images...")
        for template, text, watermark in options:
            app.image_service.create(template, text, watermark=watermark)
Exemplo n.º 5
0
def app():
    app = create_app(get_config('test'))
    yield app
Exemplo n.º 6
0
 def app():
     app = create_app(get_config('test'))
     app.config['GOOGLE_ANALYTICS_TID'] = 'my_tid'
     return app
Exemplo n.º 7
0
def app():
    yield create_app(get_config('test'))
Exemplo n.º 8
0
    def test_prod(self):
        _app = factory.create_app(settings.ProdConfig)

        assert False is _app.config['DEBUG']
        assert False is _app.config['TESTING']
Exemplo n.º 9
0
    def run(self):  # pylint: disable=method-hidden
        if app.template_service.validate():
            return 0
        else:
            return 1


def find_assets():
    """Yield paths for all static files and templates."""
    for name in ['static', 'templates']:
        directory = os.path.join(app.config['PATH'], name)
        for entry in os.scandir(directory):
            if entry.is_file():
                yield entry.path


# Select app configuration from the environment
config = get_config(os.getenv('FLASK_ENV', 'local'))

# Build the app using configuration from the environment
app = create_app(config)

# Configure the command-line interface
manager = Manager(app)
manager.add_command('validate', Validate())
manager.add_command('run', Server(extra_files=find_assets()))


if __name__ == '__main__':
    manager.run()
Exemplo n.º 10
0
    """Checks for issues in all templates."""
    def run(self):  # pylint: disable=method-hidden
        if app.template_service.validate():
            return 0
        else:
            return 1


def find_assets():
    """Yield paths for all static files and templates."""
    for name in ['static', 'templates']:
        directory = os.path.join(app.config['PATH'], name)
        for entry in os.scandir(directory):
            if entry.is_file():
                yield entry.path


# Select app configuration from the environment
config = get_config(os.getenv('FLASK_ENV', 'local'))

# Build the app using configuration from the environment
app = create_app(config)

# Configure the command-line interface
manager = Manager(app)
manager.add_command('validate', Validate())
manager.add_command('run', Server(extra_files=find_assets()))

if __name__ == '__main__':
    manager.run()
Exemplo n.º 11
0
    def test_dev(self):
        _app = factory.create_app(settings.DevConfig)

        assert True is _app.config['DEBUG']
        assert False is _app.config['TESTING']
Exemplo n.º 12
0
 def when_dev(expect):
     app = factory.create_app(settings.LocalConfig)
     expect(app.config['DEBUG']) == True
     expect(app.config['TESTING']) == False
Exemplo n.º 13
0
 def app():
     app = create_app(get_config('test'))
     app.config['GOOGLE_ANALYTICS_TID'] = 'my_tid'
     return app
Exemplo n.º 14
0
 def when_prod(expect):
     app = factory.create_app(settings.ProductionConfig)
     expect(app.config['DEBUG']) == False
     expect(app.config['TESTING']) == False
Exemplo n.º 15
0
 def when_test(expect):
     app = factory.create_app(settings.TestConfig)
     expect(app.config['DEBUG']) == True
     expect(app.config['TESTING']) == True
Exemplo n.º 16
0
 def when_dev(expect):
     app = factory.create_app(settings.LocalConfig)
     expect(app.config['DEBUG']) == True
     expect(app.config['TESTING']) == False
Exemplo n.º 17
0
 def when_prod(expect):
     app = factory.create_app(settings.ProductionConfig)
     expect(app.config['DEBUG']) == False
     expect(app.config['TESTING']) == False
Exemplo n.º 18
0
 def when_test(expect):
     app = factory.create_app(settings.TestConfig)
     expect(app.config['DEBUG']) == True
     expect(app.config['TESTING']) == True
Exemplo n.º 19
0
def app():
    yield create_app(get_config('test'))
Exemplo n.º 20
0
    def test_test(self):
        _app = factory.create_app(settings.TestConfig)

        assert True is _app.config['DEBUG']
        assert True is _app.config['TESTING']