Example #1
0
    def create_app(self):
        oauth.remote_apps = {}

        # The testing configuration is inferred from the production
        # settings, but it can only be derived after the config files
        # have actually been evaluated.
        settings.APP_NAME = APP_NAME
        settings.TESTING = True
        settings.DEBUG = True
        settings.CACHE = True
        settings.EAGER = True
        settings.SECRET_KEY = 'batman'
        settings.APP_UI_URL = UI_URL
        settings.ARCHIVE_TYPE = 'file'
        settings.ARCHIVE_PATH = self.temp_dir
        settings.DATABASE_URI = DB_URI
        settings.ALEPH_PASSWORD_LOGIN = True
        settings.MAIL_SERVER = None
        settings.ENTITIES_SERVICE = None
        settings.INDEX_PREFIX = APP_NAME
        settings.INDEX_WRITE = 'yolo'
        settings.INDEX_READ = [settings.INDEX_WRITE]
        settings.REDIS_URL = None
        settings._gcp_logger = None
        app = create_app({})
        mount_app_blueprints(app)
        return app
Example #2
0
    def create_app(self):
        oauth.remote_apps = {}

        # The testing configuration is inferred from the production
        # settings, but it can only be derived after the config files
        # have actually been evaluated.
        settings.APP_NAME = APP_NAME
        settings.TESTING = True
        settings.DEBUG = True
        settings.CACHE = True
        settings.EAGER = True
        settings.SECRET_KEY = 'batman'
        settings.APP_UI_URL = UI_URL
        settings.ARCHIVE_TYPE = 'file'
        settings.ARCHIVE_PATH = self.temp_dir
        settings.DATABASE_URI = DB_URI
        settings.ALEPH_PASSWORD_LOGIN = True
        settings.MAIL_SERVER = None
        settings.ENTITIES_SERVICE = None
        settings.ENTITIES_INDEX = '%s_entity' % APP_NAME
        settings.ENTITIES_INDEX_SET = [settings.ENTITIES_INDEX]
        settings.RECORDS_INDEX = '%s_records' % APP_NAME
        settings.RECORDS_INDEX_SET = [settings.RECORDS_INDEX]
        settings.COLLECTIONS_INDEX = '%s_collection' % APP_NAME
        settings.REDIS_URL = None
        app = create_app({})
        mount_app_blueprints(app)
        return app
Example #3
0
File: util.py Project: pudo/aleph
    def create_app(self):
        oauth.remote_apps = {}

        # The testing configuration is inferred from the production
        # settings, but it can only be derived after the config files
        # have actually been evaluated.
        settings.APP_NAME = APP_NAME
        settings.TESTING = True
        settings.DEBUG = True
        settings.CACHE = True
        settings.EAGER = True
        settings.SECRET_KEY = 'batman'
        settings.APP_UI_URL = UI_URL
        settings.ARCHIVE_TYPE = 'file'
        settings.ARCHIVE_PATH = self.temp_dir
        settings.DATABASE_URI = DB_URI
        settings.ALEPH_PASSWORD_LOGIN = True
        settings.MAIL_SERVER = None
        settings.ENTITIES_SERVICE = None
        settings.INDEX_PREFIX = APP_NAME
        settings.INDEX_WRITE = 'yolo'
        settings.INDEX_READ = [settings.INDEX_WRITE]
        settings.REDIS_URL = None
        settings._gcp_logger = None
        app = create_app({})
        mount_app_blueprints(app)
        return app
Example #4
0
 def create_app(self):
     self.temp_dir = mkdtemp()
     oauth.remote_apps = {}
     app_name = 'aleph_test_name'
     app = create_app({
         'DEBUG':
         True,
         'TESTING':
         True,
         'CACHE':
         True,
         'SECRET_KEY':
         'batman',
         'ARCHIVE_TYPE':
         'file',
         'ARCHIVE_PATH':
         self.temp_dir,
         'APP_NAME':
         app_name,
         'PRESERVE_CONTEXT_ON_EXCEPTION':
         False,
         'SQLALCHEMY_DATABASE_URI':
         (os.environ.get('ALEPH_DATABASE_URI') + '_test'),
         'ELASTICSEARCH_INDEX':
         (os.environ.get('ELASTICSEARCH_INDEX', app_name) + '_test'),
         'CELERY_ALWAYS_EAGER':
         True
     })
     mount_app_blueprints(app)
     return app
Example #5
0
def create_app(config={}):
    configure_logging(level=logging.DEBUG)
    app = Flask("aleph")
    app.config.from_object(settings)
    app.config.update(config)

    if "postgres" not in settings.DATABASE_URI:
        raise RuntimeError("aleph database must be PostgreSQL!")

    app.config.update({
        "SQLALCHEMY_DATABASE_URI": settings.DATABASE_URI,
        "FLASK_SKIP_DOTENV": True,
        "FLASK_DEBUG": settings.DEBUG,
        "BABEL_DOMAIN": "aleph",
        "PROFILE": settings.PROFILE,
    })

    if settings.PROFILE:
        app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[30])

    migrate.init_app(app, db, directory=settings.ALEMBIC_DIR)
    configure_oauth(app, cache=get_cache())
    mail.init_app(app)
    db.init_app(app)
    babel.init_app(app)
    CORS(
        app,
        resources=r"/api/*",
        origins=settings.CORS_ORIGINS,
        supports_credentials=True,
    )
    feature_policy = {
        "accelerometer": NONE,
        "camera": NONE,
        "geolocation": NONE,
        "gyroscope": NONE,
        "magnetometer": NONE,
        "microphone": NONE,
        "payment": NONE,
        "usb": NONE,
    }
    talisman.init_app(
        app,
        force_https=settings.FORCE_HTTPS,
        strict_transport_security=settings.FORCE_HTTPS,
        feature_policy=feature_policy,
        content_security_policy=settings.CONTENT_POLICY,
    )

    from aleph.views import mount_app_blueprints

    mount_app_blueprints(app)

    # This executes all registered init-time plugins so that other
    # applications can register their behaviour.
    for plugin in get_extensions("aleph.init"):
        plugin(app=app)

    return app
