def start_app(): """Start the laevus Flask application. Use chaussette as a backend WSGI server. """ args = command_line_options() config = read_config(args.config) app = create_app(config) init_logging(app.config['LOG_LEVEL'], app.config['LOG_FILENAME']) logging.info('Starting laevus...') if args.chaussette_fd is not None: srv = make_chaussette_server(app, host='fd://{0}'.format( args.chaussette_fd)) else: strs = app.config['SERVER_NAME'].split(':') host, port = strs if len(strs) == 2 else (strs.pop(), '') port = int(port) if port.isdigit() else 5000 srv = make_chaussette_server(app, host=host, port=port) signal.signal(signal.SIGINT, stop_app) signal.signal(signal.SIGTERM, stop_app) srv.serve_forever()
def setUp(self): super(TestContributeAnonymous, self).setUp() self.app = laevus.create_app(laevus.read_config(TEST_CONFIG)) self.client = self.app.test_client()
def setUp(self): super(TestHomepageAnonymous, self).setUp() self.app = create_app(read_config(TEST_CONFIG)) self.client = self.app.test_client()
from contextlib import contextmanager import csv import io import os import subprocess import anosql import click from laevus import create_app, read_config from laevus.model import User, db import laevus config = read_config() app = create_app(config) @contextmanager def sqla_raw_conn(): """Context manager returning a raw SQLAlchemy connection to the current database.""" cnx = db.engine.raw_connection() try: yield cnx except Exception: cnx.rollback() raise else: cnx.commit() finally: