本文整理汇总了Python中environ.Env.read_env方法的典型用法代码示例。如果您正苦于以下问题:Python Env.read_env方法的具体用法?Python Env.read_env怎么用?Python Env.read_env使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类environ.Env
的用法示例。
在下文中一共展示了Env.read_env方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: FileEnvTests
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import read_env [as 别名]
class FileEnvTests(EnvTests):
def setUp(self):
self.env = Env()
self._orig_environ = os.environ
os.environ = {}
file_path = Path(__file__, is_file=True)('test_env.txt')
self.env.read_env(file_path, PATH_VAR=Path(__file__, is_file=True).__root__)
示例2: dirname
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import read_env [as 别名]
REPO_PATH = dirname(PROJECT_PATH)
REPO_NAME = "op-accesso" or basename(REPO_PATH)
CONFIG_DIR = 'config'
CONFIG_PATH = join(REPO_PATH, CONFIG_DIR)
RESOURCE_DIR = 'resources'
RESOURCES_PATH = join(REPO_PATH, RESOURCE_DIR)
# Add our project to our pythonpath, this way we don't need to type our project
# name in our dotted import paths:
path.append(PROJECT_PATH)
# load environment variables
Env.read_env(normpath(join(CONFIG_PATH, '.env')))
env = Env()
########## END PATH CONFIGURATION
########## DEBUG CONFIGURATION
# See: https://docs.djangoproject.com/en/dev/ref/settings/#debug
DEBUG = env.bool('DEBUG', False)
# See: https://docs.djangoproject.com/en/dev/ref/settings/#template-debug
TEMPLATE_DEBUG = DEBUG
########## END DEBUG CONFIGURATION
########## MANAGER CONFIGURATION
ADMIN_EMAIL = env.str('ADMIN_EMAIL', '[email protected]%s.com' % PROJECT_NAME)
示例3: Env
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import read_env [as 别名]
import os
from environ import Env
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
assert os.path.isfile(os.path.join(BASE_DIR, 'manage.py'))
env = Env()
env.read_env(os.path.join(BASE_DIR, '.env'))
DEBUG = env.bool('DEBUG', default=False)
SECRET_KEY = env.str('SECRET_KEY', default=('' if not DEBUG else 'xxx'))
DATABASES = {
'default': env.db_url(
default='psql://tallessa:[email protected]/tallessa',
),
}
CACHES = {'default': env.cache_url(default='locmemcache://')}
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'rest_framework',
示例4: Env
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import read_env [as 别名]
# Django settings for project project.
import os
from environ import Env, Path
import pathlib
from django.core.exceptions import ImproperlyConfigured
DEBUG = False
PROJECT_ROOT = pathlib.Path(__file__).parent.parent.parent
PROJECT_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
BASE_DIR = os.path.dirname(PROJECT_DIR)
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
env = Env(DEBUG=(bool, False),)
Env.read_env('.env')
DEBUG = env('DEBUG')
ADMINS = (
('Greg Azevedo', '[email protected]'),
)
MANAGERS = ADMINS
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'UTC'
示例5: dirname
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import read_env [as 别名]
PROJECT_PATH = REPO_PATH = dirname(PACKAGE_PATH)
RESOURCE_DIR = 'resources'
RESOURCES_PATH = join(REPO_PATH, RESOURCE_DIR)
LOG_PATH = join(RESOURCES_PATH,'logs')
FIXTURES_DIR = 'fixtures'
FIXTURES_PATH = join(REPO_PATH, FIXTURES_DIR)
# Add our project to our pythonpath, this way we don't need to type our project
# name in our dotted import paths:
path.append(PROJECT_PATH)
# load environment variables
Env.read_env(normpath(join(REPO_PATH, '.env')))
env = Env()
######### END PATH CONFIGURATION
########## OPEN_RICOSTRUZIONE CONFIGURATION
DEBUG = env.bool('DEBUG', False)
TEMPLATE_DEBUG = env.bool('TEMPLATE_DEBUG', False)
INSTANCE_TYPE = env.str('INSTANCE_TYPE', '')
ADMINS = (
('Guglielmo Celata', '[email protected]'),
)
MANAGERS = ADMINS
DATABASES = {
示例6: env
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import read_env [as 别名]
EMAIL_HOST=(str, 'localhost'),
EMAIL_PORT=(int, 25),
EMAIL_USE_TLS=(bool, False),
EMBEDLY_KEY=(str, None),
MEDIA_ROOT=(str, os.path.join(BASE_DIR, 'media')),
DBBACKUP_AWS_ACCESS_KEY=(str, None),
DBBACKUP_AWS_SECRET_KEY=(str, None),
DBBACKUP_S3_BUCKET_NAME=(str, None),
)
# read from a local, unversioned dev environment file if it exists
local_env_file = os.path.join(PROJECT_DIR, '.env.local')
Env.read_env(
env_file=local_env_file if os.path.isfile(local_env_file) else None
)
DEBUG = env('DEBUG')
SECRET_KEY = env('SECRET_KEY')
ALLOWED_HOSTS = env('ALLOWED_HOSTS')
# make Django log to stderr
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'console': {
'class': 'logging.StreamHandler',
示例7: Env
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import read_env [as 别名]
Generated by 'django-admin startproject' using Django 1.10.5.
For more information on this file, see
https://docs.djangoproject.com/en/1.10/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.10/ref/settings/
"""
import os
from environ import Env
env_file = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'settings.env')
Env.read_env(env_file)
env = Env(DEBUG=(bool, False), )
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.10/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = env('SECRET_KEY')
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
示例8: Env
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import read_env [as 别名]
import os
from environ import Env
env = Env()
HOME_DIR = env.str(
"HOME_DIR",
default=os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
)
env.read_env(os.path.join(HOME_DIR, ".env"))
DEBUG = env.bool("DEBUG", False)
SECRET_KEY = env.bool("SECRET_KEY", "Sehr lecker Wurst" if DEBUG else Env.NOTSET)
ALLOWED_HOSTS = env.list("ALLOWED_HOSTS", default=["*"])
DATABASES = {
"default": env.db_url(default="sqlite:///%s" % os.path.join(HOME_DIR, "wurst.sqlite3"))
}
STATIC_ROOT = env.str("STATIC_ROOT", default=os.path.join(HOME_DIR, "static"))
MEDIA_ROOT = env.str("MEDIA_ROOT", default=os.path.join(HOME_DIR, "media"))
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'reversion',
'rest_framework',
'rest_framework.authtoken',
'wurst.core',
示例9: Path
# 需要导入模块: from environ import Env [as 别名]
# 或者: from environ.Env import read_env [as 别名]
from environ import Env, Path
root = Path(__file__) - 2 # two folders up
BASE_DIR = root()
# set default values and casting
env = Env(
DEBUG=(bool, False),
)
Env.read_env()
DEBUG = env('DEBUG')
SECRET_KEY = env('SECRET_KEY')
ALLOWED_HOSTS = [
'.nova.jobs'
]
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'compressor',
#'core',
#'signup',
#'scheduler',
#'review',
'homepage',