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


Python Config.get方法代码示例

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


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

示例1: device_manager

# 需要导入模块: from config.config import Config [as 别名]
# 或者: from config.config.Config import get [as 别名]
def device_manager(context):

    global manager
    global publisher

    worker_address = Config.get('services', 'worker_address')
    worker_port = Config.get('services', 'worker_port')
    worker_address = "tcp://" + worker_address + ":" + worker_port

    publisher_address = Config.get('device_service', 'publisher_address')
    publisher_port = Config.get('device_service', 'publisher_port')
    publisher_address = "tcp://" + publisher_address + ":" + publisher_port

    service = Config.get('device_service', 'service_name')

    publisher = DeviceServicePublisher(context, publisher_address)
    manager = DeviceServiceManager(context, worker_address, service)

    try:
        IOLoop.instance().start()
    except KeyboardInterrupt:
        IOLoop.instance().stop()
        publisher.shutdown()
        manager.shutdown()

    return
开发者ID:nstoik,项目名称:farm_monitor,代码行数:28,代码来源:manager.py

示例2: get_old_articles_for_query

# 需要导入模块: from config.config import Config [as 别名]
# 或者: from config.config.Config import get [as 别名]
def get_old_articles_for_query(query):
	"""
	Fetches items for a query that are older than the oldest item that has 
	already been fetched.
	"""
	logging.error("$$$$ nytArticles.get_old_articles_for_query[]")
	n_to_fetch = 10
	query.doc['n_fetched'] = query.doc['n_fetched'] + n_to_fetch
	n_requests = int(math.ceil(n_to_fetch / int(Config.get("nyt_article")["response_size"])))
	if n_requests == 0:
		n_requests = 1
	prior_cached = len(query.children)
	logging.error(prior_cached)
	prior_offset = int(int(prior_cached) / int(Config.get("nyt_article")["response_size"]))
	logging.error(prior_offset)
	
	req_pars = {
					'query_id': query.id(),
					'functions': [api.make_api_request,cache_response,fetch_comments]
				}
	for i in range(0,n_requests):
		request = {}
		for k,v in req_pars.iteritems():
			request[k] = v
		request['url'] = 'http://api.nytimes.com/svc/search/v1/article?query=text:'+query.doc['query_text'].replace(' ','+')+'+comments:y'
		request['url'] = request['url'] + '&offset='+str(int(prior_offset) + int(i))
		request['url'] = request['url'] + '&fields=body,byline,date,title,url,geo_facet,per_facet,des_facet,org_facet'
		request['url'] = request['url'] + '&api-key='+Config.get('nyt_article')['key']
		
		#logging.critical('BSM[get_old_articles_for_query] Size:'+str(sys.getsizeof(pickle.dumps(request))))
		with voxpop.VPE.beanstalkd_lock:
			voxpop.VPE.get_beanstalkd().use("nytarticle")
			voxpop.VPE.get_beanstalkd().put(pickle.dumps(request), pri=100000)
	query.save()
	return query
开发者ID:typecode,项目名称:voxpop,代码行数:37,代码来源:nytArticle.py

示例3: refresh_device

# 需要导入模块: from config.config import Config [as 别名]
# 或者: from config.config.Config import get [as 别名]
def refresh_device(device):
    address = Config.get('services', 'client_address')
    port = Config.get('services', 'client_port')
    address = "tcp://" + address + ":" + port

    socket = zmq.Context().socket(zmq.REQ)
    socket.setsockopt(zmq.LINGER, 0)
    socket.connect(address)

    message = ['00000000', 'control', 'refresh', device]
    mdp_request(socket, 'device', message, 1)
开发者ID:nstoik,项目名称:farm_monitor,代码行数:13,代码来源:device_web.py

示例4: fetch_comments_for_article_id

