當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。