import os


class Config(object):
    # FLASK GENERAL CONFIG PARAMETERS
    SECRET_KEY = os.getenv('DATABOARD_SECRET_KEY', 'abcdefghijkl')
    # abs max upload file size, to throw 413, before saving it
    WTF_CSRF_ENABLED = True
    LOG_FILENAME = None  # if None, output to screen
    MAX_CONTENT_LENGTH = 1024 * 1024 * 1024
    DEBUG = False
    TESTING = False

    # FLASK MAIL CONFIG PARAMETERS
    MAIL_SERVER = os.getenv('DATABOARD_MAIL_SERVER', 'smtp.gmail.com')
    MAIL_PORT = os.getenv('DATABOARD_MAIL_PORT', 587)
    MAIL_USERNAME = os.getenv('DATABOARD_MAIL_USERNAME', 'user')
    MAIL_PASSWORD = os.getenv('DATABOARD_MAIL_PASSWORD', 'password')
    MAIL_DEFAULT_SENDER = (
        os.getenv('DATABOARD_MAIL_SENDER_ALIAS', 'RAMP admin'),
        os.getenv('DATABOARD_MAIL_SENDER', 'rampmailer@gmail.com')
    )
    MAIL_RECIPIENTS = []
    MAIL_USE_TLS = False
    MAIL_USE_SSL = True
    MAIL_DEBUG = False

    SQLALCHEMY_TRACK_MODIFICATIONS = True
    SQLALCHEMY_DATABASE_URI = os.getenv('DATABOARD_DB_URL')
    SQLALCHEMY_MIGRATE_REPO = os.getenv('DATABOARD_DB_MIGRATE_REPO')
    SQLALCHEMY_RECORD_QUERIES = (
        True if os.getenv('DATABOARD_DB_PERF', 0) else False
    )


class RampConfig(object):
    RAMP_ADMIN_MAILS = os.getenv('DATABOARD_ADMIN_MAILS', [])

    RAMP_KITS_DIR = 'ramp-kits'
    RAMP_DATA_DIR = 'ramp-data'
    RAMP_SUBMISSIONS_DIR = 'submissions'
    RAMP_SANDBOX_DIR = 'starting_kit'

    RAMP_SERVER_PORT = 8080
    # make it False if parallel training is not working
    # is_parallelize
    RAMP_PARALLELIZE = bool(os.getenv('DATABOARD_PARALLELIZE', 1))

######################################################################


class ProductionConfig(Config):
    DEPLOYMENT_PATH = os.getenv(
        'DATABOARD_DEPLOYMENT_PATH', '/tmp/databoard')


class DevelopmentConfig(Config):
    DEBUG = True
    MAIL_DEBUG = True
    SQLALCHEMY_DATABASE_URI = os.getenv(
        'DATABOARD_DB_URL_TEST',
        'postgresql://mrramp:mrramp@localhost/databoard_test'
    )
    DEPLOYMENT_PATH = os.getenv(
        'DATABOARD_DEPLOYMENT_PATH_TEST', '/tmp/databoard_test')


class TestingConfig(Config):
    TESTING = True
    SQLALCHEMY_DATABASE_URI = os.getenv(
        'DATABOARD_DB_URL_TEST',
        'postgresql://mrramp:mrramp@localhost/databoard_test'
    )
    DEPLOYMENT_PATH = os.getenv(
        'DATABOARD_DEPLOYMENT_PATH_TEST',
        '/tmp/databoard_test',
    )

