diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2020-05-30 17:27:04 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2020-05-30 17:27:04 +0200 |
| commit | 0890fdd951d021308550a0db2e7b6f2593512957 (patch) | |
| tree | a0050b153242ccde662fc0a957a79fc7a7edc4b4 /cli/app/settings/app_cfg.py | |
initial site copied in
Diffstat (limited to 'cli/app/settings/app_cfg.py')
| -rw-r--r-- | cli/app/settings/app_cfg.py | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/cli/app/settings/app_cfg.py b/cli/app/settings/app_cfg.py new file mode 100644 index 0000000..094f51e --- /dev/null +++ b/cli/app/settings/app_cfg.py @@ -0,0 +1,94 @@ +import os +from os.path import join +import collections +import logging + +from dotenv import load_dotenv +import yaml + +from app.models import types +from pathlib import Path + +import codecs +codecs.register(lambda name: codecs.lookup('utf8') if name == 'utf8mb4' else None) + +LOG = logging.getLogger('swimmer') + +# ----------------------------------------------------------------------------- +# .env config for keys +# ----------------------------------------------------------------------------- +# Project directory +SELF_CWD = os.path.dirname(os.path.realpath(__file__)) # this file +DIR_PROJECT_ROOT = str(Path(SELF_CWD).parent.parent.parent) + +# source .env vars +fp_env = join(DIR_PROJECT_ROOT, '.env') +load_dotenv(dotenv_path=fp_env) +# VFRAME_PRODUCTION = os.getenv('VFRAME_ENV') == 'production' + +# ----------------------------------------------------------------------------- +# Click config +# ----------------------------------------------------------------------------- + +CLICK_GROUPS = { + # 'process': 'commands/process', + 'db': '', + 'flask': '', +} + + +# ----------------------------------------------------------------------------- +# File I/O +# ----------------------------------------------------------------------------- + +SELF_CWD = os.path.dirname(os.path.realpath(__file__)) # Script CWD +DIR_APP = str(Path(SELF_CWD).parent.parent.parent) + +DIR_DATA_STORE = join(DIR_APP, 'data_store') + +DIR_DATABASE = join(DIR_DATA_STORE, 'db') +DIR_UPLOADS = join(DIR_DATA_STORE, 'uploads') +DIR_EXPORTS = join(DIR_DATA_STORE, 'exports') + +DIR_DOCS = join(DIR_APP, 'docs') + +URL_DATA = '/static/data/' +URL_MEDIA = join(URL_DATA, 'media') +URL_UPLOADS = join(URL_DATA, 'uploads') +URL_EXPORTS = join(URL_DATA, 'exports') + +if 'cli' in os.getcwd(): + DIR_STATIC = os.path.abspath('../static') +else: + DIR_STATIC = os.path.abspath('static') + +HASH_TREE_DEPTH = 3 # for sha256 subdirs +HASH_BRANCH_SIZE = 3 # for sha256 subdirs + + +# ----------------------------------------------------------------------------- +# S3 storage +# ----------------------------------------------------------------------------- + +try: + S3_HTTP_BASE_URL = os.getenv("S3_HTTP_BASE_URL") + DIR_S3_VER = 'v2' + DIR_S3_MODELS = join(DIR_S3_VER, 'models') + S3_HTTP_MODELS_URL = join(S3_HTTP_BASE_URL, DIR_S3_MODELS) +except Exception as e: + # LOG.error(f'S3 .env variables not set. Can not access models.') + pass + +# ----------------------------------------------------------------------------- +# Exports +# ----------------------------------------------------------------------------- + +HTTP_EXTERNAL_HOST = os.getenv('HTTP_EXTERNAL_HOST') or "http://0.0.0.0:5000" + + +# ----------------------------------------------------------------------------- +# Unicode symbols for logger +# ----------------------------------------------------------------------------- + +UCODE_OK = u"\u2714" # check ok +UCODE_NOK = u'\u2718' # x no ok
\ No newline at end of file |
