本文整理汇总了Python中domogik.xpl.common.plugin.XplPlugin.on_mdp_request方法的典型用法代码示例。如果您正苦于以下问题:Python XplPlugin.on_mdp_request方法的具体用法?Python XplPlugin.on_mdp_request怎么用?Python XplPlugin.on_mdp_request使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类domogik.xpl.common.plugin.XplPlugin
的用法示例。
在下文中一共展示了XplPlugin.on_mdp_request方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_mdp_request
# 需要导入模块: from domogik.xpl.common.plugin import XplPlugin [as 别名]
# 或者: from domogik.xpl.common.plugin.XplPlugin import on_mdp_request [as 别名]
def on_mdp_request(self, msg):
""" Called when a MQ req/rep message is received
"""
XplPlugin.on_mdp_request(self, msg)
if msg.get_action() == "client.cmd":
print(msg)
reason = None
status = True
data = msg.get_data()
if 'blacklist' in data:
bl = data['blacklist']
else:
reason = u"Invalid command : no blacklist key in message"
status = False
if status == True:
try:
with open(self.blacklist_file, 'ab') as fp_blacklist:
fp_blacklist.write("\n{0};{1}".format("manual blacklisting", bl))
except:
reason = u"Error while completing blacklist file : {0}. Error is : {1}".format(self.blacklist_file, traceback.format_exc())
self.log.error(reason)
status = False
self.load_blacklist()
self.log.info("Reply to command")
reply_msg = MQMessage()
reply_msg.set_action('client.cmd.result')
reply_msg.add_data('status', status)
reply_msg.add_data('reason', reason)
self.reply(reply_msg.get())
if status == True:
thread.start_new_thread(self.open_modems, ())
示例2: on_mdp_request
# 需要导入模块: from domogik.xpl.common.plugin import XplPlugin [as 别名]
# 或者: from domogik.xpl.common.plugin.XplPlugin import on_mdp_request [as 别名]
def on_mdp_request(self, msg):
""" Handle Requests over MQ
@param msg : MQ req message
"""
# XplPlugin handles MQ Req/rep also
XplPlugin.on_mdp_request(self, msg)
### packages details
# retrieve the packages details
if msg.get_action() == "package.detail.get":
self.log.info(u"Packages details request : {0}".format(msg))
self._mdp_reply_packages_detail()
### device_types
# retrieve the device_types
elif msg.get_action() == "device_types.get":
self.log.info(u"Device types request : {0}".format(msg))
self._mdp_reply_device_types(msg)
### clients list and details
# retrieve the clients list
elif msg.get_action() == "client.list.get":
self.log.info(u"Clients list request : {0}".format(msg))
self._mdp_reply_clients_list()
# retrieve the clients details
elif msg.get_action() == "client.detail.get":
self.log.info(u"Clients details request : {0}".format(msg))
self._mdp_reply_clients_detail()
# start clients
elif msg.get_action() == "plugin.start.do":
self.log.info(u"Plugin startup request : {0}".format(msg))
self._mdp_reply_plugin_start(msg)
示例3: on_mdp_request
# 需要导入模块: from domogik.xpl.common.plugin import XplPlugin [as 别名]
# 或者: from domogik.xpl.common.plugin.XplPlugin import on_mdp_request [as 别名]
def on_mdp_request(self, msg):
# XplPlugin handles MQ Req/rep also
XplPlugin.on_mdp_request(self, msg)
if msg.get_action() == "reload":
self.load()
msg = MQMessage()
msg.set_action( 'reload.result' )
self.reply(msg.get())
elif msg.get_action() == "cmd.send":
self._send_xpl_command(msg)
示例4: on_mdp_request
# 需要导入模块: from domogik.xpl.common.plugin import XplPlugin [as 别名]
# 或者: from domogik.xpl.common.plugin.XplPlugin import on_mdp_request [as 别名]
def on_mdp_request(self, msg):
""" Method called when an mq request comes in
XplPlugin also needs this info, so we need to do a passthrough
"""
try:
XplPlugin.on_mdp_request(self, msg)
if msg.get_action() == "test":
pass
if msg.get_action() == "cmd.send":
self._send_xpl_command(msg)
except Exception as exp:
self.log.error(traceback.format_exc())
示例5: on_mdp_request
# 需要导入模块: from domogik.xpl.common.plugin import XplPlugin [as 别名]
# 或者: from domogik.xpl.common.plugin.XplPlugin import on_mdp_request [as 别名]
def on_mdp_request(self, msg):
# XplPlugin handles MQ Req/rep also
try:
XplPlugin.on_mdp_request(self, msg)
if msg.get_action() == "reload":
self.load()
msg = MQMessage()
msg.set_action( 'reload.result' )
self.reply(msg.get())
elif msg.get_action() == "cmd.send":
self._send_xpl_command(msg)
except:
self.log.error(traceback.format_exc())
示例6: on_mdp_request
# 需要导入模块: from domogik.xpl.common.plugin import XplPlugin [as 别名]
# 或者: from domogik.xpl.common.plugin.XplPlugin import on_mdp_request [as 别名]
def on_mdp_request(self, msg):
""" Handle Requests over MQ
@param msg : MQ req message
"""
with self._db.session_scope():
# XplPlugin handles MQ Req/rep also
XplPlugin.on_mdp_request(self, msg)
# configuration
if msg.get_action() == "config.get":
self._mdp_reply_config_get(msg)
elif msg.get_action() == "config.set":
self._mdp_reply_config_set(msg)
elif msg.get_action() == "config.delete":
self._mdp_reply_config_delete(msg)
# devices list
elif msg.get_action() == "device.get":
self._mdp_reply_devices_result(msg)