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 # ----------------------------------------------------------------------------- # 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 = { 'site': 'commands/site', 'admin': 'commands/admin', 'db': '', 'flask': '', 'demo': '', } # ----------------------------------------------------------------------------- # 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_CONTENT = join(DIR_DATA_STORE, 'content') 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') DIR_STATIC = join(DIR_APP, 'static') HASH_TREE_DEPTH = 3 # for sha256 subdirs HASH_BRANCH_SIZE = 3 # for sha256 subdirs DIR_PUBLIC_EXPORTS = os.getenv('DIR_PUBLIC_EXPORTS') or DIR_EXPORTS # ----------------------------------------------------------------------------- # Database # ----------------------------------------------------------------------------- USE_SQLITE = os.getenv("USE_SQLITE") == "True" # ----------------------------------------------------------------------------- # S3 storage # ----------------------------------------------------------------------------- try: S3_HTTP_BASE_URL = os.getenv("S3_HTTP_BASE_URL") except Exception as e: pass # ----------------------------------------------------------------------------- # Exports # ----------------------------------------------------------------------------- SERVER_NAME = os.getenv('SERVER_NAME') or '0.0.0.0:5000' DEMO_SERVER_NAME = os.getenv('DEMO_SERVER_NAME') or '0.0.0.0:3000' HTTP_EXTERNAL_HOST = os.getenv('HTTP_EXTERNAL_HOST') or f"http://{SERVER_NAME}" # ----------------------------------------------------------------------------- # Unicode symbols for logger # ----------------------------------------------------------------------------- UCODE_OK = u"\u2714" # check ok UCODE_NOK = u'\u2718' # x no ok