Пример #1
0
def init_db(test_db=False, force=False):
    """Initialize the database.

    * Creates the database.
    * Creates all tables.
    * Adds fixtures required to run the app.
    """
    click.echo("Initializing the database...")

    if force:
        click.echo("Dropping existing tables and types...")
        data_utils.drop_tables()
        data_utils.drop_types()
        click.echo("Done!")

    if test_db:
        frontend.create_app(config_path=os.path.join(
            os.path.dirname(os.path.realpath(__file__)),
            'critiquebrainz', 'test_config.py'
        ))
    else:
        frontend.create_app()

    click.echo("Creating tables... ", nl=False)
    data_utils.create_all()
    click.echo("Done!")

    click.echo("Adding fixtures... ")
    app = frontend.create_app()
    with app.app_context():
        _fixtures.install(*_fixtures.all_data)
    click.echo("Done!")

    click.echo("Initialization has been completed!")
Пример #2
0
def init_db(skip_create_db=False):
    """Initialize the database.

    * Creates the database.
    * Creates all tables.
    * Adds fixtures required to run the app.
    """
    click.echo("Initializing the database...")

    db_uri = frontend.create_app().config['SQLALCHEMY_DATABASE_URI']
    if not skip_create_db:
        init_postgres(db_uri)
        create_extension(db_uri)

    click.echo("Creating tables... ", nl=False)
    data_utils.create_all()
    click.echo("Done!")

    click.echo("Adding fixtures... ")
    app = frontend.create_app()
    with app.app_context():
        _fixtures.install(*_fixtures.all_data)
    click.echo("Done!")

    click.echo("Initialization has been completed!")
Пример #3
0
def init_db(skip_create_db=False, test_db=False):
    """Initialize the database.

    * Creates the database.
    * Creates all tables.
    * Adds fixtures required to run the app.
    """
    click.echo("Initializing the database...")

    if test_db:
        db_uri = frontend.create_app(config_path=os.path.join(
            os.path.dirname(os.path.realpath(__file__)), 'critiquebrainz',
            'test_config.py')).config['SQLALCHEMY_DATABASE_URI']
    else:
        db_uri = frontend.create_app().config['SQLALCHEMY_DATABASE_URI']

    if not skip_create_db:
        init_postgres(db_uri)
        create_extension(db_uri)

    click.echo("Creating tables... ", nl=False)
    data_utils.create_all()
    click.echo("Done!")

    click.echo("Adding fixtures... ")
    app = frontend.create_app()
    with app.app_context():
        _fixtures.install(*_fixtures.all_data)
    click.echo("Done!")

    click.echo("Initialization has been completed!")
Пример #4
0
 def create_app(self):
     app = create_app(debug=False)
     app.config['TESTING'] = True
     app.config['SQLALCHEMY_DATABASE_URI'] = app.config[
         'TEST_SQLALCHEMY_DATABASE_URI']
     app.config['WTF_CSRF_ENABLED'] = False
     return app
Пример #5
0
def pull_translations():
    """Pull translations for languages defined in config from Transifex and compile them.

    Before using this command make sure that you properly configured Transifex client.
    More info about that is available at http://docs.transifex.com/developer/client/setup#configuration.
    """
    languages = ','.join(frontend.create_app().config['SUPPORTED_LANGUAGES'])
    _run_command("tx pull -f -r critiquebrainz.critiquebrainz -l %s" % languages)
Пример #6
0
def pull_translations():
    """Pull translations for languages defined in config from Transifex and compile them.

    Before using this command make sure that you properly configured Transifex client.
    More info about that is available at http://docs.transifex.com/developer/client/setup#configuration.
    """
    languages = ','.join(frontend.create_app().config['SUPPORTED_LANGUAGES'])
    _run_command("tx pull -f -r critiquebrainz.critiquebrainz -l %s" % languages)
Пример #7
0
def pull_translations():
    """Pull translations for languages defined in config from Transifex and compile them.

    Before using this command make sure that you properly configured Transifex client.
    More info about that is available at http://docs.transifex.com/developer/client/setup#configuration.
    """
    languages = ','.join(create_app().config['SUPPORTED_LANGUAGES'])
    local("tx pull -f -r critiquebrainz.critiquebrainz -l %s" % languages)
    print(green("Translations have been updated successfully.", bold=True))
Пример #8
0
def pull_translations():
    """Pull translations for languages defined in config from Transifex and compile them.

    Before using this command make sure that you properly configured Transifex client.
    More info about that is available at http://docs.transifex.com/developer/client/setup#configuration.
    """
    languages = ','.join(create_app().config['SUPPORTED_LANGUAGES'])
    local("tx pull -f -r critiquebrainz.critiquebrainz -l %s" % languages)
    print(green("Translations have been updated successfully.", bold=True))
