config.py 795 Bytes
Newer Older
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import logging
import os

import requests
import toml
from dotenv import load_dotenv

log = logging.getLogger(__name__)

load_dotenv()


SECRET_KEY = os.environ.get("SECRET_KEY") or None


BADGE_CONFIG_URL = os.environ.get("BADGE_CONFIG_URL") or None
BADGE_CONFIG = None
if BADGE_CONFIG_URL is None:
    log.warning("BADGE_CONFIG_URL environment variable is not set, disable badge feature")
else:
    response = requests.get(BADGE_CONFIG_URL)
    if not response.ok:
        log.warning("Can't retrieve badge config from [%s], disable badge feature", BADGE_CONFIG_URL)
    else:
        BADGE_CONFIG = toml.loads(response.text)


SHIELDS_IO_BASE_URL = os.environ.get("SHIELDS_IO_BASE_URL") or None
29
if SHIELDS_IO_BASE_URL and not SHIELDS_IO_BASE_URL.endswith('/'):
30
    SHIELDS_IO_BASE_URL += '/'