コード例 #1
0
ファイル: libreant_users.py プロジェクト: maxigas/libreant
def libreant_users(debug, settings, users_db, pretty):
    initLoggers(logNames=['config_utils'])
    global conf
    conf = get_def_conf()
    conf.update(load_cfg(settings, debug=debug))
    cliConf = {}
    if debug:
        cliConf['DEBUG'] = True
    if users_db:
        cliConf['USERS_DATABASE'] = users_db
    conf.update(cliConf)
    if conf['USERS_DATABASE'] is None:
        die('--users-db parameter not set')
    if pretty:
        global json_dumps
        json_dumps = pretty_json_dumps
    initLoggers(logging.DEBUG if conf.get('DEBUG', False) else logging.WARNING)

    global usersDB
    try:
        usersDB = users.init_db(conf['USERS_DATABASE'],
                                pwd_salt_size=conf['PWD_SALT_SIZE'],
                                pwd_rounds=conf['PWD_ROUNDS'])
        users.populate_with_defaults()
    except Exception as e:
        if conf['DEBUG']:
            raise
        else:
            die(str(e))
コード例 #2
0
ファイル: libreant_db.py プロジェクト: ael-code/libreant
def libreant_db(debug, settings, fsdb_path, es_indexname, es_hosts):
    initLoggers(logNames=['config_utils'])
    global conf
    conf = config_utils.load_configs('LIBREANT_', defaults=get_def_conf(), path=settings)
    cliConf = {}
    if debug:
        cliConf['DEBUG'] = True
    if fsdb_path:
        cliConf['FSDB_PATH'] = fsdb_path
    if es_indexname:
        cliConf['ES_INDEXNAME'] = es_indexname
    if es_hosts:
        cliConf['ES_HOSTS'] = es_hosts
    conf.update(cliConf)
    initLoggers(logging.DEBUG if conf.get('DEBUG', False) else logging.WARNING)

    try:
        global arc
        arc = Archivant(conf=conf)
    except Exception, e:
        if conf.get('DEBUG', False):
            raise
        else:
            click.secho(str(e), fg='yellow', err=True)
            exit(1)
コード例 #3
0
ファイル: libreant_db.py プロジェクト: insomnia-lab/libreant
def libreant_db(debug, settings, fsdb_path, es_indexname, es_hosts):
    initLoggers(logNames=['config_utils'])
    global conf
    conf = get_def_conf()
    conf.update(load_cfg(settings, debug=debug))
    cliConf = {}
    if debug:
        cliConf['DEBUG'] = True
    if fsdb_path:
        cliConf['FSDB_PATH'] = fsdb_path
    if es_indexname:
        cliConf['ES_INDEXNAME'] = es_indexname
    if es_hosts:
        cliConf['ES_HOSTS'] = es_hosts
    conf.update(cliConf)
    initLoggers(logging.DEBUG if conf.get('DEBUG', False) else logging.INFO)

    try:
        global arc
        arc = Archivant(conf=conf)
    except Exception as e:
        if conf.get('DEBUG', False):
            raise
        else:
            die(str(e))
コード例 #4
0
def libreant_users(debug, settings, users_db, pretty):
    initLoggers(logNames=['config_utils'])
    global conf
    conf = get_def_conf()
    conf.update(load_cfg(settings, debug=debug))
    cliConf = {}
    if debug:
        cliConf['DEBUG'] = True
    if users_db:
        cliConf['USERS_DATABASE'] = users_db
    conf.update(cliConf)
    if conf['USERS_DATABASE'] is None:
        die('--users-db parameter not set')
    if pretty:
        global json_dumps
        json_dumps = pretty_json_dumps
    initLoggers(logging.DEBUG if conf.get('DEBUG', False) else logging.WARNING)

    global usersDB
    try:
        usersDB = users.init_db(conf['USERS_DATABASE'],
                                   pwd_salt_size=conf['PWD_SALT_SIZE'],
                                   pwd_rounds=conf['PWD_ROUNDS'])
        users.populate_with_defaults()
    except Exception as e:
        if conf['DEBUG']:
            raise
        else:
            die(str(e))
コード例 #5
0
ファイル: __init__.py プロジェクト: maxigas/libreant
 def setUpClass(cls):
     conf = get_def_conf()
     conf.update({
         'TESTING': True,
         'ES_INDEXNAME': 'webant_test',
     })
     cls.conf = conf
コード例 #6
0
ファイル: libreant_db.py プロジェクト: maxigas/libreant
def libreant_db(debug, settings, fsdb_path, es_indexname, es_hosts):
    initLoggers(logNames=['config_utils'])
    global conf
    conf = get_def_conf()
    conf.update(load_cfg(settings, debug=debug))
    cliConf = {}
    if debug:
        cliConf['DEBUG'] = True
    if fsdb_path:
        cliConf['FSDB_PATH'] = fsdb_path
    if es_indexname:
        cliConf['ES_INDEXNAME'] = es_indexname
    if es_hosts:
        cliConf['ES_HOSTS'] = es_hosts
    conf.update(cliConf)
    initLoggers(logging.DEBUG if conf.get('DEBUG', False) else logging.INFO)

    try:
        global arc
        arc = Archivant(conf=conf)
    except Exception as e:
        if conf.get('DEBUG', False):
            raise
        else:
            die(str(e))
