import os
from dotenv import load_dotenv

basedir = os.path.abspath(os.path.dirname(__file__))
load_dotenv(os.path.join(basedir, '.flaskenv'))


class Config(object):
    SECRET_KEY = os.environ.get('SECRET_KEY')
    SECURITY_SALT = os.environ.get('SECURITY_SALT')
    SQLALCHEMY_DATABASE_URI = os.environ.get('DATABASE_URL') or \
        'sqlite:///' + os.path.join(basedir, 'app.db')
    SQLALCHEMY_TRACK_MODIFICATIONS = False
    LOG_TO_STDOUT = os.environ.get('LOG_TO_STDOUT')
    OAUTH2_REFRESH_TOKEN_GENERATOR = False
    NATIVE_CLIENT_ID = os.environ.get('NATIVE_CLIENT_ID')
    NATIVE_CLIENT_SECRET = os.environ.get('NATIVE_CLIENT_SECRET')
    OAUTH2_TOKEN_EXPIRES_IN = {
        'password': 15552000,
        #'refresh_token': 300,
    }

    AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID')
    AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY')
    ASSOCIATE_TAG = os.environ.get('ASSOCIATE_TAG')
    AWS_REGION = os.environ.get('AWS_REGION')
    UPLOAD_FOLDER = os.path.join(basedir, '/app/book_images')

    MAIL_SERVER = os.environ.get('MAIL_SERVER')
    MAIL_PORT = os.environ.get('MAIL_PORT')
    MAIL_USE_SSL = os.environ.get('MAIL_PORT')
    MAIL_USERNAME = os.environ.get('MAIL_USERNAME')
    MAIL_PASSWORD = os.environ.get('MAIL_PASSWORD')
    MAIL_DEFAULT_SENDER = os.environ.get('MAIL_DEFAULT_SENDER')

    APP_NAME = os.environ.get('APP_NAME')
    URL_TOKEN_EXPIRATION = os.environ.get('URL_TOKEN_EXPIRATION')

    PRESERVE_CONTEXT_ON_EXCEPTION = os.environ.get('PRESERVE_CONTEXT_ON_EXCEPTION')
    PROPAGATE_EXCEPTIONS = os.environ.get('PROPAGATE_EXCEPTIONS')