class Config: """ The base configuration option. Contains the defaults. """ DEBUG = False DEVELOPMENT = False STAGING = False PRODUCTION = False TESTING = False SECRET_KEY = env.str('SECRET_KEY', default=None) CACHING = False PROFILE = False SQLALCHEMY_RECORD_QUERIES = False FLASK_ADMIN_SWATCH = 'lumen' VERSION = VERSION_NAME SQLALCHEMY_TRACK_MODIFICATIONS = True ERROR_404_HELP = False CSRF_ENABLED = True SERVER_NAME = env('SERVER_NAME', default=None) CORS_HEADERS = 'Content-Type' SQLALCHEMY_DATABASE_URI = env('DATABASE_URL', default=None) SQLALCHEMY_ENGINE_OPTIONS = {'pool_pre_ping': True} SERVE_STATIC = env.bool('SERVE_STATIC', default=False) DATABASE_QUERY_TIMEOUT = 0.1 SENTRY_DSN = env('SENTRY_DSN', default=None) ENABLE_ELASTICSEARCH = env.bool('ENABLE_ELASTICSEARCH', default=False) ELASTICSEARCH_HOST = env('ELASTICSEARCH_HOST', default='localhost:9200') REDIS_URL = env('REDIS_URL', default='redis://localhost:6379/0') CELERY_BACKKEND = env('CELERY_BACKEND', default='redis') # API configs SOFT_DELETE = True PROPOGATE_ERROR = env.bool('PROPOGATE_ERROR', default=False) DASHERIZE_API = True API_PROPOGATE_UNCAUGHT_EXCEPTIONS = env.bool( 'API_PROPOGATE_UNCAUGHT_EXCEPTIONS', default=True) ETAG = True SENTRY_TRACES_SAMPLE_RATE = env.float('SENTRY_TRACES_SAMPLE_RATE', default=0.01) if not SQLALCHEMY_DATABASE_URI: print('`DATABASE_URL` either not exported or empty') exit() BASE_DIR = basedir FORCE_SSL = os.getenv('FORCE_SSL', 'no') == 'yes' if SERVE_STATIC: UPLOADS_FOLDER = BASE_DIR + '/static/uploads/' TEMP_UPLOADS_FOLDER = BASE_DIR + '/static/uploads/temp/' UPLOAD_FOLDER = UPLOADS_FOLDER STATIC_URL = '/static/' STATIC_ROOT = 'staticfiles' STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'), ) if FORCE_SSL: PREFERRED_URL_SCHEME = 'https'
def test_float(): expected = float(env_vars['FLOAT']) assert_type_value(float, expected, env.float('FLOAT'))
from envparse import env MAX_IMG_DIMENSIONAL = env.int("MAX_IMG_DIMENSIONAL", default=1024) SOURCE_IMG_PATH = env.str("SOURCE_IMG_PATH", default="images/source/source.jpg") STYLE_IMG_PATH = env.str("STYLE_IMG_PATH", default="images/style/style.jpg") RESULT_IMG_PATH = env.str("RESULT_IMG_PATH", default="images/result/") ITERATIONS_NUM = env.int("ITERATIONS_NUM", default=1000) CONTENT_WEIGHT = env.float("CONTENT_WEIGHT", default=1e3) STYLE_WEIGHT = env.float("STYLE_WEIGHT", default=1e-2)
class Config: """ The base configuration option. Contains the defaults. """ DEBUG = False DEVELOPMENT = False STAGING = False PRODUCTION = False TESTING = False SECRET_KEY = env.str('SECRET_KEY', default=None) CACHING = False PROFILE = False SQLALCHEMY_RECORD_QUERIES = False FLASK_ADMIN_SWATCH = 'lumen' VERSION = VERSION_NAME ACCEPTED_LANGUAGES = [ 'en', 'bn', 'de', 'es', 'fr', 'hi', 'id', 'ja', 'ko', 'pl', 'ru', 'th', 'vi', 'zh_Hans', 'zh_Hant', ] SQLALCHEMY_TRACK_MODIFICATIONS = True ERROR_404_HELP = False CSRF_ENABLED = True SERVER_NAME = env('SERVER_NAME', default=None) CORS_HEADERS = 'Content-Type' SQLALCHEMY_DATABASE_URI = env('DATABASE_URL', default=None) SQLALCHEMY_ENGINE_OPTIONS = {'pool_pre_ping': True} SERVE_STATIC = env.bool('SERVE_STATIC', default=False) DATABASE_QUERY_TIMEOUT = 0.1 SENTRY_DSN = env('SENTRY_DSN', default=None) SENTRY_RELEASE_NAME = ( env('SENTRY_PROJECT_NAME', default='eventyay-server') + '@' + VERSION_NAME ) SENTRY_TRACES_SAMPLE_RATE = env.float('SENTRY_TRACES_SAMPLE_RATE', default=0.1) ENABLE_ELASTICSEARCH = env.bool('ENABLE_ELASTICSEARCH', default=False) ELASTICSEARCH_HOST = env('ELASTICSEARCH_HOST', default='localhost:9200') REDIS_URL = env('REDIS_URL', default='redis://localhost:6379/0') CELERY_BACKKEND = env('CELERY_BACKEND', default='redis') # API configs SOFT_DELETE = True PROPOGATE_ERROR = env.bool('PROPOGATE_ERROR', default=False) DASHERIZE_API = True API_PROPOGATE_UNCAUGHT_EXCEPTIONS = env.bool( 'API_PROPOGATE_UNCAUGHT_EXCEPTIONS', default=True ) ETAG = True ATTACH_ORDER_PDF = env.bool('ATTACH_ORDER_PDF', default=True) # Allow unverified users to buy free tickets. Default: False ALLOW_UNVERIFIED_FREE_ORDERS = env.bool('ALLOW_UNVERIFIED_FREE_ORDERS', default=False) if not SQLALCHEMY_DATABASE_URI: print('`DATABASE_URL` either not exported or empty') sys.exit() BASE_DIR = basedir FORCE_SSL = os.getenv('FORCE_SSL', 'no') == 'yes' if SERVE_STATIC: UPLOADS_FOLDER = BASE_DIR + '/static/uploads/' TEMP_UPLOADS_FOLDER = BASE_DIR + '/static/uploads/temp/' UPLOAD_FOLDER = UPLOADS_FOLDER STATIC_URL = '/static/' STATIC_ROOT = 'staticfiles' STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),) if FORCE_SSL: PREFERRED_URL_SCHEME = 'https'
import tempfile from envparse import env DATABASE_BACKUPS_PATH = env.str('MTDJ_DATABASE_BACKUPS_PATH', default=tempfile.gettempdir()) DATABASE_BACKUP_TARGETS = [ 'accounts.MoodyUser', 'accounts.UserEmotion', 'accounts.UserSongVote', 'tunes.Emotion', 'tunes.Song', ] IMAGE_FILE_UPLOAD_PATH = env.str('MTDJ_IMAGE_FILE_UPLOAD_PATH', default=tempfile.gettempdir()) BROWSE_DEFAULT_JITTER = env.float('MTDJ_BROWSE_DEFAULT_JITTER', default=0.05) BROWSE_DEFAULT_LIMIT = env.int('MTDJ_BROWSE_DEFAULT_LIMIT', default=9) BROWSE_PLAYLIST_STRATEGIES = ['energy', 'valence', 'danceability'] CANDIDATE_BATCH_SIZE_FOR_USER_EMOTION_ATTRIBUTES_UPDATE = 15 CREATE_USER_EMOTION_RECORDS_SIGNAL_UID = 'user_post_save_create_useremotion_records' UPDATE_USER_EMOTION_ATTRIBUTES_SIGNAL_UID = 'user_song_vote_post_save_update_useremotion_attributes' ADD_SPOTIFY_DATA_TOP_ARTISTS_SIGNAL_UID = 'spotify_auth_post_save_add_spotify_top_artists' LOG_MOODY_USER_FAILED_LOGIN_SIGNAL_UID = 'moody_user_failed_login'
def test_float(): expected = float(env_vars['FLOAT']) assert_type_value(float, expected, env.float('FLOAT'))
from envparse import env env.read_envfile() SERVICE_TOKEN = env.str('SERVICE_TOKEN') API_VERSION = env.float('API_VERSION', default=5.103) BIT_TOKEN = env.str('BIT_TOKEN') BOT_TOKEN = env.str('BOT_TOKEN') REDIS_HOST = env.str('REDIS_HOST', default='localhost') REDIS_PORT = env.int('REDIS_PORT', default=6379) REDIS_PASS = env.str('REDIS_PASS', default=None)