#!/usr/bin/env python

"""
Pootle configuration for Travis
https://travis-ci.org
"""

import os


if os.environ.get("TRAVIS"):
    DEBUG = False
    TEMPLATE_DEBUG = DEBUG

    DATABASE_BACKEND = os.environ.get("DATABASE_BACKEND")
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': working_path('dbs/pootle_travis.db'),
            'USER': '',
            'PASSWORD': '',
            'HOST': '',
            'PORT': '',
            'ATOMIC_REQUESTS': True,
        }
    }

    CACHES = {
        'default': {
            'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
            'LOCATION': '127.0.0.1:11211',
        }
    }

    if DATABASE_BACKEND == "postgres":
        DATABASES['default']['ENGINE'] = 'django.db.backends.postgresql_psycopg2'
        DATABASES['default']['NAME'] = 'pootle'
        DATABASES['default']['USER'] = 'postgres'
    elif DATABASE_BACKEND == "mysql":
        DATABASES['default']['ENGINE'] = 'django.db.backends.mysql'
        DATABASES['default']['NAME'] = 'pootle'
        DATABASES['default']['USER'] = 'travis'
