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',
    )

[((6, 17, 6, 66), 'os.getenv', 'os.getenv', ({(6, 27, 6, 49): '"""DATABOARD_SECRET_KEY"""', (6, 51, 6, 65): '"""abcdefghijkl"""'}, {}), "('DATABOARD_SECRET_KEY', 'abcdefghijkl')", False, 'import os\n'), ((15, 18, 15, 70), 'os.getenv', 'os.getenv', ({(15, 28, 15, 51): '"""DATABOARD_MAIL_SERVER"""', (15, 53, 15, 69): '"""smtp.gmail.com"""'}, {}), "('DATABOARD_MAIL_SERVER', 'smtp.gmail.com')", False, 'import os\n'), ((16, 16, 16, 53), 'os.getenv', 'os.getenv', ({(16, 26, 16, 47): '"""DATABOARD_MAIL_PORT"""', (16, 49, 16, 52): '587'}, {}), "('DATABOARD_MAIL_PORT', 587)", False, 'import os\n'), ((17, 20, 17, 64), 'os.getenv', 'os.getenv', ({(17, 30, 17, 55): '"""DATABOARD_MAIL_USERNAME"""', (17, 57, 17, 63): '"""user"""'}, {}), "('DATABOARD_MAIL_USERNAME', 'user')", False, 'import os\n'), ((18, 20, 18, 68), 'os.getenv', 'os.getenv', ({(18, 30, 18, 55): '"""DATABOARD_MAIL_PASSWORD"""', (18, 57, 18, 67): '"""password"""'}, {}), "('DATABOARD_MAIL_PASSWORD', 'password')", False, 'import os\n'), ((29, 30, 29, 59), 'os.getenv', 'os.getenv', ({(29, 40, 29, 58): '"""DATABOARD_DB_URL"""'}, {}), "('DATABOARD_DB_URL')", False, 'import os\n'), ((30, 30, 30, 68), 'os.getenv', 'os.getenv', ({(30, 40, 30, 67): '"""DATABOARD_DB_MIGRATE_REPO"""'}, {}), "('DATABOARD_DB_MIGRATE_REPO')", False, 'import os\n'), ((37, 23, 37, 61), 'os.getenv', 'os.getenv', ({(37, 33, 37, 56): '"""DATABOARD_ADMIN_MAILS"""', (37, 58, 37, 60): '[]'}, {}), "('DATABOARD_ADMIN_MAILS', [])", False, 'import os\n'), ((53, 22, 54, 54), 'os.getenv', 'os.getenv', ({(54, 8, 54, 35): '"""DATABOARD_DEPLOYMENT_PATH"""', (54, 37, 54, 53): '"""/tmp/databoard"""'}, {}), "('DATABOARD_DEPLOYMENT_PATH', '/tmp/databoard')", False, 'import os\n'), ((60, 30, 63, 5), 'os.getenv', 'os.getenv', ({(61, 8, 61, 31): '"""DATABOARD_DB_URL_TEST"""', (62, 8, 62, 61): '"""postgresql://mrramp:mrramp@localhost/databoard_test"""'}, {}), "('DATABOARD_DB_URL_TEST',\n    'postgresql://mrramp:mrramp@localhost/databoard_test')", False, 'import os\n'), ((64, 22, 65, 64), 'os.getenv', 'os.getenv', ({(65, 8, 65, 40): '"""DATABOARD_DEPLOYMENT_PATH_TEST"""', (65, 42, 65, 63): '"""/tmp/databoard_test"""'}, {}), "('DATABOARD_DEPLOYMENT_PATH_TEST', '/tmp/databoard_test')", False, 'import os\n'), ((70, 30, 73, 5), 'os.getenv', 'os.getenv', ({(71, 8, 71, 31): '"""DATABOARD_DB_URL_TEST"""', (72, 8, 72, 61): '"""postgresql://mrramp:mrramp@localhost/databoard_test"""'}, {}), "('DATABOARD_DB_URL_TEST',\n    'postgresql://mrramp:mrramp@localhost/databoard_test')", False, 'import os\n'), ((74, 22, 77, 5), 'os.getenv', 'os.getenv', ({(75, 8, 75, 40): '"""DATABOARD_DEPLOYMENT_PATH_TEST"""', (76, 8, 76, 29): '"""/tmp/databoard_test"""'}, {}), "('DATABOARD_DEPLOYMENT_PATH_TEST', '/tmp/databoard_test')", False, 'import os\n'), ((20, 8, 20, 62), 'os.getenv', 'os.getenv', ({(20, 18, 20, 47): '"""DATABOARD_MAIL_SENDER_ALIAS"""', (20, 49, 20, 61): '"""RAMP admin"""'}, {}), "('DATABOARD_MAIL_SENDER_ALIAS', 'RAMP admin')", False, 'import os\n'), ((21, 8, 21, 66), 'os.getenv', 'os.getenv', ({(21, 18, 21, 41): '"""DATABOARD_MAIL_SENDER"""', (21, 43, 21, 65): '"""rampmailer@gmail.com"""'}, {}), "('DATABOARD_MAIL_SENDER', 'rampmailer@gmail.com')", False, 'import os\n'), ((32, 16, 32, 49), 'os.getenv', 'os.getenv', ({(32, 26, 32, 45): '"""DATABOARD_DB_PERF"""', (32, 47, 32, 48): '(0)'}, {}), "('DATABOARD_DB_PERF', 0)", False, 'import os\n'), ((47, 28, 47, 65), 'os.getenv', 'os.getenv', ({(47, 38, 47, 61): '"""DATABOARD_PARALLELIZE"""', (47, 63, 47, 64): '1'}, {}), "('DATABOARD_PARALLELIZE', 1)", False, 'import os\n')]