[((89, 138), 'os.getenv', 'os.getenv', (['"""DATABOARD_SECRET_KEY"""', '"""abcdefghijkl"""'], {}), "('DATABOARD_SECRET_KEY', 'abcdefghijkl')\n", (98, 138), False, 'import os\n'), ((419, 471), 'os.getenv', 'os.getenv', (['"""DATABOARD_MAIL_SERVER"""', '"""smtp.gmail.com"""'], {}), "('DATABOARD_MAIL_SERVER', 'smtp.gmail.com')\n", (428, 471), False, 'import os\n'), ((488, 525), 'os.getenv', 'os.getenv', (['"""DATABOARD_MAIL_PORT"""', '(587)'], {}), "('DATABOARD_MAIL_PORT', 587)\n", (497, 525), False, 'import os\n'), ((546, 590), 'os.getenv', 'os.getenv', (['"""DATABOARD_MAIL_USERNAME"""', '"""user"""'], {}), "('DATABOARD_MAIL_USERNAME', 'user')\n", (555, 590), False, 'import os\n'), ((611, 659), 'os.getenv', 'os.getenv', (['"""DATABOARD_MAIL_PASSWORD"""', '"""password"""'], {}), "('DATABOARD_MAIL_PASSWORD', 'password')\n", (620, 659), False, 'import os\n'), ((995, 1024), 'os.getenv', 'os.getenv', (['"""DATABOARD_DB_URL"""'], {}), "('DATABOARD_DB_URL')\n", (1004, 1024), False, 'import os\n'), ((1055, 1093), 'os.getenv', 'os.getenv', (['"""DATABOARD_DB_MIGRATE_REPO"""'], {}), "('DATABOARD_DB_MIGRATE_REPO')\n", (1064, 1093), False, 'import os\n'), ((1246, 1284), 'os.getenv', 'os.getenv', (['"""DATABOARD_ADMIN_MAILS"""', '[]'], {}), "('DATABOARD_ADMIN_MAILS', [])\n", (1255, 1284), False, 'import os\n'), ((1730, 1786), 'os.getenv', 'os.getenv', (['"""DATABOARD_DEPLOYMENT_PATH"""', '"""/tmp/databoard"""'], {}), "('DATABOARD_DEPLOYMENT_PATH', '/tmp/databoard')\n", (1739, 1786), False, 'import os\n'), ((1900, 1993), 'os.getenv', 'os.getenv', (['"""DATABOARD_DB_URL_TEST"""', '"""postgresql://mrramp:mrramp@localhost/databoard_test"""'], {}), "('DATABOARD_DB_URL_TEST',\n    'postgresql://mrramp:mrramp@localhost/databoard_test')\n", (1909, 1993), False, 'import os\n'), ((2034, 2100), 'os.getenv', 'os.getenv', (['"""DATABOARD_DEPLOYMENT_PATH_TEST"""', '"""/tmp/databoard_test"""'], {}), "('DATABOARD_DEPLOYMENT_PATH_TEST', '/tmp/databoard_test')\n", (2043, 2100), False, 'import os\n'), ((2190, 2283), 'os.getenv', 'os.getenv', (['"""DATABOARD_DB_URL_TEST"""', '"""postgresql://mrramp:mrramp@localhost/databoard_test"""'], {}), "('DATABOARD_DB_URL_TEST',\n    'postgresql://mrramp:mrramp@localhost/databoard_test')\n", (2199, 2283), False, 'import os\n'), ((2324, 2390), 'os.getenv', 'os.getenv', (['"""DATABOARD_DEPLOYMENT_PATH_TEST"""', '"""/tmp/databoard_test"""'], {}), "('DATABOARD_DEPLOYMENT_PATH_TEST', '/tmp/databoard_test')\n", (2333, 2390), False, 'import os\n'), ((696, 750), 'os.getenv', 'os.getenv', (['"""DATABOARD_MAIL_SENDER_ALIAS"""', '"""RAMP admin"""'], {}), "('DATABOARD_MAIL_SENDER_ALIAS', 'RAMP admin')\n", (705, 750), False, 'import os\n'), ((760, 818), 'os.getenv', 'os.getenv', (['"""DATABOARD_MAIL_SENDER"""', '"""rampmailer@gmail.com"""'], {}), "('DATABOARD_MAIL_SENDER', 'rampmailer@gmail.com')\n", (769, 818), False, 'import os\n'), ((1144, 1177), 'os.getenv', 'os.getenv', (['"""DATABOARD_DB_PERF"""', '(0)'], {}), "('DATABOARD_DB_PERF', 0)\n", (1153, 1177), False, 'import os\n'), ((1563, 1600), 'os.getenv', 'os.getenv', (['"""DATABOARD_PARALLELIZE"""', '(1)'], {}), "('DATABOARD_PARALLELIZE', 1)\n", (1572, 1600), False, 'import os\n')]