Esempio n. 1
0
def init_app():
    from psi.app.config import TestConfig
    # warnings.warn("Recreating DB")
    # recreate_database(TestConfig)
    if os.environ.get('CI_MODE') == 'True':
        active_config = CITestConfig
    else:
        active_config = TestConfig
    application = create_app(active_config)
    init_all(application)
    return application
Esempio n. 2
0
def init_app():
    from psi.app.config import TestConfig
    # warnings.warn("Recreating DB")
    # recreate_database(TestConfig)
    if os.environ.get('CI_MODE') == 'True':
        active_config = CITestConfig
    else:
        active_config = TestConfig
    application = create_app(active_config)
    init_all(application)
    return application
Esempio n. 3
0
import logging
import math
import os
import random
import sys

import click
import flask_migrate
import psycopg2

from psi.app import create_app, init_all
from psi.app.utils import retry
from psi import MIGRATION_DIR

# Using flask's default `click` command line environment
application = create_app()
init_all(application, migrate=False)
log = logging.getLogger(__name__)


@application.cli.command()
@click.argument('retries', default=5)
@click.argument('migrate', default=True)
def wait_on_postgres(retries=5, migrate=True):
    """Block until Postgres is ready (optionally, run any migrations)

    Shamelessly appropriated from https://github.com/agconti/wait-for-postgres
    """
    dsn = os.environ.get('DATABASE_URL')

    @retry(retries, exceptions=(psycopg2.OperationalError, ))
Esempio n. 4
0
# coding=utf-8
import sys
import os


try:
    # This import should behind above two lines
    # To avoid Chinese character display issue
    from psi.app import create_app, init_all
except ImportError:
    # If os.getcwd() is _inside_ the psi package, add parent directory
    # to front of PATH so the interpreter can import the `psi` package
    _root_dir = os.path.join(os.path.dirname(os.path.realpath(__file__)), '..')
    sys.path.insert(0, _root_dir)
    # Try the import again!
    from psi.app import create_app, init_all


application = create_app()
socket_io = init_all(application, migrate=False)