Пример #9
0
    def test_flask_debugtoolbar(self):
        """ Test if flask debugtoolbar is loaded correctly

        Creating an app with default config so that debug is True
        and SECRET_KEY is defined.
        """
        app = create_app(debug=True)
        client = app.test_client()
        resp = client.get("/about")
        self.assert200(resp)
        self.assertIn("flDebug", str(resp.data))
Пример #10
0
def init_db():
    """Initialize the database.

    * Creates the database.
    * Creates all tables.
    * Adds fixtures required to run the app.
    """
    click.echo("Initializing the database...")

    init_postgres(frontend.create_app().config["SQLALCHEMY_DATABASE_URI"])

    click.echo("Creating tables... ", nl=False)
    data_utils.create_tables(frontend.create_app())
    click.echo("Done!")

    click.echo("Adding fixtures... ")
    app = frontend.create_app()
    with app.app_context():
        _fixtures.install(app, *_fixtures.all_data)
    click.echo("Done!")

    click.echo("Initialization has been completed!")
Пример #11
0
def init_db(skip_create_db=False, test_db=False, force=False):
    """Initialize the database.

    * Creates the database.
    * Creates all tables.
    * Adds fixtures required to run the app.
    """
    click.echo("Initializing the database...")

    if force:
        click.echo("Dropping existing tables and types...")
        data_utils.drop_tables()
        data_utils.drop_types()
        click.echo("Done!")

    if test_db:
        db_uri = frontend.create_app(config_path=os.path.join(
            os.path.dirname(os.path.realpath(__file__)),
            'critiquebrainz', 'test_config.py'
        )).config['SQLALCHEMY_DATABASE_URI']
    else:
        db_uri = frontend.create_app().config['SQLALCHEMY_DATABASE_URI']

    if not skip_create_db:
        init_postgres(db_uri)
        create_extension(db_uri)

    click.echo("Creating tables... ", nl=False)
    data_utils.create_all()
    click.echo("Done!")

    click.echo("Adding fixtures... ")
    app = frontend.create_app()
    with app.app_context():
        _fixtures.install(*_fixtures.all_data)
    click.echo("Done!")

    click.echo("Initialization has been completed!")
Пример #12
0
def test(init_db=True, coverage=True):
    """Run all tests.

    It will also initialize the test database and create code coverage report, unless
    specified otherwise. Database that will be used for tests can be specified in the
    application config file. See `TEST_SQLALCHEMY_DATABASE_URI` variable.

    Code coverage report will be located in cover/index.html file.
    """
    if init_db:
        # Creating database-related stuff
        init_postgres(create_app().config['TEST_SQLALCHEMY_DATABASE_URI'])

    if coverage:
        local("nosetests --exe --with-coverage --cover-package=critiquebrainz --cover-erase --cover-html")
        print(yellow("Coverage report can be found in cover/index.html file.", bold=True))
    else:
        local("nosetests --exe")
Пример #13
0
def test(init_db=True, coverage=True):
    """Run all tests.

    It will also initialize the test database and create code coverage report, unless
    specified otherwise. Database that will be used for tests can be specified in the
    application config file. See `TEST_SQLALCHEMY_DATABASE_URI` variable.

    Code coverage report will be located in cover/index.html file.
    """
    if init_db:
        # Creating database-related stuff
        init_postgres(create_app().config['TEST_SQLALCHEMY_DATABASE_URI'])

    if coverage:
        local("nosetests --exe --with-coverage --cover-package=critiquebrainz --cover-erase --cover-html")
        print(yellow("Coverage report can be found in cover/index.html file.", bold=True))
    else:
        local("nosetests --exe")
Пример #14
0
 def create_app(self):
     app = create_app()
     app.config['TESTING'] = True
     app.config['SQLALCHEMY_DATABASE_URI'] = app.config['TEST_SQLALCHEMY_DATABASE_URI']
     return app
Пример #15
0
def clear_memcached():
    with frontend.create_app().app_context():
        cache.flush_all()
    click.echo("Flushed everything from memcached.")
Пример #16
0
import os
import subprocess
from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware
from brainzutils import cache
import click
from critiquebrainz import frontend, ws
from critiquebrainz.data import dump_manager
import critiquebrainz.data.utils as data_utils
import critiquebrainz.data.fixtures as _fixtures

cli = click.Group()

application = DispatcherMiddleware(frontend.create_app(),
                                   {"/ws/1": ws.create_app()})

