def strtobool(value): return bool(_strtobool(str(value)))
def strtobool(value): try: return bool(_strtobool(value)) except ValueError: return False
def strtobool(val: str, default: bool = False) -> bool: try: return _strtobool(val) except (AttributeError, ValueError): return default
def strtobool(x): return x if isinstance(x, bool) else bool(_strtobool(x))
def strtobool(value): try: return bool(_strtobool(value)) except ValueError: return False
EMAIL_BACKEND = 'django.core.mail.backends.locmem.EmailBackend' EMAIL_SUBJECT_PREFIX = '[Django Template CI] ' SERVER_EMAIL = '*****@*****.**' # ---------------------------------------------------------------------------------------------------------------------- # Custom Project Configuration DATA_IMPORT_DIR = _Path(PROJECT_DIR, 'data_imports') DATA_PROCESSING_DIR = _Path(PROJECT_DIR, 'data') DATA_ERROR_LOGS_DIR = _Path(PROJECT_DIR, 'import_errors') # ---------------------------------------------------------------------------------------------------------------------- # Turn on sql logging; useful if you can't figure out why test cases are failing if _strtobool(get_env_setting('DEBUG_SQL', '0')): # Beware of unexpected side-effects of DEBUG!! # SQL logging is hardcoded to only log if DEBUG is turned on; # There's no way of turning on DEBUG just for SQL logging DEBUG = True DEBUG_WEBPACK = False print("Enabling SQL dump (pid %d)\n" % _os.getpid(), file=_sys.stderr) LOGGING['loggers']['django.db.backends']['handlers'].append('console') # ---------------------------------------------------------------------------------------------------------------------- print("Loaded CI config (pid %d)\n" % _os.getpid(), file=_sys.stderr) # This must be set for env to work # assert(get_env_setting('MOCK_DATE_START', '') != '')
""" from distutils.util import strtobool as _strtobool import hashlib as _hashlib import logging as _logging from pathlib import Path import random as _random import re as _re import sys as _sys import warnings as _warnings from .base import * # ---------------------------------------------------------------------------------------------------------------------- # Core Site configuration DEBUG = _strtobool(get_env_setting("DEBUG", "1")) DEBUG_WEBPACK = True AUTOMATED_TESTS = True ALLOWED_HOSTS += [ "127.0.0.1", "localhost", ] # WSGI_APPLICATION = None INTERNAL_IPS = [ "127.0.0.1", ] # Add this to your base template to alter styling based on the environment
def strtobool(x): return x if isinstance(x, bool) else bool(_strtobool(x))
def strtobool(value): return bool(_strtobool(str(value)))
def strtobool(x): """wraps `distutils.util.strtobool` that casts 'yes', 'no', '1', '0', 'true', 'false', etc to boolean values, but only if the given value isn't already a boolean""" return x if isinstance(x, bool) else bool(_strtobool(str(x)))
'127.0.0.1', ] # Add this to your base template to alter styling based on the environment # (eg change background colour depending on whether prod/stage/dev) BODY_ENV_CLASS = 'env-dev' # ---------------------------------------------------------------------------------------------------------------------- # Application definition INSTALLED_APPS += ( # 'ui_patterns', ) # "DEBUG_TOOLBAR=0 ./manage.py runserver" to run server w/ django debug toolbar off. if _strtobool(get_env_setting('DEBUG_TOOLBAR', '1')): INSTALLED_APPS += ('debug_toolbar', ) MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware', ) DEBUG_TOOLBAR_CONFIG = { 'SKIP_TEMPLATE_PREFIXES': ( 'django/forms/widgets/', 'admin/widgets/', 'floppyforms/', # needed to avoid infinite loops ), } # ---------------------------------------------------------------------------------------------------------------------- # Template configuration if DEBUG: for _tpl in TEMPLATES:
def __bool__(self): return bool(_strtobool(self))
LOGGING["loggers"]["werkzeug"]["level"] = "WARNING" # ---------------------------------------------------------------------------------------------------------------------- # Email Configuration EMAIL_BACKEND = "django.core.mail.backends.locmem.EmailBackend" EMAIL_SUBJECT_PREFIX = "[Django Template CI] " SERVER_EMAIL = "*****@*****.**" # ---------------------------------------------------------------------------------------------------------------------- # Turn on sql logging; useful if you can't figure out why test cases are failing if _strtobool(get_env_setting("DEBUG_SQL", "0")): # Beware of unexpected side-effects of DEBUG!! # SQL logging is hardcoded to only log if DEBUG is turned on; # There's no way of turning on DEBUG just for SQL logging DEBUG = True DEBUG_WEBPACK = False print("Enabling SQL dump (pid %d)\n" % _os.getpid(), file=_sys.stderr) LOGGING["loggers"]["django.db.backends"]["handlers"].append("console") # ---------------------------------------------------------------------------------------------------------------------- print("Loaded CI config (pid %d)\n" % _os.getpid(), file=_sys.stderr) # This must be set for env to work # assert(get_env_setting('MOCK_DATE_START', '') != '')
# ---------------------------------------------------------------------------------------------------------------------- # Core Site configuration ALLOWED_HOSTS = [ # 'www.mysite.com', 'circle.its.unimelb.edu.au', ] BODY_ENV_CLASS = 'env-prod' # Force HTTPS SECURE_SSL_REDIRECT = True SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https') # Only use HTTPS for various cookies SESSION_COOKIE_SECURE = True CSRF_COOKIE_SECURE = True ADMINS = [(email, email) for email in get_env_setting('ADMINS').split(',')] # ---------------------------------------------------------------------------------------------------------------------- # Custom Project Configuration DATA_IMPORT_DIR = _Path(get_env_setting('DATA_IMPORT_DIR')) DATA_PROCESSING_DIR = _Path(get_env_setting('DATA_PROCESSING_DIR')) DATA_ERROR_LOGS_DIR = _Path(get_env_setting('DATA_ERROR_LOGS_DIR')) # ---------------------------------------------------------------------------------------------------------------------- if not _strtobool(get_env_setting('CI_SERVER', '0')): assert len(ADMINS) > 0
from distutils.util import strtobool as _strtobool import hashlib as _hashlib import os as _os from pathlib import Path as _Path import random as _random import re as _re import warnings as _warnings is_ci = _os.environ.get('CI_SERVER', 'no') == 'yes' BASE_DIR = _Path(__file__).parent # Select DB engine if _strtobool(_os.environ.get('TOX', '0')): # look for the DB name in one of the tox environment name components _engine = [ _e for _e in ('postgresql', 'mysql') if _e in str(_Path(_os.environ['VIRTUAL_ENV']).name).split('-') ] assert _engine _engine = f'django.db.backends.{_engine[0]}' elif _os.environ.get('PGDATABASE'): _engine = 'django.db.backends.postgresql' else: _engine = 'django.db.backends.mysql' # DB default settings _db_vars = { 'NAME': ('DB_NAME', 'alliance_django_utils'), 'HOST': ('DB_HOST', 'localhost'),