# 需要导入模块: from config.config import Config [as 别名]
# 或者: from config.config.Config import get [as 别名]
def fetch_comments_for_article_id(pars={}, **kwargs):
    if "article_id" not in pars:
        logging.error("**** nytCommunity.fetch_comments_for_article: NO ARTICLE ID PROVIDED")
        return False
    if "article_url" not in pars:
        logging.error("**** nytCommunity.fetch_comments_for_article: NO ARTICLE URL PROVIDED")
        return False
    logging.info(
        "$$$$ nytCommunity.fetch_comments_for_article_id[id:" + pars["article_id"] + ",url:" + pars["article_url"] + "]"
    )
    _url = "http://api.nytimes.com/svc/community/v2/comments/url/exact-match.json?"
    _url = _url + "url=" + urllib.quote_plus(pars["article_url"])
    _url = _url + "&sort=oldest"
    _url = _url + "&api-key=" + Config.get("nyt_community")["key"]
    request = {
        "url": _url,
        "article_id": pars["article_id"],
        "article_url": pars["article_url"],
        "functions": [api.make_api_request, fetch_remainder],
    }
    # logging.critical('BSM[fetch_comments_for_article_id] Size:'+str(sys.getsizeof(pickle.dumps(request))))
    with voxpop.VPE.beanstalkd_lock:
        voxpop.VPE.get_beanstalkd().use("nytcommunity")
        voxpop.VPE.get_beanstalkd().put(pickle.dumps(request), pri=100000)
    return True
开发者ID:typecode,项目名称:voxpop,代码行数:27,代码来源:nytCommunity.py

示例5: _build_paths

# 需要导入模块: from config.config import Config [as 别名]
# 或者: from config.config.Config import get [as 别名]
    def _build_paths(self):
        rrd_location = Config.get('rrdtool', 'location')

        self.folder_path = rrd_location + self.folder
        self.file_path = self.folder_path + self.file_name

        if not os.path.exists(self.folder_path):
            os.makedirs(self.folder_path)
开发者ID:nstoik,项目名称:farm_monitor,代码行数:10,代码来源:rrd.py

示例6: delete_device

# 需要导入模块: from config.config import Config [as 别名]
# 或者: from config.config.Config import get [as 别名]
def delete_device(device):
    address = Config.get('services', 'client_address')
    port = Config.get('services', 'client_port')
    address = "tcp://" + address + ":" + port

    socket = zmq.Context().socket(zmq.REQ)
    socket.setsockopt(zmq.LINGER, 0)
    socket.connect(address)

    message = ['00000000', 'control', 'remove', device.id]
    mdp_request(socket, 'device', message, 1)

    rrd = RRD(device.id, 'device')
    rrd.remove(remove_folder=True)

    db_session.query(Device).filter_by(id=device.id).delete()
    db_session.commit()

    return
开发者ID:nstoik,项目名称:farm_monitor,代码行数:21,代码来源:device_web.py

示例7: grainbin_manager

# 需要导入模块: from config.config import Config [as 别名]
# 或者: from config.config.Config import get [as 别名]
def grainbin_manager(context):

    global manager

    worker_address = Config.get('services', 'worker_address')
    worker_port = Config.get('services', 'worker_port')
    worker_address = "tcp://" + worker_address + ":" + worker_port

    service = Config.get('grainbin_service', 'service_name')

    manager = GrainbinServiceManager(context, worker_address, service)

    try:
        IOLoop.instance().start()
    except KeyboardInterrupt:
        IOLoop.instance().stop()
        manager.shutdown()

    return
开发者ID:nstoik,项目名称:farm_monitor,代码行数:21,代码来源:grainbin_service.py

示例8: farm_broker

# 需要导入模块: from config.config import Config [as 别名]
# 或者: from config.config.Config import get [as 别名]
def farm_broker():
    global broker

    worker_address = Config.get('broker', 'worker_address')
    worker_port = Config.get('broker', 'worker_port')
    worker_address = "tcp://" + worker_address + ":" + worker_port

    client_address = Config.get('broker', 'client_address')
    client_port = Config.get('broker', 'client_port')
    client_address = "tcp://" + client_address + ":" + client_port

    context = zmq.Context()
    broker = FarmBroker(context,
                        main_ep=worker_address,
                        opt_ep=client_address)
    try:
        IOLoop.instance().start()
    except KeyboardInterrupt:
        IOLoop.instance().stop()
        broker.shutdown()
    return