# Files listed here will be monitored for changes in debug mode and will
# force a reload when modified.
OBSERVE_FILES = [
    "critiquebrainz/frontend/static/build/rev-manifest.json",
]


@cli.command()
@click.option("--host", "-h", default="0.0.0.0", show_default=True)
@click.option("--port", "-p", default=8080, show_default=True)
@click.option("--debug",
              "-d",
              is_flag=True,
              help="Turns debugging mode on or off. If specified, overrides "
              "'DEBUG' value in the config file.")
Пример #17
0
 def decorated(*args, **kwargs):
     with frontend.create_app(config_path=os.path.join(
             os.path.dirname(os.path.realpath(__file__)), '..',
             'test_config.py')).test_request_context():
         return f(*args, **kwargs)
Пример #18
0
 def decorated(*args, **kwargs):
     with frontend.create_app().test_request_context():
         return f(*args, **kwargs)
Пример #19
0
def clear_memcached():
    with create_app().app_context():
        cache.flush_all()
    print(green("Flushed everything from memcached.", bold=True))
def main():
    app = create_app()
    with app.app_context():
        import_musicbrainz_row_ids()
Пример #21
0
 def create_app(self):
     app = create_app(config_path=os.path.join(
         os.path.dirname(os.path.realpath(__file__)), '..',
         'test_config.py'))
     return app
def main():
    app = create_app()
    with app.app_context():
        import_musicbrainz_row_ids()
Пример #23
0
def clear_memcached():
    with frontend.create_app().app_context():
        cache.flush_all()
    click.echo("Flushed everything from memcached.")
Пример #24
0
def clear_memcached():
    with create_app().app_context():
        cache.flush_all()
    print(green("Flushed everything from memcached.", bold=True))
Пример #25
0
 def create_app(self):
     app = create_app(debug=False)
     app.config['TESTING'] = True
     app.config['SQLALCHEMY_DATABASE_URI'] = app.config['TEST_SQLALCHEMY_DATABASE_URI']
     app.config['WTF_CSRF_ENABLED'] = False
     return app
Пример #26
0
 def create_app(self):
     app = create_app(config_path=os.path.join(
         os.path.dirname(os.path.realpath(__file__)),
         '..', 'test_config.py'
     ))
     return app
Пример #27
0
 def decorated(*args, **kwargs):
     with frontend.create_app().test_request_context():
         return f(*args, **kwargs)
Пример #28
0
import os
import subprocess
from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware
from brainzutils import cache
import click
from critiquebrainz import frontend, ws
from critiquebrainz.data import dump_manager
import critiquebrainz.data.utils as data_utils
import critiquebrainz.data.fixtures as _fixtures


cli = click.Group()

application = DispatcherMiddleware(frontend.create_app(), {
    "/ws/1": ws.create_app()
})

# Files listed here will be monitored for changes in debug mode and will
# force a reload when modified.
OBSERVE_FILES = [
    "critiquebrainz/frontend/static/build/rev-manifest.json",
]


@cli.command()
@click.option("--host", "-h", default="0.0.0.0", show_default=True)
@click.option("--port", "-p", default=8080, show_default=True)
@click.option("--debug", "-d", is_flag=True,
              help="Turns debugging mode on or off. If specified, overrides "
                   "'DEBUG' value in the config file.")
Пример #29
0
 def decorated(*args, **kwargs):
     with frontend.create_app(
             config_path=os.path.join(
                 os.path.dirname(os.path.realpath(__file__)),
                 '..', 'test_config.py')).test_request_context():
         return f(*args, **kwargs)
Пример #30
0
from werkzeug.serving import run_simple
from werkzeug.wsgi import DispatcherMiddleware
from critiquebrainz import frontend
from critiquebrainz import ws
from critiquebrainz.data import dump_manager
import critiquebrainz.data.utils as data_utils
import critiquebrainz.data.fixtures as _fixtures
import subprocess
import click


cli = click.Group()

application = DispatcherMiddleware(frontend.create_app(), {"/ws/1": ws.create_app()})

OBSERVE_FILES = ["critiquebrainz/frontend/static/build/rev-manifest.json"]


@cli.command()
@click.option("--host", "-h", default="0.0.0.0", show_default=True)
@click.option("--port", "-p", default=8080, show_default=True)
@click.option(
    "--debug",
    "-d",
    is_flag=True,
    help="Turns debugging mode on or off. If specified, overrides " "'DEBUG' value in the config file.",
)
def runserver(host, port, debug=False):
    run_simple(host, port, application, use_debugger=debug, extra_files=OBSERVE_FILES)