Exemplo n.º 1
0
def main():
    global logger
    logging.basicConfig(level=logging.WARNING,
                        format="[%(asctime)s %(levelname)s] %(message)s")
    logger = logging.getLogger()

    args = parse_args()

    # set logging level
    if args.verbose > 1:
        set_log_debug(logger)
    elif args.verbose == 1:
        set_log_info(logger)

    logger.info('Initializing DB...')
    init_db()
    logger.info('Done initializing database')
Exemplo n.º 2
0
def main():
    global logger
    logging.basicConfig(
        level=logging.INFO,
        format="[%(asctime)s %(levelname)s] %(message)s"
    )
    logger = logging.getLogger()
    set_log_info(logger)

    logger.info('Initializing DB...')
    init_db()
    atexit.register(cleanup_db)
    logger.info('Done initializing database')

    # enter REPL
    print(
        'All models are imported; database session is available as "db_session"'
    )
    code.interact(local=dict(globals(), **locals()))
Exemplo n.º 3
0
"""

import logging

from flask import Flask

from motion_pipeline.database.db import cleanup_db, init_db

format = "%(asctime)s [%(levelname)s %(filename)s:%(lineno)s - " \
         "%(name)s.%(funcName)s() ] %(message)s"
logging.basicConfig(level=logging.DEBUG, format=format)
logger = logging.getLogger()

app = Flask(__name__)
app.jinja_env.add_extension('jinja2.ext.loopcontrols')
init_db()


def before_request():
    """
    When running in debug mode, clear jinja cache.
    """
    logger.warning('DEBUG MODE - Clearing jinja cache')
    app.jinja_env.cache = {}


@app.teardown_appcontext
def shutdown_session(exception=None):
    cleanup_db()