當前位置: 首頁>>代碼示例>>Python>>正文


Python Config.from_pyfile方法代碼示例

本文整理匯總了Python中flask.config.Config.from_pyfile方法的典型用法代碼示例。如果您正苦於以下問題:Python Config.from_pyfile方法的具體用法?Python Config.from_pyfile怎麽用?Python Config.from_pyfile使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在flask.config.Config的用法示例。


在下文中一共展示了Config.from_pyfile方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: from flask.config import Config [as 別名]
# 或者: from flask.config.Config import from_pyfile [as 別名]
    def __init__(self, settings=None):
        
        self.settings = settings
        
        log_cfg = Config('')

        log_cfg.from_pyfile( settings['LOGGING_CONFIG'])        
        
        self.log = logging_factory.get_logger(settings['APP_NAME'], settings['LOGGING_PATH'], log_cfg['LOGGING'])
        
        self.dbattr_dict = {'ORA':'ora_db','PG':'pg_db', 'DB':'db'}
        
        self.name_dict = {'ORA':'oracle','PG':'postgresql', 'DB':'oracle'}
        
        #import dbsession after logger initialized
        from mabolab.database import dbfactory
        
        for db_type in settings['DB_TYPE']:       

            if not hasattr(self, self.dbattr_dict[db_type]):
                #self.log.debug("set %s" %(db_type) )
                setattr(self, self.dbattr_dict[db_type], dbfactory.get_db(self.name_dict[db_type], settings) )
        
        if not hasattr(self, 'db'):
            setattr(self, 'db', dbfactory.get_db(self.name_dict['DB'], settings) )
開發者ID:mabotech,項目名稱:maboss.py,代碼行數:27,代碼來源:base.py

示例2: cli

# 需要導入模塊: from flask.config import Config [as 別名]
# 或者: from flask.config.Config import from_pyfile [as 別名]
def cli(ctx):
    '''
    Access and modify data from a PISS server on the command line.
    '''
    current_dir = os.path.dirname(os.path.realpath(__file__))
    config_file = os.path.splitext(os.path.basename(__file__))[0] + ".cfg"

    ctx.obj = {}
    ctx.obj['current_dir'] = current_dir
    ctx.obj['config_file'] = config_file

    if ctx.args[0] != 'register':
        if not os.path.isfile(os.path.join(current_dir, config_file)):
            click.echo('No configuration file found! Use `register <url>`  to\
 create one!')
            ctx.abort()

        try:
            app_config = Config(current_dir)
            app_config.from_pyfile(config_file)
        except Exception as e:
            click.echo('Could not load config from file. Use `register <url>`\
 to create a new one!')
            ctx.abort()

        try:
            ctx.obj['credentials'] = app_config['CREDENTIALS']
            ctx.obj['meta_url'] = app_config['META_URL']
            meta_post = app_config['META_POST']
            ctx.obj['meta_post'] = meta_post
            ctx.obj['url'] = meta_post['server']['urls']['posts_feed']
        except Exception as e:
            click.echo('Parameters missing from configuration file! Use\
 `register <url>` to fix!')
            ctx.abort()
開發者ID:dephraser,項目名稱:piss,代碼行數:37,代碼來源:piss_cli.py

示例3: setUp

# 需要導入模塊: from flask.config import Config [as 別名]
# 或者: from flask.config.Config import from_pyfile [as 別名]
    def setUp(self):
    
        tmp = '../config/logging_config.py'
        
        
        log_cfg = Config('')

        log_cfg.from_pyfile(tmp)    
       
        self.logging_cfg = log_cfg['LOGGING']        
開發者ID:mabotech,項目名稱:mabopy,代碼行數:12,代碼來源:test_logging.py

示例4: load

# 需要導入模塊: from flask.config import Config [as 別名]
# 或者: from flask.config.Config import from_pyfile [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

示例5: configs

# 需要導入模塊: from flask.config import Config [as 別名]
# 或者: from flask.config.Config import from_pyfile [as 別名]
    def configs(self):
        if not hasattr(self, '_configs'):
            configs = Config(ROOT)
            resoure = ResourceLoader.get().get_resoure('settings.py')
            config_files = resoure.as_list()
            if config_files:
                for path in config_files:
                    configs.from_pyfile(path)
            else:
                raise Exception('need a configuration file to start app')

            self._configs = configs
        return self._configs
開發者ID:IamFive,項目名稱:vclassifieds,代碼行數:15,代碼來源:env.py

示例6: download_users

# 需要導入模塊: from flask.config import Config [as 別名]
# 或者: from flask.config.Config import from_pyfile [as 別名]
def download_users():
    """
    Download users.xml file.
    """
    import urllib2
    from flask.config import Config
    config = Config(etc())
    config.from_pyfile("deploy.cfg")
    response = urllib2.urlopen(config['USERS_URL'])
    users_xml = os.path.join('runtime', 'data', 'users.xml')
    if response.code == 200:
        with open(users_xml, 'w') as f:
            f.write(response.read())
開發者ID:stxnext-kindergarten,項目名稱:presence-analyzer-mslowinski,代碼行數:15,代碼來源:script.py

示例7: make_config

# 需要導入模塊: from flask.config import Config [as 別名]
# 或者: from flask.config.Config import from_pyfile [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

示例8: __init__

