コード例 #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
ファイル: manage.py プロジェクト: metabrainz/critiquebrainz
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
ファイル: fabfile.py プロジェクト: ortizginer/critiquebrainz
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
ファイル: fabfile.py プロジェクト: dpmittal/critiquebrainz
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
ファイル: manage.py プロジェクト: dpmittal/critiquebrainz
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
ファイル: manage.py プロジェクト: metabrainz/critiquebrainz
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
ファイル: fabfile.py プロジェクト: dpmittal/critiquebrainz
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
ファイル: fabfile.py プロジェクト: ortizginer/critiquebrainz
def clear_memcached():
    with create_app().app_context():
        cache.flush_all()
    print(green("Flushed everything from memcached.", bold=True))
コード例 #20
0
def main():
    app = create_app()
    with app.app_context():
        import_musicbrainz_row_ids()
コード例 #21
0
ファイル: testing.py プロジェクト: shagun6/critiquebrainz
 def create_app(self):
     app = create_app(config_path=os.path.join(
         os.path.dirname(os.path.realpath(__file__)), '..',
         'test_config.py'))
     return app
コード例 #22
0
def main():
    app = create_app()
    with app.app_context():
        import_musicbrainz_row_ids()
コード例 #23
0
ファイル: manage.py プロジェクト: metabrainz/critiquebrainz
def clear_memcached():
    with frontend.create_app().app_context():
        cache.flush_all()
    click.echo("Flushed everything from memcached.")
コード例 #24
0
ファイル: fabfile.py プロジェクト: dpmittal/critiquebrainz
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
ファイル: testing.py プロジェクト: metabrainz/critiquebrainz
 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
ファイル: utils.py プロジェクト: metabrainz/critiquebrainz
 def decorated(*args, **kwargs):
     with frontend.create_app().test_request_context():
         return f(*args, **kwargs)
コード例 #28
0
ファイル: manage.py プロジェクト: metabrainz/critiquebrainz
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
ファイル: utils.py プロジェクト: metabrainz/critiquebrainz
 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
ファイル: manage.py プロジェクト: dpmittal/critiquebrainz
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)