import os
import sys

import contracts
import dj_database_url
from django.contrib import messages
from django.core.exceptions import ImproperlyConfigured
import shortuuid
from signalbox.utilities.get_env_variable import get_env_variable
from twilio.exceptions import TwilioException
from twilio.rest import TwilioRestClient


# String of space separated email addresses to be sent notifications when
DATA_ADMINS = get_env_variable("DATA_ADMINS", default="", required=False).split()


# Disable pycontracts in production for performance reasons.
CONTRACTS_ENABLED = get_env_variable("CONTRACTS_ENABLED", default=False)
if not CONTRACTS_ENABLED:
    contracts.disable_all()


#### VERSIONING ###

# Determines whether the Reversion machinery is employed to keep logs
# of changes to Answers, Observations etc. It's off by default, because it rapidly
# generates a lot of data, but is useful for complex studies.

USE_VERSIONING = get_env_variable("USE_VERSIONING", default=False)
from signalbox.configurable_settings import *
from signalbox.utilities.get_env_variable import get_env_variable
import twilio
from twilio.rest import TwilioRestClient
import imp
import sys
import os
import socket
import string

sys.path.insert(1, os.path.dirname(os.path.realpath(__file__)))

# This must be set but using random string#
SECRET_KEY = get_env_variable(
    'SECRET_KEY',
    required=True,
    default=shortuuid.uuid(),
    warning="USING RANDOM SECRET KEY - SESSIONS MAY NOT PERSIST")

try:
    TESTING = 'test' == sys.argv[1]
except IndexError:
    TESTING = False

# yaml setting - can be set as "true" or "false" but not "True"/"False"
DEBUG = bool(
    get_env_variable('DEBUG', required=False, default=False, as_yaml=True))

# Display and admin functionality
USE_I18N = False
USE_L10N = False
from signalbox.configurable_settings import *
from signalbox.utilities.get_env_variable import get_env_variable
import twilio
from twilio.rest import TwilioRestClient
import imp
import sys
import os
import socket
import string

sys.path.insert(1, os.path.dirname(os.path.realpath(__file__)))


# This must be set but using random string#
SECRET_KEY = get_env_variable('SECRET_KEY',
    required=True,
    default=shortuuid.uuid(),
    warning="USING RANDOM SECRET KEY - SESSIONS MAY NOT PERSIST")


try:
    TESTING = 'test' == sys.argv[1]
except IndexError:
    TESTING = False


# yaml setting - can be set as "true" or "false" but not "True"/"False"
DEBUG = bool(get_env_variable('DEBUG', required=False, default=False, as_yaml=True))


# Display and admin functionality
USE_I18N = False
import os
import sys
from django.core.exceptions import ImproperlyConfigured
import dj_database_url
import shortuuid
from signalbox.utilities.get_env_variable import get_env_variable
from twilio.exceptions import TwilioException
from twilio.rest import TwilioRestClient


# This must be set but using random string#
SECRET_KEY = get_env_variable('SECRET_KEY',
    required=True,
    default=shortuuid.uuid(),
    warning="USING RANDOM SECRET KEY - SESSIONS MAY NOT PERSIST")

try:
    TESTING = 'test' == sys.argv[1]
except IndexError:
    TESTING = False

# override setting above in testing because some tests need it
if bool('test' in sys.argv):
    print "Turning on versioning because we are testing"
    USE_VERSIONING = True


# yaml setting - can be set as "true" or "false" but not "True"/"False"
DEBUG = bool(get_env_variable('DEBUG', required=False, default=False, as_yaml=True))

import os
import sys

import contracts
import dj_database_url
from django.contrib import messages
from django.core.exceptions import ImproperlyConfigured
import shortuuid
from signalbox.utilities.get_env_variable import get_env_variable
from twilio.exceptions import TwilioException
from twilio.rest import TwilioRestClient

# String of space separated email addresses to be sent notifications when
DATA_ADMINS = get_env_variable("DATA_ADMINS", default="",
                               required=False).split()

# Disable pycontracts in production for performance reasons.
CONTRACTS_ENABLED = get_env_variable('CONTRACTS_ENABLED', default=False)
if not CONTRACTS_ENABLED:
    contracts.disable_all()

#### VERSIONING ###

# Determines whether the Reversion machinery is employed to keep logs
# of changes to Answers, Observations etc. It's off by default, because it rapidly
# generates a lot of data, but is useful for complex studies.

USE_VERSIONING = get_env_variable('USE_VERSIONING', default=False)

# override setting above in testing because some tests need it
if bool('test' in sys.argv):