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


Python Config.from_envvar方法代码示例

本文整理汇总了Python中flask.config.Config.from_envvar方法的典型用法代码示例。如果您正苦于以下问题:Python Config.from_envvar方法的具体用法?Python Config.from_envvar怎么用?Python Config.from_envvar使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在flask.config.Config的用法示例。


在下文中一共展示了Config.from_envvar方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: load_config

# 需要导入模块: from flask.config import Config [as 别名]
# 或者: from flask.config.Config import from_envvar [as 别名]
def load_config():
    cfg = Config(dirname(dirname(__file__)))
    cfg.from_object("autobit.settings")
    if "AUTOBIT_SETTINGS" in os.environ:
        cfg.from_envvar("AUTOBIT_SETTINGS")

    if not exists(cfg['WATCH_DIR']):
        logger.info("Creating watch dir: {}".format(cfg['WATCH_DIR']))
        os.makedirs(cfg['WATCH_DIR'])

    return cfg
开发者ID:leighmacdonald,项目名称:autobit,代码行数:13,代码来源:__init__.py

示例2: load

# 需要导入模块: from flask.config import Config [as 别名]
# 或者: from flask.config.Config import from_envvar [as 别名]
def load(config_filename='settings.py'):
    """Create a Flask config that will be used to update the application
    config when it is created."""
    config = Config("pjuu")

    # Load the default settings
    config.from_pyfile(config_filename)

    # Load the setting from the Environment variable
    config.from_envvar('PJUU_SETTINGS', silent=True)

    return config
开发者ID:pjuu,项目名称:pjuu,代码行数:14,代码来源:configurator.py

示例3: make_config

# 需要导入模块: from flask.config import Config [as 别名]
# 或者: from flask.config.Config import from_envvar [as 别名]
def make_config(app=None):
    if app is not None:
        cfg = app.config
    else:
        from flask.config import Config
        root_path = os.path.dirname(__file__).rsplit('/', 1)[0]
        cfg = Config(root_path)

    # customize config here
    cfg.from_object(default_config)
    cfg.from_pyfile('myapp.cfg', silent=True)
    cfg.from_envvar('MYAPP_CONFIG', silent=True)
    cfg['BABEL_DEFAULT_LOCALE'] = cfg['LANG']
    return cfg
开发者ID:haje01,项目名称:flask-plate,代码行数:16,代码来源:make_config.py

示例4: make_config

# 需要导入模块: from flask.config import Config [as 别名]
# 或者: from flask.config.Config import from_envvar [as 别名]
def make_config():
    cfg = Config('')
    cfg.from_object('datacat.settings.default')
    cfg.from_envvar('DATACAT_SETTINGS', silent=True)
    return cfg
开发者ID:rshk-archive,项目名称:datacat-poc-140825,代码行数:7,代码来源:core.py

示例5: Config

# 需要导入模块: from flask.config import Config [as 别名]
# 或者: from flask.config.Config import from_envvar [as 别名]
import os
import sys
import time
import logging

from flask.config import Config

import boto.sqs
from boto.sqs.message import RawMessage
from boto import exception

LOG = logging.getLogger('alerta.sqs')

config = Config('/')
config.from_pyfile('/etc/alertad.conf', silent=True)
config.from_envvar('ALERTA_SVR_CONF_FILE', silent=True)

DEFAULT_AWS_REGION = 'eu-west-1'
DEFAULT_AWS_SQS_QUEUE = 'alerts'

AWS_REGION = os.environ.get('AWS_REGION') or config.get('AWS_REGION', DEFAULT_AWS_REGION)
AWS_ACCESS_KEY_ID = os.environ.get('AWS_ACCESS_KEY_ID') or config.get('AWS_ACCESS_KEY_ID')
AWS_SECRET_ACCESS_KEY = os.environ.get('AWS_SECRET_ACCESS_KEY') or config.get('AWS_SECRET_ACCESS_KEY')
AWS_SQS_QUEUE = os.environ.get('AWS_SQS_QUEUE') or config.get('AWS_SQS_QUEUE', DEFAULT_AWS_SQS_QUEUE)


class Worker(object):

    def __init__(self):

        try:
开发者ID:msupino,项目名称:alerta-contrib,代码行数:33,代码来源:alerta_sqs.py

示例6: Config

# 需要导入模块: from flask.config import Config [as 别名]
# 或者: from flask.config.Config import from_envvar [as 别名]
from flask.config import Config
from celery.utils.log import get_task_logger
from ckanpackager.tasks.url_package_task import UrlPackageTask
from ckanpackager.tasks.datastore_package_task import DatastorePackageTask
from ckanpackager.tasks.dwc_archive_package_task import DwcArchivePackageTask

config = Config(__file__)
config.from_object('ckanpackager.config_defaults')
config.from_envvar('CKANPACKAGER_CONFIG')

from celery import Celery

app = Celery('tasks', broker=config['CELERY_BROKER'])
app.conf.CELERY_DISABLE_RATE_LIMITS = True
app.conf.CELERY_ACCEPT_CONTENT = ['json']
app.conf.CELERY_TASK_SERIALIZER = 'json'
app.conf.CELERY_CREATE_MISSING_QUEUES = True
app.conf.CELERY_DEFAULT_QUEUE = 'slow'


@app.task
def run_task(task, request):
    """ Run/enqueue the given task for the given request
   
    Note that the request should be validated before
    this is called.
 
    @param task: Name of the task. One of package_url,
                 package_dwc_archive or package_datastore
    @param request: Dictionary containing the request
    """
开发者ID:NaturalHistoryMuseum,项目名称:ckanpackager,代码行数:33,代码来源:task_setup.py


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