开发者ID:nstoik,项目名称:farm_monitor,代码行数:23,代码来源:farm_broker.py

示例9: get_new_articles_for_query

# 需要导入模块: from config.config import Config [as 别名]
# 或者: from config.config.Config import get [as 别名]
def get_new_articles_for_query(query):
	"""
	Fetches items for a query that are newer than the newest item that has 
	already been fetched.
	"""
	logging.error("$$$$ nytArticles.get_new_articles_for_query[]")

	for i in range(0,n_requests):
		request = {}
		for k,v in req_pars.iteritems():
			request[k] = v
		request['url'] = 'http://api.nytimes.com/svc/search/v1/article?query=text:'+query.doc['query_text'].replace(' ','+')+'+comments:y'
		request['url'] = request['url'] + '&offset='+str(prior_cached + (i * int(Config.get("nyt_article")["response_size"])))
		request['url'] = request['url'] + '&fields=body,byline,date,title,url,geo_facet,per_facet,des_facet,org_facet'
		request['url'] = request['url'] + '&api-key='+Config.get('nyt_article')['key']
		
		#logging.critical('BSM[get_new_articles_for_query] Size:'+str(sys.getsizeof(pickle.dumps(request))))
		with voxpop.VPE.beanstalkd_lock:
			voxpop.VPE.get_beanstalkd().use("nytarticle")
			voxpop.VPE.get_beanstalkd().put(pickle.dumps(request), pri=100000)
	return message
开发者ID:typecode,项目名称:voxpop,代码行数:23,代码来源:nytArticle.py

示例10: create

# 需要导入模块: from config.config import Config [as 别名]
# 或者: from config.config.Config import get [as 别名]
    def create(self, sources):
        """
        creates an rrd file
        sources is a list of data sources to add.
        Every item in the list must have a unique 'name' key
        that identifies the item
        """
        archives = Config.get('rrdtool', 'data_archives')
        data_archives = [x.strip() for x in archives.splitlines()]

        data_source = []
        for x in sources:
            if 'name' in x:
                data_source.append("DS:" + x['name'] + ":GAUGE:7200:-40:80")

        path = self.file_path
        rrdtool.create(path, "--step", '3600', data_source, data_archives)

        return
开发者ID:nstoik,项目名称:farm_monitor,代码行数:21,代码来源:rrd.py

示例11: StartpageWindow

