Example #1
0
def get_db_username():
    url = get_setting("DATABASE_URL")
    if not url:
        return "--- no database configured ---"

    url = urlsplit(url)
    return url.username
Example #2
0
def get_db_name():
    url = get_setting("DATABASE_URL")
    if not url:
        return "--- no database configured ---"

    url = urlsplit(url)
    name = url.path.replace("/", "")
    return name
Example #3
0
File: db.py Project: KozlovSer/TMS
def get_db_host():
    url = get_setting("DATABASE_URL")
    if not url:
        return "--- no database configured ---"

    url = urlsplit(url)
    host = url.hostname
    return host
Example #4
0
File: db.py Project: KozlovSer/TMS
def get_db_port():
    url = get_setting("DATABASE_URL")
    if not url:
        return "--- no database configured ---"

    url = urlsplit(url)
    port = int(url.port or 5432)
    return port
Example #5
0
def in_virtualenv():
    try:
        from framework.util.settings import get_setting
    except ImportError:
        # noinspection PyUnresolvedReferences
        from settings import get_setting

    synth_venv = get_setting("VENV_SYNTHETIC", False, convert=bool)
    actual_venv = _discover_venv_by_prefix()
    return synth_venv or actual_venv
Example #6
0
def in_virtualenv():
    try:
        from framework.util.settings import get_setting

        synth_venv = get_setting("VENV_SYNTHETIC")
    except ImportError:
        env_value = os.getenv("VENV_SYNTHETIC", "False").capitalize()
        synth_venv = bool(eval(env_value))

    actual_venv = _discover_venv_by_prefix()
    return bool(synth_venv or actual_venv)
def set_config_vars():
    token = get_setting("HEROKU_API_TOKEN")
    app_id = get_setting("HEROKU_API_APP_ID")
    sentry_dsn = get_setting("SENTRY_DSN")

    url = f"{API}/{app_id}/config-vars"

    headers = {
        "Accept": "application/vnd.heroku+json; version=3",
        "Authorization": f"Bearer {token}",
        "Content-Type": "application/json",
    }

    payload = {
        "DYNACONF_SENTRY_DSN": sentry_dsn,
        "ENV_FOR_DYNACONF": "heroku",
        "PYTHONPATH": "src",
    }

    resp = requests.patch(url, headers=headers, json=payload)
    print(resp.json())
Example #8
0
import sentry_sdk
from main.custom_types import RequestT
from framework.util.settings import get_setting
from main.handlers import get_handler
from main.handlers import handle_500

sentry_sdk.init(get_setting("SENTRY_DSN"), traces_sample_rate=1.0)


def application(environ, start_response):
    request = RequestT(environ)
    handler = get_handler(request)

    try:
        response = handler(request)
    except Exception:
        response = handle_500(request)

    status = f"{response.status.value} {response.status.phrase}"
    headers_list = list(response.headers_items())
    start_response(status, headers_list)

    yield response.payload.encode()
Example #9
0
from framework.util.settings import get_setting

HOST = get_setting("HOST", "localhost")
PORT = get_setting("PORT", 8000, convert=int)
DATABASE_URL = get_setting("DATABASE_URL")
from multiprocessing import cpu_count

from framework.dirs import DIR_SRC
from framework.util.settings import get_setting

_port = get_setting("PORT", 8000, convert=int)
bind = f"0.0.0.0:{_port}"
chdir = DIR_SRC.as_posix()
graceful_timeout = 10
max_requests = 200
max_requests_jitter = 20
pythonpath = DIR_SRC.as_posix()
reload = False
timeout = 30
worker_class = "framework.workers.AsyncioUvicornWorker"
workers = get_setting("WEB_CONCURRENCY", cpu_count() * 2 + 1, convert=int)