Ejemplo n.º 1
0
from pathlib import Path

from bedrock.base.config_manager import config


# ROOT path of the project. A pathlib.Path object.
ROOT_PATH = Path(__file__).resolve().parents[2]
ROOT = str(ROOT_PATH)


def path(*args):
    return abspath(str(ROOT_PATH.joinpath(*args)))


# Is this a dev instance?
DEV = config('DEV', parser=bool, default='false')
PROD = config('PROD', parser=bool, default='false')

DEBUG = config('DEBUG', parser=bool, default='false')

DATABASES = {
    'default': dj_database_url.parse('sqlite:///bedrock.db'),
}

CACHES = config(
    'CACHES',
    parser=json.loads,
    default=json.dumps(
        {'default': {
            'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
            'LOCATION': 'translations'}}))
Ejemplo n.º 2
0
# add bedrock to path
sys.path.append(ROOT)

# must import after adding bedrock to path
from bedrock.base.config_manager import config  # noqa

# these are the defaults, but explicit is better
JOB_DEFAULTS = {
    "coalesce": True,
    "max_instances": 1,
}
schedule = BlockingScheduler(job_defaults=JOB_DEFAULTS)

HOSTNAME = platform.node()
DB_UPDATE_MINUTES = config("DB_UPDATE_MINUTES", default="5", parser=int)
LOCAL_DB_UPDATE = config("LOCAL_DB_UPDATE", default="False", parser=bool)
DB_DOWNLOAD_IGNORE_GIT = config("DB_DOWNLOAD_IGNORE_GIT",
                                default="False",
                                parser=bool)
RUN_TIMES = {}

# Dead Man's Snitch
DEAD_MANS_SNITCH_URL = config("DEAD_MANS_SNITCH_URL", default="")

MANAGE = str(ROOT_PATH / "manage.py")
HEALTH_FILE_BASE = f"{DATA_PATH}/last-run"

# The jobs are run every five minutes, so should all normally complete within that
# timeframe. If they don't (eg, they've hung), we set a timeout just before then,
# so that they are killed and we will try again.
Ejemplo n.º 3
0
ROOT = str(ROOT_PATH)

# add bedrock to path
sys.path.append(ROOT)

# must import after adding bedrock to path
from bedrock.base.config_manager import config  # noqa

# these are the defaults, but explicit is better
JOB_DEFAULTS = {
    'coalesce': True,
    'max_instances': 1,
}
schedule = BlockingScheduler(job_defaults=JOB_DEFAULTS)

DB_UPDATE_MINUTES = config('DB_UPDATE_MINUTES', default='5', parser=int)
LOCAL_DB_UPDATE = config('LOCAL_DB_UPDATE', default='False', parser=bool)
DB_DOWNLOAD_IGNORE_GIT = config('DB_DOWNLOAD_IGNORE_GIT', default='False', parser=bool)
RUN_TIMES = {}

# Dead Man's Snitch
DEAD_MANS_SNITCH_URL = config('DEAD_MANS_SNITCH_URL', default='')

MANAGE = str(ROOT_PATH / 'manage.py')
HEALTH_FILE_BASE = '/tmp/last-run'


def set_updated_time(name):
    check_call('touch {}-{}'.format(HEALTH_FILE_BASE, name), shell=True)

Ejemplo n.º 4
0
import socket
import struct
import sys
from os.path import abspath

from django.utils.functional import lazy

import sentry_sdk
from everett.manager import ListOf
from pathlib import Path
from sentry_sdk.integrations.django import DjangoIntegration

from bedrock.base.config_manager import config

# ROOT path of the project. A pathlib.Path object.
DATA_PATH = config('DATA_PATH', default='data')
ROOT_PATH = Path(__file__).resolve().parents[2]
DATA_PATH = ROOT_PATH / DATA_PATH
ROOT = str(ROOT_PATH)


def path(*args):
    return abspath(str(ROOT_PATH.joinpath(*args)))


