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))
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)
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))
def setUpClass(cls): conf = get_def_conf() conf.update({ 'TESTING': True, 'ES_INDEXNAME': 'webant_test', }) cls.conf = conf
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)
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))
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)
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)
def get_wtc(): return create_app(get_def_conf()).test_client()
def test_init_def_conf(): create_app(get_def_conf())
def test_init_debug(): c = get_def_conf() c.update(dict(DEFAULT=True)) create_app(c)
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()