Example #6
0
def create_app(config={}):
    configure_logging()
    app = Flask('aleph')
    app.config.from_object(settings)
    app.config.update(config)

    if 'postgres' not in settings.DATABASE_URI:
        raise RuntimeError("aleph database must be PostgreSQL!")

    app.config.update({
        'SQLALCHEMY_DATABASE_URI': settings.DATABASE_URI,
        'FLASK_SKIP_DOTENV': True,
        'FLASK_DEBUG': settings.DEBUG,
        'BABEL_DOMAIN': 'aleph',
    })

    migrate.init_app(app, db, directory=settings.ALEMBIC_DIR)
    configure_oauth(app, cache=get_cache())
    mail.init_app(app)
    db.init_app(app)
    babel.init_app(app)
    CORS(app,
         resources=r'/api/*',
         origins=settings.CORS_ORIGINS,
         supports_credentials=True)
    feature_policy = {
        'accelerometer': NONE,
        'camera': NONE,
        'geolocation': NONE,
        'gyroscope': NONE,
        'magnetometer': NONE,
        'microphone': NONE,
        'payment': NONE,
        'usb': NONE
    }
    talisman.init_app(app,
                      force_https=settings.FORCE_HTTPS,
                      strict_transport_security=settings.FORCE_HTTPS,
                      feature_policy=feature_policy,
                      content_security_policy=settings.CONTENT_POLICY)

    from aleph.views import mount_app_blueprints
    mount_app_blueprints(app)

    # Monkey-patch followthemoney
    # from aleph.logic.names import name_frequency
    # registry.name._specificity = name_frequency

    # This executes all registered init-time plugins so that other
    # applications can register their behaviour.
    for plugin in get_extensions('aleph.init'):
        plugin(app=app)

    return app
Example #7
0
File: util.py Project: tomjie/aleph
 def create_app(self):
     self.temp_dir = mkdtemp()
     app = create_app({
         'DEBUG': True,
         'TESTING': True,
         'CACHE': True,
         'SECRET_KEY': 'batman',
         'ARCHIVE_TYPE': 'file',
         'ARCHIVE_PATH': self.temp_dir,
         'APP_NAME': 'aleph_test_name',
         'PRESERVE_CONTEXT_ON_EXCEPTION': False,
         'CELERY_ALWAYS_EAGER': True
     })
     mount_app_blueprints(app)
     return app
Example #8
0
 def create_app(self):
     self.temp_dir = mkdtemp()
     app = create_app({
         'DEBUG': True,
         'TESTING': True,
         'CACHE': True,
         'SECRET_KEY': 'batman',
         'ARCHIVE_TYPE': 'file',
         'ARCHIVE_PATH': self.temp_dir,
         'APP_NAME': 'aleph_test_name',
         'PRESERVE_CONTEXT_ON_EXCEPTION': False,
         'CELERY_ALWAYS_EAGER': True
     })
     mount_app_blueprints(app)
     return app
Example #9
0
    def create_app(self):
        oauth.remote_apps = {}

        # The testing configuration is inferred from the production
        # settings, but it can only be derived after the config files
        # have actually been evaluated.
        settings.APP_NAME = APP_NAME
        settings.TESTING = True
        settings.DEBUG = True
        settings.CACHE = True
        settings.SECRET_KEY = 'batman'
        settings.APP_UI_URL = UI_URL
        settings.ARCHIVE_TYPE = 'file'
        settings.ARCHIVE_PATH = self.temp_dir
        settings.DATABASE_URI = DB_URI
        settings.QUEUE = False
        settings.MAIL_SERVER = None
        app = create_app({})
        mount_app_blueprints(app)
        return app
Example #10
0
from aleph.ingest import ingest_document
from aleph.index import delete_index, upgrade_search
from aleph.index import index_document_id
from aleph.logic import reindex_entities, delete_collection, process_collection
from aleph.logic import update_collection
from aleph.logic.alerts import check_alerts
from aleph.logic.bulk import bulk_load
from aleph.logic.xref import xref_collection
from aleph.util import load_config_file


log = logging.getLogger('aleph')
flask_script_commands.text_type = str

app = create_app()
mount_app_blueprints(app)
manager = Manager(app)
manager.add_command('db', MigrateCommand)
manager.add_command('routes', ShowUrls)


@manager.command
def collections():
    """List all collections."""
    for collection in Collection.all():
        print collection.id, collection.foreign_id, collection.label


@manager.command
def alerts():
    """Generate alert notifications."""
Example #11
0
from aleph.alerts import check_alerts
from aleph.ingest import reingest_collection
from aleph.index import init_search, delete_index, upgrade_search
from aleph.index import index_document_id
from aleph.logic import reindex_entities, delete_collection, analyze_collection
from aleph.graph import upgrade_graph, load_documents, load_entities
from aleph.ext import get_crawlers
from aleph.crawlers.directory import DirectoryCrawler
from aleph.crawlers.sql import SQLCrawler
from aleph.crawlers.metafolder import MetaFolderCrawler


log = logging.getLogger('aleph')

app = create_app()
mount_app_blueprints(app)
manager = Manager(app)
manager.add_command('assets', ManageAssets(assets))
manager.add_command('db', MigrateCommand)


@manager.command
def collections():
    """List all collections."""
    for collection in Collection.all():
        print collection.id, collection.foreign_id, collection.label


@manager.command
def alerts():
    """Generate alert notifications."""