Exemplo n.º 1
0
def _init():
    # creates MongoDB connection
    from lmfdb.config import Configuration
    configureDBConnection(**Configuration().get_mongodb())
    makeDBConnection()
    # creates PostgresSQL connection
    from lmfdb.db_backend import db
    assert db
Exemplo n.º 2
0
def css():
    from lmfdb.config import Configuration
    color = Configuration().get_color()
    response = make_response(render_template("style.css",
                                             color_template=color))
    response.headers['Content-type'] = 'text/css'
    # don't cache css file, if in debug mode.
    if current_app.debug:
        response.headers['Cache-Control'] = 'no-cache, no-store'
    else:
        response.headers['Cache-Control'] = 'public, max-age=600'
    return response
Exemplo n.º 3
0
def main():
    logging.info("main: ...done.")
    flask_options = Configuration().get_flask()

    if "profiler" in flask_options and flask_options["profiler"]:
        print "Profiling!"
        from werkzeug.contrib.profiler import ProfilerMiddleware
        app.wsgi_app = ProfilerMiddleware(app.wsgi_app,
                                          restrictions=[30],
                                          sort_by=('cumulative', 'time',
                                                   'calls'))
        del flask_options["profiler"]

    app.run(**flask_options)
Exemplo n.º 4
0
def setup_logging():
    logging_options = Configuration().get_logging()
    file_handler = logging.FileHandler(logging_options['logfile'])

    file_handler.setLevel(logging.WARNING)
    if 'logfocus' in logging_options:
        set_logfocus(logging_options['logfocus'])
        logging.getLogger(get_logfocus()).setLevel(logging.DEBUG)

    root_logger = logging.getLogger()
    root_logger.setLevel(logging.INFO)
    root_logger.name = "LMFDB"

    formatter = logging.Formatter(
        utils.LmfdbFormatter.fmtString.split(r'[')[0])
    ch = logging.StreamHandler()
    ch.setFormatter(formatter)
    root_logger.addHandler(ch)

    app.logger.addHandler(file_handler)
Exemplo n.º 5
0
    root_logger.name = "LMFDB"

    formatter = logging.Formatter(
        utils.LmfdbFormatter.fmtString.split(r'[')[0])
    ch = logging.StreamHandler()
    ch.setFormatter(formatter)
    root_logger.addHandler(ch)

    app.logger.addHandler(file_handler)


if True:
    # this bit is so that we can import website.py to use with gunicorn
    # and to setup logging before anything
    setup_logging()
    logging.info("Configuration = %s" % Configuration().get_all())

    _init()
    if [int(c) for c in sage.version.version.split(".")[:2]
        ] < [int(c) for c in LMFDB_SAGE_VERSION.split(".")[:2]]:
        logging.warning("*** WARNING: SAGE VERSION %s IS OLDER THAN %s ***" %
                        (sage.version.version, LMFDB_SAGE_VERSION))

# Import top-level modules that makeup the site
# Note that this necessarily includes everything, even code in still in an alpha state
import pages
assert pages
import api
assert api
import belyi
assert belyi