当前位置: 首页>>代码示例>>Python>>正文


Python Env.read_env方法代码示例

本文整理汇总了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__)
开发者ID:AliLozano,项目名称:django-environ,代码行数:10,代码来源:test.py

示例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)
开发者ID:openpolis,项目名称:op-accesso,代码行数:32,代码来源:base.py

示例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',
开发者ID:tallessa,项目名称:tallessa-backend,代码行数:33,代码来源:settings.py

示例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'
开发者ID:gregazevedo,项目名称:gregazevedo,代码行数:32,代码来源:base.py

示例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 = {
开发者ID:DeppSRL,项目名称:open_ricostruzione,代码行数:33,代码来源:base.py

示例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',
开发者ID:CharleyFarley,项目名称:localore,代码行数:33,代码来源:settings.py

示例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
开发者ID:fanzalika,项目名称:openreceipts-server,代码行数:31,代码来源:settings.py

示例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',
开发者ID:japsu,项目名称:wurst,代码行数:33,代码来源:settings.py

示例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',
开发者ID:ghostwords,项目名称:nova,代码行数:33,代码来源:settings.py


注:本文中的environ.Env.read_env方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。