File: settings.py

package info (click to toggle)
graphite-web 1.2.1~pre2-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 8,976 kB
  • sloc: javascript: 86,824; python: 25,420; makefile: 124; sh: 91; ruby: 74; perl: 24
file content (88 lines) | stat: -rw-r--r-- 2,806 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
from __future__ import print_function
import atexit
import os
import shutil
import tempfile

from django import VERSION
from django.conf import settings, global_settings

# Silence the warning about an insecure SECRET_KEY
global_settings.SECRET_KEY = 'SUPER_SAFE_TESTING_KEY'

settings.configure(default_settings=global_settings)
from graphite.settings import *  # noqa

# support testing with mysql & postgres via tox
if os.environ.get('TEST_MYSQL'):
    DATABASES = {
        'default': {
            'NAME': 'graphite',
            'ENGINE': 'django.db.backends.mysql',
            'USER': os.environ.get('TEST_MYSQL_USER') or 'graphite',
            'PASSWORD': os.environ.get('TEST_MYSQL_PASSWORD') or '',
            'HOST': os.environ.get('TEST_MYSQL_HOST') or 'localhost',
            'PORT': os.environ.get('TEST_MYSQL_PORT') or '3306',
            'TEST': {
                'NAME': os.environ.get('TEST_MYSQL_NAME') or 'test_graphite',
            },
        },
    }
elif os.environ.get('TEST_POSTGRESQL'):
    DATABASES = {
        'default': {
            'NAME': 'graphite',
            'ENGINE': 'django.db.backends.postgresql',
            'USER': os.environ.get('TEST_POSTGRESQL_USER') or 'graphite',
            'PASSWORD': os.environ.get('TEST_POSTGRESQL_PASSWORD') or '',
            'HOST': os.environ.get('TEST_POSTGRESQL_HOST') or 'localhost',
            'PORT': os.environ.get('TEST_POSTGRESQL_PORT') or '5432',
            'TEST': {
                'NAME': os.environ.get('TEST_POSTGRESQL_NAME') or 'test_graphite',
            },
        },
    }

TAGDB_REDIS_HOST = os.environ.get('TEST_REDIS_HOST') or 'localhost'
TAGDB_REDIS_PORT = os.environ.get('TEST_REDIS_PORT') or 6379

if VERSION < (1, 6):
    TEST_RUNNER = 'discover_runner.DiscoverRunner'

CACHES = {
    'default': {
        'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
    },
}

# Temporary directories


def atexit_tmpremover(dirname):
    """ Utility to remove a temporary directory during program exit. """
    try:
        shutil.rmtree(dirname)
        print("Removed temporary directory: %s" % dirname)
    except OSError:
        # if the temp dir was removed already by other means
        pass


# create a temporary directory
TEMP_GRAPHITE_DIR = tempfile.mkdtemp(prefix='graphite-test-')
atexit.register(atexit_tmpremover, TEMP_GRAPHITE_DIR)

LOG_DIR = os.path.join(TEMP_GRAPHITE_DIR, 'log')
os.mkdir(LOG_DIR)

WHISPER_DIR = os.path.join(TEMP_GRAPHITE_DIR, 'whisper/')
os.mkdir(WHISPER_DIR)

# Manually add WHISPER_DIR to STANDARD_DIRS
# STANDARD_DIRS is generated programmatically in settings.py, the modification of
# WHISPER_DIR above does not change the value in STANDARD_DIRS.
STANDARD_DIRS = [WHISPER_DIR]

INDEX_FILE = os.path.join(TEMP_GRAPHITE_DIR, 'index')

URL_PREFIX = '/graphite'