# -*- coding: utf-8 -*-
# Django settings for a Codespeed project.
import os

DEBUG = True
TEMPLATE_DEBUG = DEBUG

BASEDIR = os.path.abspath(os.path.dirname(__file__))
TOPDIR = os.path.split(BASEDIR)[1]

PARENT_DIR = os.path.split(BASEDIR)[-1]
ALLOWED_HOSTS = [PARENT_DIR + '.stefan-marr.de', '127.0.0.1']

#: The directory which should contain checked out source repositories:
REPOSITORY_BASE_PATH = os.path.join(BASEDIR, "repos")

ADMINS = (
    # ('Your Name', 'your_email@domain.com'),
)

MANAGERS = ADMINS
DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASEDIR, 'data.db'),
    }
}

TIME_ZONE = 'Europe/Brussels'

LANGUAGE_CODE = 'en-us'

SITE_ID = 1

USE_I18N = False

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = os.path.join(BASEDIR, "media")

# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = '/media/'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/static/admin/'

# Make this unique, and don't share it with anybody.
SECRET_KEY = 'as%n_m#)^vee2pe91^^@c))sl7^c6t-9r8n)_69%)2yt+(la2&'


MIDDLEWARE = (
    'django.middleware.common.CommonMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
)

# if DEBUG:
#     import traceback
#     import logging
#
#     # Define a class that logs unhandled errors
#     class LogUncatchedErrors:
#         def __init__(self, arg):
#             pass
#
#         def __call__(self, arg):
#             pass
#
#         def process_exception(self, request, exception):
#             logging.error("Unhandled Exception on request for %s\n%s" %
#                                  (request.build_absolute_uri(),
#                                   traceback.format_exc()))
#     # And add it to the middleware classes
#     MIDDLEWARE += ('settings.LogUncatchedErrors',)
#
#     # set shown level of logging output to debug
#     logging.basicConfig(level=logging.DEBUG)

ROOT_URLCONF = '{0}.urls'.format(TOPDIR)


TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASEDIR, 'templates')],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.admin',
    'django.contrib.staticfiles',
    'codespeed',
)


STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASEDIR, "sitestatic")
STATICFILES_DIRS = (
    os.path.join(BASEDIR, 'static'),
)


# Codespeed settings that can be overwritten here.
from codespeed.settings import *

## General default options ##
WEBSITE_NAME = "SOM: Simple Object Machine" # This name will be used in the reports RSS feed

DEF_ENVIRONMENT = "Infinity Ubuntu" #Name of the environment which should be selected as default


DEF_BASELINE = None # Which executable + revision should be default as a baseline
                    # Given as the name of the executable and commitid of the revision
                    # Example: defaultbaseline = {'executable': 'myexe', 'revision': '21'}

## Changes view options ##
DEF_EXECUTABLE = 'Java8U66' # Executable that should be chosen as default in the changes view
                      # Given as the name of the executable.
                      # Example: defaultexecutable = "myexe"

## Timeline view options ##
DEF_BENCHMARK = "grid" # Default selected benchmark. Possible values:
                       #   "grid": will show the grid of plots
                       #   "show_none": will just show a text message
                       #   "mybench": will select benchmark "mybench"

TIMELINE_BRANCHES = True # NOTE: Only the default branch is currently shown
                         # Get timeline results for specific branches
                         # Set to False if you want timeline plots and results only for trunk.

NORMALIZATION = True # True will enable normalization as the default selection
                      # in the Comparison view. The default normalization can be
                      # chosen in the defaultbaseline setting

CHART_ORIENTATION = 'horizontal' # 'vertical' or 'horizontal can be chosen as
                              # default chart orientation

COMP_EXECUTABLES = [('RPySOM-jit', 'L'),
                    ('TruffleSOM', 'L'),
                    ('SOMpp',      'L') ]  # Which executable + revision should be checked as default
                         # Given as a list of tuples containing the
                         # name of an executable + commitid of a revision
                         # An 'L' denotes the last revision
                         # Example:
                         # COMP_EXECUTABLES = [
                         #     ('myexe', '21df2423ra'),
                         #     ('myexe', 'L'),]

ALLOW_ANONYMOUS_POST = True  # Whether anonymous users can post results
REQUIRE_SECURE_AUTH = False  # Whether auth needs to be over a secure channel

