コード例 #1
0
ファイル: facade.py プロジェクト: zeazje/szurubooru
def validate_config() -> None:
    '''
    Check whether config doesn't contain errors that might prove
    lethal at runtime.
    '''
    from szurubooru.func.auth import RANK_MAP
    for privilege, rank in config.config['privileges'].items():
        if rank not in RANK_MAP.values():
            raise errors.ConfigError(
                'Rank %r for privilege %r is missing' % (rank, privilege))
    if config.config['default_rank'] not in RANK_MAP.values():
        raise errors.ConfigError(
            'Default rank %r is not on the list of known ranks' % (
                config.config['default_rank']))

    for key in ['base_url', 'api_url', 'data_url', 'data_dir']:
        if not config.config[key]:
            raise errors.ConfigError(
                'Service is not configured: %r is missing' % key)

    if not os.path.isabs(config.config['data_dir']):
        raise errors.ConfigError(
            'data_dir must be an absolute path')

    if not config.config['database']:
        raise errors.ConfigError('Database is not configured')
コード例 #2
0
ファイル: config.py プロジェクト: paul1409/fumobooru
def docker_config() -> Dict:
    for key in [
            'POSTGRES_USER',
            'POSTGRES_PASSWORD',
            'POSTGRES_HOST',
            'ESEARCH_HOST'
    ]:
        if not os.getenv(key, False):
            raise errors.ConfigError(f'Environment variable "{key}" not set')
    return {
        'debug': True,
        'show_sql': int(os.getenv('LOG_SQL', 0)),
        'data_url': os.getenv('DATA_URL', 'data/'),
        'data_dir': '/data/',
        'database': 'postgres://%(user)s:%(pass)s@%(host)s:%(port)d/%(db)s' % {
            'user': os.getenv('POSTGRES_USER'),
            'pass': os.getenv('POSTGRES_PASSWORD'),
            'host': os.getenv('POSTGRES_HOST'),
            'port': int(os.getenv('POSTGRES_PORT', 5432)),
            'db': os.getenv('POSTGRES_DB', os.getenv('POSTGRES_USER'))
        },
        'elasticsearch': {
            'host': os.getenv('ESEARCH_HOST'),
            'port': int(os.getenv('ESEARCH_PORT', 9200)),
            'index': os.getenv('ESEARCH_INDEX', 'szurubooru')
        }
    }
コード例 #3
0
def validate_config() -> None:
    """
    Check whether config doesn't contain errors that might prove
    lethal at runtime.
    """
    from szurubooru.func.auth import RANK_MAP

    for privilege, rank in config.config["privileges"].items():
        if rank not in RANK_MAP.values():
            raise errors.ConfigError("Rank %r for privilege %r is missing" %
                                     (rank, privilege))
    if config.config["default_rank"] not in RANK_MAP.values():
        raise errors.ConfigError(
            "Default rank %r is not on the list of known ranks" %
            (config.config["default_rank"]))

    for key in ["data_url", "data_dir"]:
        if not config.config[key]:
            raise errors.ConfigError(
                "Service is not configured: %r is missing" % key)

    if not os.path.isabs(config.config["data_dir"]):
        raise errors.ConfigError("data_dir must be an absolute path")

    if not config.config["database"]:
        raise errors.ConfigError("Database is not configured")

    if config.config["webhooks"] and not isinstance(config.config["webhooks"],
                                                    list):
        raise errors.ConfigError("Webhooks must be provided as a list of URLs")

    if config.config["smtp"]["host"]:
        if not config.config["smtp"]["port"]:
            raise errors.ConfigError("SMTP host is set but port is not set")
        if not config.config["smtp"]["user"]:
            raise errors.ConfigError(
                "SMTP host is set but username is not set")
        if not config.config["smtp"]["pass"]:
            raise errors.ConfigError(
                "SMTP host is set but password is not set")
        if not config.config["smtp"]["from"]:
            raise errors.ConfigError(
                "From address must be set to use mail-based password reset")
コード例 #4
0
def validate_config() -> None:
    '''
    Check whether config doesn't contain errors that might prove
    lethal at runtime.
    '''
    from szurubooru.func.auth import RANK_MAP
    for privilege, rank in config.config['privileges'].items():
        if rank not in RANK_MAP.values():
            raise errors.ConfigError('권한 %r 의 등급 %r 이(가) 누락되었습니다' %
                                     (privilege, rank))
    if config.config['default_rank'] not in RANK_MAP.values():
        raise errors.ConfigError('기본 등급 %r 은(는) 알려진 등급 리스트에 없습니다' %
                                 (config.config['default_rank']))

    for key in ['base_url', 'api_url', 'data_url', 'data_dir']:
        if not config.config[key]:
            raise errors.ConfigError('서비스가 설정되지 않았습니다: %r 이(가) 누락됨' % key)

    if not os.path.isabs(config.config['data_dir']):
        raise errors.ConfigError('data_dir 는 절대 경로여야 합니다')

    if not config.config['database']:
        raise errors.ConfigError('데이터베이스가 설정되지 않았습니다')
コード例 #5
0
ファイル: facade.py プロジェクト: sun-beyond/szurubooru
def validate_config() -> None:
    '''
    Check whether config doesn't contain errors that might prove
    lethal at runtime.
    '''
    from szurubooru.func.auth import RANK_MAP
    for privilege, rank in config.config['privileges'].items():
        if rank not in RANK_MAP.values():
            raise errors.ConfigError(
                'Rank %r for privilege %r is missing' % (rank, privilege))
    if config.config['default_rank'] not in RANK_MAP.values():
        raise errors.ConfigError(
            'Default rank %r is not on the list of known ranks' % (
                config.config['default_rank']))

    for key in ['data_url', 'data_dir']:
        if not config.config[key]:
            raise errors.ConfigError(
                'Service is not configured: %r is missing' % key)

    if not os.path.isabs(config.config['data_dir']):
        raise errors.ConfigError(
            'data_dir must be an absolute path')

    if not config.config['database']:
        raise errors.ConfigError('Database is not configured')

    if config.config['smtp']['host']:
        if not config.config['smtp']['port']:
            raise errors.ConfigError(
                'SMTP host is set but port is not set')
        if not config.config['smtp']['user']:
            raise errors.ConfigError(
                'SMTP host is set but username is not set')
        if not config.config['smtp']['pass']:
            raise errors.ConfigError(
                'SMTP host is set but password is not set')
        if not config.config['smtp']['from']:
            raise errors.ConfigError(
                'From address must be set to use mail-based password reset')
コード例 #6
0
ファイル: config.py プロジェクト: MrVauxs/szurubooru
def _docker_config() -> Dict:
    for key in ["POSTGRES_USER", "POSTGRES_PASSWORD", "POSTGRES_HOST"]:
        if not os.getenv(key, False):
            raise errors.ConfigError(f'Environment variable "{key}" not set')
    return {
        "debug": True,
        "show_sql": int(os.getenv("LOG_SQL", 0)),
        "data_url": os.getenv("DATA_URL", "data/"),
        "data_dir": "/data/",
        "database": "postgres://%(user)s:%(pass)s@%(host)s:%(port)d/%(db)s"
        % {
            "user": os.getenv("POSTGRES_USER"),
            "pass": os.getenv("POSTGRES_PASSWORD"),
            "host": os.getenv("POSTGRES_HOST"),
            "port": int(os.getenv("POSTGRES_PORT", 5432)),
            "db": os.getenv("POSTGRES_DB", os.getenv("POSTGRES_USER")),
        },
    }