# 需要導入模塊: from flask.config import Config [as 別名]
# 或者: from flask.config.Config import from_pyfile [as 別名]
 def __init__(self, debug=False):
     self.valid = True
     # loggerを初期化する
     logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s')
     logger = logging.getLogger(self.service_name)
     logger.setLevel(logging.DEBUG)
     self.logger = logger
     # 設定ファイルからAPIkeyとかを読み込む
     current_dir = os.path.dirname(__file__)
     config = Config('../../')
     if os.path.exists(activate_this):
         config.from_pyfile("wsgi_dev.cfg")
     else:
         config.from_pyfile("dev.cfg")
     #self.logger.debug(config)
     self.validate(self.require_config, config['EXTERNAL_CONFIG'])
     self.config = config['EXTERNAL_CONFIG']
     self.debug = config['POST_DEBUG']
開發者ID:yuiseki,項目名稱:python_postutil,代碼行數:20,代碼來源:postutil.py

示例9: test_settings_abs_path

# 需要導入模塊: from flask.config import Config [as 別名]
# 或者: from flask.config.Config import from_pyfile [as 別名]
    def test_settings_abs_path(self):
        """Check if the config obj is updated with default_settings when it is 
        passed as a python file absolute path
        """
        abs_path = getcwd() + '/arachne/tests/test_settings.py'
        test_app = self.create_app(settings=abs_path)

        # load config from pyfile
        flask_app = Flask(__name__)
        flask_app.config.from_object('arachne.default_settings')

        config_cls = Config(__name__)
        config_cls.from_pyfile(abs_path)

        # update config with the arachne default settings
        flask_app.config.update(config_cls)

        # test if config dicts are same
        self.assertEquals(test_app.config, flask_app.config)
開發者ID:bjzt10161,項目名稱:arachne,代碼行數:21,代碼來源:test_flaskapp.py

示例10: test_settings_abs_path

# 需要導入模塊: from flask.config import Config [as 別名]
# 或者: from flask.config.Config import from_pyfile [as 別名]
    def test_settings_abs_path(self):
        """Check if the config obj is updated with default_settings when it is 
        passed as a python file absolute path
        """
        abs_path = getcwd() + '/arachne/tests/test_settings.py'
        test_app = self.create_app(settings=abs_path)

        # since the object initialized created is always different
        # we ignore CRAWLER_PROCESS setting for test
        if SCRAPY_VERSION >= (1, 0, 0):
            del test_app.config['CRAWLER_PROCESS']

        # load config from pyfile
        flask_app = Flask(__name__)
        flask_app.config.from_object('arachne.default_settings')

        config_cls = Config(__name__)
        config_cls.from_pyfile(abs_path)

        # update config with the arachne default settings
        flask_app.config.update(config_cls)

        # test if config dicts are same
        self.assertEquals(test_app.config, flask_app.config)
開發者ID:JallyHe,項目名稱:arachne,代碼行數:26,代碼來源:test_flaskapp.py

示例11: config_to_dict

# 需要導入模塊: from flask.config import Config [as 別名]
# 或者: from flask.config.Config import from_pyfile [as 別名]
def config_to_dict(root_path, config_file):
    config = FlaskConfig(root_path)
    config.from_pyfile(config_file)
    return dict((k, v) for k, v in config.iteritems())
開發者ID:iter8ve,項目名稱:pygreen,代碼行數:6,代碼來源:pygreen.py

示例12: Config

# 需要導入模塊: from flask.config import Config [as 別名]
# 或者: from flask.config.Config import from_pyfile [as 別名]

from datetime import datetime

from sqlalchemy import String, Integer
from sqlalchemy.sql.expression import text , bindparam, outparam

from mabolab.core.base import Base



from flask.config import Config

settings = Config("" )

settings.from_pyfile( 'C:/MTP/mabotech/maboss1.2/maboss/configuration/central_config.py')

settings['APP_NAME'] = "next_seq"

base = Base( settings)


db = base.get_db("oracle") 


def get_next_seq():
    """ call stored procedure """
    
    sql = """BP_SP_GETNEXTCERTNO (:I_FACILITY, :O_CertNo, :O_Message )"""

    #bind parameters and set out parameters
開發者ID:mabotech,項目名稱:maboss.py,代碼行數:32,代碼來源:next_seq.py

示例13: Config

# 需要導入模塊: from flask.config import Config [as 別名]
# 或者: from flask.config.Config import from_pyfile [as 別名]

from flask.config import Config

from mabolab.core.global_obj import Global

CENTRAL_CONFIG = 'C:/MTP/mabotech/maboss1.3.0/maboss/conf/maboss_config.py'

settings = Config("")

settings.from_pyfile(CENTRAL_CONFIG)

settings['APP_NAME'] = "monitor_bli"

g = Global(settings)

db = g.get_db('postgresql')

ora = g.get_db('oracle')

log = g.get_logger()



def dbtest(serialno):
    
    sql = """select status, lastupdateon from cob_t_serial_no_workstation 
where serialno = '%s'  and workstation = '42700' 
order by id desc""" % (serialno)

    rtn = ora.execute(sql)
開發者ID:mabotech,項目名稱:mabo.io,代碼行數:32,代碼來源:oracle_connection_test.py

示例14: Config

# 需要導入模塊: from flask.config import Config [as 別名]
# 或者: from flask.config.Config import from_pyfile [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):
開發者ID:msupino,項目名稱:alerta-contrib,代碼行數:31,代碼來源:alerta_sqs.py

示例15: Config

# 需要導入模塊: from flask.config import Config [as 別名]
# 或者: from flask.config.Config import from_pyfile [as 別名]

from flask.config import Config


py = 'config.py'

root_path = ""

setting = Config(root_path)

setting.from_pyfile(py)

print setting['LOGGING']

print setting['PG_URL']

print setting['ORA_URL']
開發者ID:mabotech,項目名稱:maboss.py,代碼行數:19,代碼來源:settings.py


注:本文中的flask.config.Config.from_pyfile方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。