# 需要导入模块: from config.config import Config [as 别名]
# 或者: from config.config.Config import get [as 别名]
class StartpageWindow(wx.Frame):
    """Main class of sc2mafia the start page, the create game page.
    All GUI logic is here.
    """

    def __init__(self, parent, id, title, style):
        """Construct the GUI from config file, and bind GUI events to
        their handlers.

        """
        # 读取sc2mafia.cfg
        self.readFromCfg()
        # 调用基类的构造函数
        wx.Frame.__init__(self, parent, wx.ID_ANY, title, size=self.framesize, style=style)
        # 加载资源
        # self.resin = Resin(os.path.join(homepath,
        #        'res', self.prefer.getValue("iconset")))
        self.resin = Resin()
        # 图标
        self.SetIcon(self.resin.getIcon("notalon"))
        # 提示
        self.tips = wx.CreateFileTipProvider("Tips.txt", 0)
        self.showtips = int(self.config.get("other", "showtips"))
        if self.showtips:
            wx.CallAfter(self.ShowTips)  # 显示Tips的同时显示主界面
            # self.ShowTips()  # 与上面相反,显示Tips之后才显示主界面
        # 创建MenuBar
        self.createMenuBar()
        # 创建ToolBar
        self.createToolBar()
        # 创建StatusBar
        self.createStatusBar()
        # 创建主显示栏
        self.createMainWindow()
        # 绑定关闭窗口的方法
        self.Bind(wx.EVT_CLOSE, self.OnCloseWindow)
        # 创建TaskBarIcon
        self.tbIcon = tbIcon(self)

    # -----------------创建主框架的相关函数------------------ #
    def readFromCfg(self):
        """读取配置文件

        """
        self.config = Config(os.path.join(homepath, "sc2mafia.cfg"))
        self.framesize = (int(self.config.get("frame", "width")), int(self.config.get("frame", "height")))

    def menuData(self):
        """菜单项数据

        """
        return (
            (u"程序", (u"退出", u"退出程序", self.OnCloseWindow)),
            (
                u"员工档案",
                (u"新建", u"在远程服务器新建一个员工档案", self.OnCreateStaff),
                (u"修改", u"修改一个员工档案", self.OnModifyStaff),
                (u"查看", u"查看所有员工档案", self.OnDisplayStaff),
                (u"筛选", u"筛选员工档案", self.OnFilterStaff),
            ),
            (u"工资", (u"工资单发送", "用邮件发送工资单", self.OnMailSalary)),
            (u"其他", (u"报销系统", u"在这里登录报销系统", self.OnOpenExpAccHtml)),
            (u"工具", (u"通讯录", u"快速查询通讯录的小工具", self.OnSearchAddr)),
            (
                u"帮助",
                (u"用户手册", u"用户手册", self.OnManual),
                ("", "", ""),
                (u"版权", u"本软件的版权信息", self.OnCopyRight),
                (u"关于作者", u"本软件作者的相关信息", self.OnAuthor),
                (u"关于本软件", u"本软件的相关信息", self.OnAbout),
            ),
        )

    def createMenuBar(self):
        """创建菜单栏

        """
        menuBar = wx.MenuBar()
        for eachMenuData in self.menuData():
            menuLabel = eachMenuData[0]
            menuItems = eachMenuData[1:]
            menuBar.Append(self.createMenu(menuItems), menuLabel)
            self.SetMenuBar(menuBar)

    def createMenu(self, menuData):
        """创建一个菜单 --从创建菜单栏函数中抽象出来的函数

        """
        menu = wx.Menu()
        for eachLabel, eachStatus, eachHandler in menuData:
            if not eachLabel:
                menu.AppendSeparator()
                continue
            menuItem = menu.Append(-1, eachLabel, eachStatus)
            self.Bind(wx.EVT_MENU, eachHandler, menuItem)
        return menu

    def toolBarData(self):
        """工具栏数据

#.........这里部分代码省略.........
开发者ID:cmal,项目名称:sc2mafia,代码行数:103,代码来源:window.py

示例12: test_get

# 需要导入模块: from config.config import Config [as 别名]
# 或者: from config.config.Config import get [as 别名]
def test_get():
    config = Config(config_file_master)
    assert config.get('default.city') == 'Anyang'
开发者ID:yaxin-cn,项目名称:konfig,代码行数:5,代码来源:test.py

示例13: fetch_remainder

# 需要导入模块: from config.config import Config [as 别名]
# 或者: from config.config.Config import get [as 别名]
def fetch_remainder(message={}):
    if "json" not in message:
        logging.error("$$$$ nytCommunity.fetch_remainder: ERROR NO JSON")
        return False
    if "results" not in message["json"]:
        logging.error("$$$$ nytCommunity.fetch_remainder: ERROR NO RESULTS IN JSON")
        return False
    if "totalCommentsFound" not in message["json"]["results"]:
        logging.warning("$$$$ nytCommunity.fetch_remainder: NO COMMENTS FOUND")
        return message
    if int(message["json"]["results"]["totalCommentsFound"]) <= 0:
        logging.warning("$$$$ nytCommunity.fetch_remainder: NO COMMENTS TO FETCH")
        return message
    if "article_id" not in message:
        logging.error("$$$$ nytCommunity.fetch_remainder: ERROR NO ARTICLE_ID PROVIDED")
        return False
    if "article_url" not in message:
        logging.error("**** nytCommunity.fetch_remainder: NO ARTICLE URL PROVIDED")
        return False

    logging.critical("$$$$ nytCommunity.fetch_remainder[" + message["article_id"].encode("utf-8") + "]")
    article = voxpop.VPE.get_items().get(_id=message["article_id"])
    if article is None:
        logging.error("$$$$ nytCommunity.fetch_remainder:ERROR Article Not Found")
        return False

    if "n_comments_cached" not in article.doc:
        article.doc["n_comments_cached"] = 0
    if int(article.doc["n_comments_cached"]) == int(message["json"]["results"]["totalCommentsFound"]):
        logging.error("$$$$ nytCommunity.fetch_remainder:All Comments already cached.")
        return False

    _nCommentsToFetch = int(message["json"]["results"]["totalCommentsFound"]) - article.doc["n_comments_cached"]
    n_requests = int(math.ceil(_nCommentsToFetch / int(Config.get("nyt_community")["response_size"]))) + 1
    _nRequestsOffset = int(
        math.floor(article.doc["n_comments_cached"] / int(Config.get("nyt_community")["response_size"]))
    )
    req_pars = {
        "article_id": message["article_id"],
        "article_url": message["article_url"],
        "functions": [api.make_api_request, cache_response],
    }
    logging.critical(
        "$$$$ nytCommunity.fetch_remainder: adding "
        + str(n_requests)
        + " more requests at offset ["
        + str(_nRequestsOffset)
        + "]"
    )
    for i in range(_nRequestsOffset, n_requests):
        request = {}
        for k, v in req_pars.iteritems():
            request[k] = v
        _url = "http://api.nytimes.com/svc/community/v2/comments/url/exact-match.json?"
        _url = _url + "url=" + urllib.quote_plus(message["article_url"])
        _url = _url + "&offset=" + str(i * 25)
        _url = _url + "&sort=oldest"
        _url = _url + "&api-key=" + Config.get("nyt_community")["key"]
        request["url"] = _url
        # logging.critical('BSM[fetch_remainder] Size:'+str(sys.getsizeof(pickle.dumps(request))))
        with voxpop.VPE.beanstalkd_lock:
            voxpop.VPE.get_beanstalkd().use("nytcommunity")
            voxpop.VPE.get_beanstalkd().put(pickle.dumps(request), pri=100000)
    return message
开发者ID:typecode,项目名称:voxpop,代码行数:66,代码来源:nytCommunity.py

示例14: Flask

# 需要导入模块: from config.config import Config [as 别名]
# 或者: from config.config.Config import get [as 别名]
from flask import Flask, render_template, g
import logging
from logging.handlers import RotatingFileHandler
from datetime import datetime

# user made module imports below
from user_web import user
from device_web import device
from grainbin_web import grain_bin

from config.config import Config
from database.model import db_session, Device, Grainbin

app = Flask(__name__)
app.secret_key = Config.get('flask', 'secret_key')
app.register_blueprint(user, url_prefix='/user')
app.register_blueprint(device, url_prefix='/device')
if Config.getboolean('services', 'grainbin_service'):
    app.register_blueprint(grain_bin, url_prefix='/grain_bin')

logfile_path = Config.get('flask', 'logfile_path')
file_handler = RotatingFileHandler(logfile_path,
                                   maxBytes=1024 * 1024 * 10,
                                   backupCount=10)
file_handler.setLevel(logging.WARNING)
formatter = logging.Formatter(
    "%(asctime)s - %(name)s - %(levelname)s - %(message)s")
file_handler.setFormatter(formatter)
app.logger.addHandler(file_handler)

开发者ID:nstoik,项目名称:farm_monitor,代码行数:31,代码来源:webinterface.py


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