예제 #1
0
파일: app.py 프로젝트: JayMaree/cuckoo
def create_app(database_connection):
    app = Flask("Distributed Cuckoo")
    app.config["SQLALCHEMY_DATABASE_URI"] = database_connection
    app.config["SECRET_KEY"] = os.urandom(32)

    app.register_blueprint(ApiBlueprint, url_prefix="/api")
    app.register_blueprint(ApiBlueprint, url_prefix="/api/v1")

    db.init_app(app)
    db.create_all(app=app)

    return app
예제 #2
0
def create_app():
    app = Flask("Distributed Cuckoo")
    app.config.from_object(settings)

    for blueprint, routes in blueprints:
        for route in routes:
            app.register_blueprint(blueprint, url_prefix=route)

    db.init_app(app)
    db.create_all(app=app)

    # Check whether an alembic version is present and whether
    # we're up-to-date.
    with app.app_context():
        row = AlembicVersion.query.first()
        if not row:
            db.session.add(AlembicVersion(AlembicVersion.VERSION))
            db.session.commit()
        elif row.version_num != AlembicVersion.VERSION:
            sys.exit("Your database is not up-to-date. Please upgrade it "
                     "using alembic (run `alembic upgrade head`).")

    # Further check the configuration.
    if not settings.SQLALCHEMY_DATABASE_URI:
        sys.exit("Please configure a database connection.")

    if not settings.report_formats:
        sys.exit("Please configure one or more reporting formats.")

    if not settings.samples_directory or \
            not os.path.isdir(settings.samples_directory):
        sys.exit("Please configure a samples directory path.")

    if not settings.reports_directory or \
            not os.path.isdir(settings.reports_directory):
        sys.exit("Please configure a reports directory path.")

    return app
예제 #3
0
파일: app.py 프로젝트: 0day29/cuckoo
def create_app():
    app = Flask("Distributed Cuckoo")
    app.config.from_object(settings)

    for blueprint, routes in blueprints:
        for route in routes:
            app.register_blueprint(blueprint, url_prefix=route)

    db.init_app(app)
    db.create_all(app=app)

    # Check whether an alembic version is present and whether
    # we're up-to-date.
    with app.app_context():
        row = AlembicVersion.query.first()
        if not row:
            db.session.add(AlembicVersion(AlembicVersion.VERSION))
            db.session.commit()
        elif row.version_num != AlembicVersion.VERSION:
            sys.exit("Your database is not up-to-date. Please upgrade it "
                     "using alembic (run `alembic upgrade head`).")

    # Further check the configuration.
    if not settings.SQLALCHEMY_DATABASE_URI:
        sys.exit("Please configure a database connection.")

    if not settings.report_formats:
        sys.exit("Please configure one or more reporting formats.")

    if not settings.samples_directory or \
            not os.path.isdir(settings.samples_directory):
        sys.exit("Please configure a samples directory path.")

    if not settings.reports_directory or \
            not os.path.isdir(settings.reports_directory):
        sys.exit("Please configure a reports directory path.")

    return app
예제 #4
0
파일: app.py 프로젝트: Fluffinko/cuckoo
def create_app(database_connection):
    app = Flask("Distributed Cuckoo")
    app.config["SQLALCHEMY_DATABASE_URI"] = database_connection
    app.config["SECRET_KEY"] = os.urandom(32)

    for blueprint, routes in blueprints:
        for route in routes:
            app.register_blueprint(blueprint, url_prefix=route)

    db.init_app(app)
    db.create_all(app=app)

    # Check whether an alembic version is present and whether
    # we're up-to-date.
    with app.app_context():
        row = AlembicVersion.query.first()
        if not row:
            db.session.add(AlembicVersion(AlembicVersion.VERSION))
            db.session.commit()
        elif row.version_num != AlembicVersion.VERSION:
            sys.exit("Your database is not up-to-date. Please upgrade it "
                     "using alembic (run `alembic upgrade head`).")

    return app
예제 #5
0
def create_app(database_connection):
    app = Flask("Distributed Cuckoo")
    app.config["SQLALCHEMY_DATABASE_URI"] = database_connection
    app.config["SECRET_KEY"] = os.urandom(32)

    for blueprint, routes in blueprints:
        for route in routes:
            app.register_blueprint(blueprint, url_prefix=route)

    db.init_app(app)
    db.create_all(app=app)

    # Check whether an alembic version is present and whether
    # we're up-to-date.
    with app.app_context():
        row = AlembicVersion.query.first()
        if not row:
            db.session.add(AlembicVersion(AlembicVersion.VERSION))
            db.session.commit()
        elif row.version_num != AlembicVersion.VERSION:
            sys.exit("Your database is not up-to-date. Please upgrade it "
                     "using alembic (run `alembic upgrade head`).")

    return app