コード例 #7
0
ファイル: agherant.py プロジェクト: ael-code/libreant
def agherant(settings, debug, port, address, agherant_descriptions):
    initLoggers(logNames=['config_utils'])
    conf = config_utils.load_configs('LIBREANT_', defaults=get_def_conf(), path=settings)
    cliConf = {}
    if debug:
        cliConf['DEBUG'] = True
    if port:
        cliConf['PORT'] = port
    if address:
        cliConf['ADDRESS'] = address
    if agherant_descriptions:
        cliConf['AGHERANT_DESCRIPTIONS'] = agherant_descriptions
    conf.update(cliConf)
    initLoggers(logging.DEBUG if conf.get('DEBUG', False) else logging.WARNING)
    try:
        main(conf)
    except Exception as e:
        if conf.get('DEBUG', False):
            raise
        else:
            click.secho(str(e), fg='yellow', err=True)
コード例 #8
0
def libreant(settings, debug, port, address, fsdb_path, es_indexname, es_hosts,
             users_db, preset_paths, agherant_descriptions, dump_settings):
    initLoggers(logNames=['config_utils'])
    conf = get_def_conf()
    conf.update(load_cfg(settings, debug=debug))
    cliConf = {}
    if debug:
        cliConf['DEBUG'] = True
    if port:
        cliConf['PORT'] = port
    if address:
        cliConf['ADDRESS'] = address
    if fsdb_path:
        cliConf['FSDB_PATH'] = fsdb_path
    if es_indexname:
        cliConf['ES_INDEXNAME'] = es_indexname
    if es_hosts:
        cliConf['ES_HOSTS'] = es_hosts
    if users_db:
        cliConf['USERS_DATABASE'] = users_db
    if preset_paths:
        cliConf['PRESET_PATHS'] = preset_paths
    if agherant_descriptions:
        cliConf['AGHERANT_DESCRIPTIONS'] = agherant_descriptions
    conf.update(cliConf)

    if dump_settings:
        click.echo(json.dumps(conf, indent=3))
        exit(0)

    initLoggers(logging.DEBUG if conf.get('DEBUG', False) else logging.INFO)
    try:
        main(conf)
    except Exception as e:
        if conf.get('DEBUG', False):
            raise
        else:
            die(str(e))
コード例 #9
0
ファイル: agherant.py プロジェクト: maxigas/libreant
def agherant(settings, debug, port, address, agherant_descriptions):
    initLoggers(logNames=['config_utils'])
    conf = get_def_conf()
    conf.update(load_cfg(settings, debug=debug))
    cliConf = {}
    if debug:
        cliConf['DEBUG'] = True
    if port:
        cliConf['PORT'] = port
    if address:
        cliConf['ADDRESS'] = address
    if agherant_descriptions:
        cliConf['AGHERANT_DESCRIPTIONS'] = agherant_descriptions
    conf.update(cliConf)
    initLoggers(logging.DEBUG if conf.get('DEBUG', False) else logging.INFO)
    try:
        main(conf)
    except Exception as e:
        if conf.get('DEBUG', False):
            raise
        else:
            click.secho(str(e), fg='yellow', err=True)
            exit(1)
コード例 #10
0
ファイル: libreant.py プロジェクト: ael-code/libreant
def libreant(settings, debug, port, address, fsdb_path, es_indexname, es_hosts, users_db, preset_paths, agherant_descriptions, dump_settings):
    initLoggers(logNames=['config_utils'])
    conf = config_utils.load_configs('LIBREANT_', defaults=get_def_conf(), path=settings)
    cliConf = {}
    if debug:
        cliConf['DEBUG'] = True
    if port:
        cliConf['PORT'] = port
    if address:
        cliConf['ADDRESS'] = address
    if fsdb_path:
        cliConf['FSDB_PATH'] = fsdb_path
    if es_indexname:
        cliConf['ES_INDEXNAME'] = es_indexname
    if es_hosts:
        cliConf['ES_HOSTS'] = es_hosts
    if users_db:
        cliConf['USERS_DATABASE'] = users_db
    if preset_paths:
        cliConf['PRESET_PATHS'] = preset_paths
    if agherant_descriptions:
        cliConf['AGHERANT_DESCRIPTIONS'] = agherant_descriptions
    conf.update(cliConf)

    if dump_settings:
        click.echo(json.dumps(conf, indent=3))
        exit(0)

    initLoggers(logging.DEBUG if conf.get('DEBUG', False) else logging.WARNING)
    try:
        main(conf)
    except Exception as e:
        if conf.get('DEBUG', False):
            raise
        else:
            click.secho(str(e), fg='yellow', err=True)
            exit(1)
コード例 #11
0
ファイル: test_main_routes.py プロジェクト: ael-code/libreant
def get_wtc():
    return create_app(get_def_conf()).test_client()
コード例 #12
0
def test_init_def_conf():
    create_app(get_def_conf())
コード例 #13
0
def test_init_debug():
    c = get_def_conf()
    c.update(dict(DEFAULT=True))
    create_app(c)
コード例 #14
0
ファイル: __init__.py プロジェクト: ael-code/libreant
 def setUp(self):
     conf = get_def_conf()
     conf['USERS_DATABASE'] = "sqlite:///:memory:"
     conf['PWD_ROUNDS'] = 1
     conf['TESTING'] = True
     self.wtc = create_app(conf).test_client()