def data_path(*args):
    return abspath(str(DATA_PATH.joinpath(*args)))


# Is this a dev instance?
DEV = config('DEV', parser=bool, default='false')
Ejemplo n.º 5
0
# add bedrock to path
sys.path.append(ROOT)

# must import after adding bedrock to path
from bedrock.base.config_manager import config  # noqa

# these are the defaults, but explicit is better
JOB_DEFAULTS = {
    'coalesce': True,
    'max_instances': 1,
}
schedule = BlockingScheduler(job_defaults=JOB_DEFAULTS)

HOSTNAME = platform.node()
DB_UPDATE_MINUTES = config('DB_UPDATE_MINUTES', default='5', parser=int)
LOCAL_DB_UPDATE = config('LOCAL_DB_UPDATE', default='False', parser=bool)
DB_DOWNLOAD_IGNORE_GIT = config('DB_DOWNLOAD_IGNORE_GIT',
                                default='False',
                                parser=bool)
RUN_TIMES = {}

# Dead Man's Snitch
DEAD_MANS_SNITCH_URL = config('DEAD_MANS_SNITCH_URL', default='')

MANAGE = str(ROOT_PATH / 'manage.py')
HEALTH_FILE_BASE = '/tmp/last-run'


def set_updated_time(name):
    check_call('touch {}-{}'.format(HEALTH_FILE_BASE, name), shell=True)
Ejemplo n.º 6
0
from pathlib2 import Path

from bedrock.base.config_manager import config


# ROOT path of the project. A pathlib.Path object.
ROOT_PATH = Path(__file__).resolve().parents[2]
ROOT = str(ROOT_PATH)


def path(*args):
    return abspath(str(ROOT_PATH.joinpath(*args)))


# Is this a dev instance?
DEV = config('DEV', parser=bool, default='false')
PROD = config('PROD', parser=bool, default='false')

DEBUG = config('DEBUG', parser=bool, default='false')

DATABASES = {
    'default': dj_database_url.parse('sqlite:///bedrock.db'),
}

CACHES = config(
    'CACHES',
    parser=json.loads,
    default=json.dumps(
        {'default': {
            'BACKEND': 'django.core.cache.backends.locmem.LocMemCache',
            'LOCATION': 'translations'}}))
Ejemplo n.º 7
0
# flake8: noqa
import os

from bedrock.base.config_manager import config


try:
    import newrelic.agent
except ImportError:
    newrelic = False


if newrelic:
    newrelic_ini = config('NEWRELIC_PYTHON_INI_FILE', default='')
    if newrelic_ini:
        newrelic.agent.initialize(newrelic_ini)
    else:
        newrelic = False

IS_HTTPS = os.environ.get('HTTPS', '').strip() == 'on'
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bedrock.settings')

# must be imported after env var is set above.
from django.core.handlers.wsgi import WSGIRequest
from django.core.wsgi import get_wsgi_application

from whitenoise.django import DjangoWhiteNoise
from raven.contrib.django.raven_compat.middleware.wsgi import Sentry


class WSGIHTTPSRequest(WSGIRequest):
Ejemplo n.º 8
0
# flake8: noqa
import os

from bedrock.base.config_manager import config

try:
    import newrelic.agent
except ImportError:
    newrelic = False

if newrelic:
    newrelic_ini = config('NEWRELIC_PYTHON_INI_FILE', default='')
    if newrelic_ini:
        newrelic.agent.initialize(newrelic_ini)
    else:
        newrelic = False

IS_HTTPS = os.environ.get('HTTPS', '').strip() == 'on'
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'bedrock.settings')

# must be imported after env var is set above.
from django.core.handlers.wsgi import WSGIRequest
from django.core.wsgi import get_wsgi_application

from whitenoise.django import DjangoWhiteNoise
from raven.contrib.django.raven_compat.middleware.wsgi import Sentry


class WSGIHTTPSRequest(WSGIRequest):
    def _get_scheme(self):
        if IS_HTTPS: