本文整理汇总了Python中domogik.common.database.DbHelper.del_plugin_config方法的典型用法代码示例。如果您正苦于以下问题:Python DbHelper.del_plugin_config方法的具体用法?Python DbHelper.del_plugin_config怎么用?Python DbHelper.del_plugin_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类domogik.common.database.DbHelper
的用法示例。
在下文中一共展示了DbHelper.del_plugin_config方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: DBConnector
# 需要导入模块: from domogik.common.database import DbHelper [as 别名]
# 或者: from domogik.common.database.DbHelper import del_plugin_config [as 别名]
#.........这里部分代码省略.........
@param data : MQ req message
"""
msg = MQMessage()
msg.set_action('config.result')
status = True
msg_data = data.get_data()
if 'type' not in msg_data:
status = False
reason = "Config request : missing 'type' field : {0}".format(data)
if msg_data['type'] != "plugin":
status = False
reason = "Config request not available for type={0}".format(msg_data['type'])
if 'name' not in msg_data:
status = False
reason = "Config request : missing 'name' field : {0}".format(data)
if 'host' not in msg_data:
status = False
reason = "Config request : missing 'host' field : {0}".format(data)
if status == False:
self.log.error(reason)
else:
reason = ""
type = msg_data['type']
name = msg_data['name']
host = msg_data['host']
msg.add_data('type', type)
msg.add_data('name', name)
msg.add_data('host', host)
try:
self._db.del_plugin_config(name, host)
self.log.info(u"Delete config for {0} {1}".format(type, name))
self.publish_config_updated(type, name, host)
except:
status = False
reason = "Error while deleting configuration for '{0} {1} on {2} : {3}".format(type, name, host, traceback.format_exc())
self.log.error(reason)
msg.add_data('reason', reason)
msg.add_data('status', status)
self.log.debug(msg.get())
self.reply(msg.get())
def _fetch_techno_config(self, name, host, key):
'''
Fetch a plugin global config value in the database
@param name : the plugin of the element
@param host : hostname
@param key : the key of the config tuple to fetch
'''
try:
try:
result = self._db.get_plugin_config(name, host, key)
# tricky loop as workaround for a (sqlalchemy?) bug :
# sometimes the given result is for another plugin/key
# so while we don't get the good data, we loop
# This bug happens rarely
while result.id != name or \
result.hostname != host or \
result.key != key:
self.log.debug(u"Bad result : {0}/{1} != {2}/{3}".format(result.id, result.key, plugin, key))
示例2: DBConnector
# 需要导入模块: from domogik.common.database import DbHelper [as 别名]
# 或者: from domogik.common.database.DbHelper import del_plugin_config [as 别名]
#.........这里部分代码省略.........
@param data : MQ req message
"""
msg = MQMessage()
msg.set_action('config.result')
status = True
msg_data = data.get_data()
if 'type' not in msg_data:
status = False
reason = "Config request : missing 'type' field : {0}".format(data)
if msg_data['type'] not in ["plugin", "brain", "interface"]:
status = False
reason = "Configuration deletion not available for type={0}".format(msg_data['type'])
if 'name' not in msg_data:
status = False
reason = "Config request : missing 'name' field : {0}".format(data)
if 'host' not in msg_data:
status = False
reason = "Config request : missing 'host' field : {0}".format(data)
if status == False:
self.log.error(reason)
else:
reason = ""
type = msg_data['type']
name = msg_data['name']
host = msg_data['host']
msg.add_data('type', type)
msg.add_data('name', name)
msg.add_data('host', host)
try:
self._db.del_plugin_config(type, name, host)
self.log.info(u"Delete config for {0} {1}".format(type, name))
self.publish_config_updated(type, name, host)
except:
status = False
reason = "Error while deleting configuration for '{0} {1} on {2} : {3}".format(type, name, host, traceback.format_exc())
self.log.error(reason)
msg.add_data('reason', reason)
msg.add_data('status', status)
self.log.debug(msg.get())
self.reply(msg.get())
def _fetch_techno_config(self, name, type, host, key):
'''
Fetch a plugin global config value in the database
@param name : the plugin of the element
@param host : hostname
@param key : the key of the config tuple to fetch
'''
try:
try:
result = self._db.get_plugin_config(type, name, host, key)
# tricky loop as workaround for a (sqlalchemy?) bug :
# sometimes the given result is for another plugin/key
# so while we don't get the good data, we loop
# This bug happens rarely
while result.id != name or \
result.type != type or \
result.hostname != host or \
result.key != key:
示例3: DBConnector
# 需要导入模块: from domogik.common.database import DbHelper [as 别名]
# 或者: from domogik.common.database.DbHelper import del_plugin_config [as 别名]
#.........这里部分代码省略.........
@param data : MQ req message
"""
msg = MQMessage()
msg.set_action('config.result')
status = True
msg_data = data.get_data()
if 'type' not in msg_data:
status = False
reason = "Config request : missing 'type' field : {0}".format(data)
if msg_data['type'] != "plugin":
status = False
reason = "Config request not available for type={0}".format(msg_data['type'])
if 'name' not in msg_data:
status = False
reason = "Config request : missing 'name' field : {0}".format(data)
if 'host' not in msg_data:
status = False
reason = "Config request : missing 'host' field : {0}".format(data)
if status == False:
self.log.error(reason)
else:
reason = ""
type = msg_data['type']
name = msg_data['name']
host = msg_data['host']
msg.add_data('type', type)
msg.add_data('name', name)
msg.add_data('host', host)
try:
self._db.del_plugin_config(name, host)
self.log.info(u"Delete config for {0} {1}".format(type, name))
self.publish_config_updated(type, name, host)
except:
status = False
reason = "Error while deleting configuration for '{0} {1} on {2} : {3}".format(type, name, host, traceback.format_exc())
self.log.error(reason)
msg.add_data('reason', reason)
msg.add_data('status', status)
self.log.debug(msg.get())
self.reply(msg.get())
def _fetch_techno_config(self, name, host, key):
'''
Fetch a plugin global config value in the database
@param name : the plugin of the element
@param host : hostname
@param key : the key of the config tuple to fetch
'''
try:
try:
result = self._db.get_plugin_config(name, host, key)
# tricky loop as workaround for a (sqlalchemy?) bug :
# sometimes the given result is for another plugin/key
# so while we don't get the good data, we loop
# This bug happens rarely
while result.id != name or \
result.hostname != host or \
result.key != key:
self.log.debug(u"Bad result : {0}/{1} != {2}/{3}".format(result.id, result.key, plugin, key))