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


Python MQMessage.get方法代码示例

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


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

示例1: scenario_edit

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import get [as 别名]
def scenario_edit(id):
    # Fetch all known actions
    actions = []
    cli = MQSyncReq(app.zmq_context)
    msg = MQMessage()
    msg.set_action('action.list')
    res = cli.request('scenario', msg.get(), timeout=10)
    if res is not None:
        res = res.get_data()
        if 'result' in res:
            res = json.loads(res['result'])
            actions = res.keys()
    # Fetch all known tests
    tests = []
    cli = MQSyncReq(app.zmq_context)
    msg = MQMessage()
    msg.set_action('test.list')
    res = cli.request('scenario', msg.get(), timeout=10)
    if res is not None:
        res = res.get_data()
        if 'result' in res:
            res = json.loads(res['result'])
            tests = res.keys()
    # TODO laod the json for this scenario
    # if not exists send None == new
    jso = None

    return render_template('scenario_edit.html',
        mactive = "scenario",
        actions = actions,
        tests = tests,
        json = jso)
开发者ID:geneReeves,项目名称:domogik,代码行数:34,代码来源:scenario.py

示例2: _mdp_reply_config_set

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import get [as 别名]
    def _mdp_reply_config_set(self, data):
        """ Reply to config.set MQ req
            @param data : MQ req message
        """
        print "#################"
        msg = MQMessage()
        msg.set_action('config.result')
        status = True
        msg_data = data.get_data()
        if 'type' not in msg_data:
            status = False
            reason = "Config set : missing 'type' field : {0}".format(data)

        if msg_data['type'] != "plugin":
            status = False
            reason = "Config set not available for type={0}".format(msg_data['type'])

        if 'name' not in msg_data:
            status = False
            reason = "Config set : missing 'name' field : {0}".format(data)

        if 'host' not in msg_data:
            status = False
            reason = "Config set : missing 'host' field : {0}".format(data)

        if 'data' not in msg_data:
            status = False
            reason = "Config set : missing 'data' 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']
            data = msg_data['data']
            msg.add_data('type', type)
            msg.add_data('name', name)
            msg.add_data('host', host)
            try: 
                # we add a configured key set to true to tell the UIs and plugins that there are some configuration elements
                self._db.set_plugin_config(name, host, "configured", True)
                for key in msg_data['data']:
                    self._db.set_plugin_config(name, host, key, data[key])
                self.publish_config_updated(type, name, host)
            except:
                reason = "Error while setting configuration for '{0} {1} on {2}' : {3}".format(type, name, host, traceback.format_exc())
                status = False
                self.log.error(reason)

        msg.add_data('status', status)
        msg.add_data('reason', reason)

        self.log.debug(msg.get())
        self.reply(msg.get())
开发者ID:Basilic,项目名称:domogik,代码行数:58,代码来源:dbmgr.py

示例3: scenario_edit

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import get [as 别名]
def scenario_edit(id):
    default_json = '{"type":"dom_condition","id":"1","deletable":false}'
    # laod the json
    if id == 0:
        name = "ikke"
        jso = default_json
    else:
        # TODO laod from DB
        jso = default_json
        name = "new"
    # create a form
    class F(Form):
        sid = HiddenField("id", default=id)
        sname = TextField("name", default=name)
        sjson = HiddenField("json")
        submit = SubmitField("Send")
        pass
    form = F()

    if request.method == 'POST' and form.validate():
        print request.form
        flash(gettext("Changes saved"), "success")
        return redirect("/scenario")
        pass
    else:
        # Fetch all known actions
        actions = []
        cli = MQSyncReq(app.zmq_context)
        msg = MQMessage()
        msg.set_action('action.list')
        res = cli.request('scenario', msg.get(), timeout=10)
        if res is not None:
            res = res.get_data()
            if 'result' in res:
                res = json.loads(res['result'])
                actions = res.keys()
        # Fetch all known tests
        tests = []
        cli = MQSyncReq(app.zmq_context)
        msg = MQMessage()
        msg.set_action('test.list')
        res = cli.request('scenario', msg.get(), timeout=10)
        if res is not None:
            res = res.get_data()
            if 'result' in res:
                res = json.loads(res['result'])
                tests = res.keys()
        # ouput
        return render_template('scenario_edit.html',
            mactive = "scenario",
            form = form,
            name = name,
            actions = actions,
            tests = tests,
            jso = jso)
开发者ID:ka2er,项目名称:domogik,代码行数:57,代码来源:scenario.py

示例4: _mdp_reply

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import get [as 别名]
 def _mdp_reply(self, plugin, hostname, key, value, element=None):
     msg = MQMessage()
     msg.setaction( 'config.result' )
     msg.add_data('plugin', plugin)
     msg.add_data('hostname', hostname)
     msg.add_data('key', key)
     msg.add_data('value', value)
     if element:
         msg.add_data('element', element)
     print msg.get()
     self.reply(msg.get())
开发者ID:capof,项目名称:domogik,代码行数:13,代码来源:dbmgr.py

示例5: _mdp_reply_config_delete

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import get [as 别名]
    def _mdp_reply_config_delete(self, data):
        """ Reply to config.delete MQ req
            Delete all the config items for the given type, name and host
            @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())
开发者ID:Basilic,项目名称:domogik,代码行数:51,代码来源:dbmgr.py

示例6: WSCommandSend

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import get [as 别名]
 def WSCommandSend(self, data):
     cli = MQSyncReq(zmq.Context())
     msg = MQMessage()
     msg.set_action('cmd.send')
     msg.add_data('cmdid', data['command_id'])
     msg.add_data('cmdparams', data['parameters'])
     return cli.request('xplgw', msg.get(), timeout=10).get()
开发者ID:pnb990,项目名称:domoweb,代码行数:9,代码来源:handlers.py

示例7: client_devices_edit

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import get [as 别名]
def client_devices_edit(client_id, did):
    with app.db.session_scope():
        device = app.db.get_device_sql(did)
        MyForm = model_form(Device, \
                        base_class=Form, \
                        db_session=app.db.get_session(),
                        exclude=['params', 'commands', 'sensors', 'address', 'xpl_commands', 'xpl_stats', 'device_type_id', 'client_id', 'client_version'])
        form = MyForm(request.form, device)

        if request.method == 'POST' and form.validate():
            # save it
            app.db.update_device(did, \
                    d_name=request.form['name'], \
                    d_description=request.form['description'], \
                    d_reference=request.form['reference'])
            # message the suer
            flash(gettext("Device saved"), 'success')
            # reload stats
            req = MQSyncReq(app.zmq_context)
            msg = MQMessage()
            msg.set_action( 'reload' )
            resp = req.request('xplgw', msg.get(), 100)
            # redirect
            return redirect("/client/{0}/dmg_devices/known".format(client_id))
        else:
            return render_template('client_device_edit.html',
                form = form,
                clientid = client_id,
                mactive="clients",
                active = 'devices'
                )
开发者ID:geneReeves,项目名称:domogik,代码行数:33,代码来源:clients.py

示例8: client_devices_new

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import get [as 别名]
def client_devices_new(client_id):
    cli = MQSyncReq(app.zmq_context)
    msg = MQMessage()
    msg.set_action('client.detail.get')
    res = cli.request('manager', msg.get(), timeout=10)
    if res is not None:
        detaila = res.get_data()
        data = detaila[client_id]['data']
    else:
        data = {}
    if type(data["device_types"]) is not dict:
        dtypes = {}
    else:
        dtypes = list(data["device_types"].keys())
    products = {}
    if "products" in data:
        for prod in data["products"]:
            products[prod["name"]] = prod["type"]
 
    return render_template('client_device_new.html',
            device_types = dtypes,
            products = products,
            clientid = client_id,
            mactve="clients",
            active = 'devices'
            )
开发者ID:mehrdad-s,项目名称:domogik,代码行数:28,代码来源:clients.py

示例9: check_config

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import get [as 别名]
def check_config(type, name, host, key, exp_value):
    cli = MQSyncReq(zmq.Context())
    msg = MQMessage()
    msg.set_action('config.get')
    msg.add_data('type', type)
    msg.add_data('host', host)
    msg.add_data('name', name)
    msg.add_data('key', key)
    result = cli.request('dbmgr', msg.get(), timeout=10)
    if result:
	data = result.get_data()
	if 'status' in data:
	    if not data['status']:
                print(result.get())
	        raise RuntimeError("DbMgr did not return status true on a config.set for {0}-{1}.{2} : {3} = {4}".format(type, name, host, key, value))
            else:
                if 'value' in data:
                    if data['value'] != exp_value:
       			print(result.get())
                        raise RuntimeError("The returned value is not the expected value for {0}-{1}.{2} : {3} = {4} but received {5}".format(type, name, host, key, exp_value, data['value']))
		    else:
                        return True
                else:
                    print(result.get())
	            raise RuntimeError("DbMgr did not return a value on a config.set for {0}-{1}.{2} : {3} = {4}".format(type, name, host, key, value))
        else:
	    print(result.get())
	    raise RuntimeError("DbMgr did not return a status on a config.set for {0}-{1}.{2} : {3} = {4}".format(type, name, host, key, value))
    else:
        raise RuntimeError("Error while setting configuration for {0}-{1}.{2} : {3} = {4}".format(type, name, host, key, value))
开发者ID:Basilic,项目名称:domogik,代码行数:32,代码来源:helpers.py

示例10: _mdp_reply_plugin_stop

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import get [as 别名]
    def _mdp_reply_plugin_stop(self, data):
        """ Stop the plugin
            @param data : MQ req message

            First, send the MQ Rep to 'ack' the request
            Then, change the plugin status to STATUS_STOP_REQUEST
            Then, quit the plugin by calling force_leave(). This should make the plugin send a STATUS_STOPPED if all is ok

            Notice that no check is done on the MQ req content : we need nothing in it as it is directly addressed to a plugin
        """
        # check if the message is for us
        content = data.get_data()
        if content['name'] != self._name or content['host'] != self.get_sanitized_hostname():
            return

        ### Send the ack over MQ Rep
        msg = MQMessage()
        msg.set_action('plugin.stop.result')
        status = True
        reason = ""
        msg.add_data('status', status)
        msg.add_data('reason', reason)
        self.reply(msg.get())

        ### Change the plugin status
        self._set_status(STATUS_STOP_REQUEST)

        ### Try to stop the plugin
        # if it fails, the manager should try to kill the plugin
        self.force_leave()
开发者ID:cedric-bollini,项目名称:domogik,代码行数:32,代码来源:plugin.py

示例11: test_XplCmd

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import get [as 别名]
    def test_XplCmd(self, parameters = {}, statParams = None):
        """Send an Xpl cmd with statics parameters by request, if necessary start testcase listener for ack message and 
             check if insert in database is ok.
        """
        if self.get_return_confirmation() :
            schema,  data,  statResult = self.get_XplStat_fromAck(statParams)
            th = threading.Thread(None, self.assert_Xpl_Stat_Ack_Wait, "th_test_0110_xpl-ack_from_{0}".format(self.command_name), (schema,  data, statResult))
            th.start()
            time.sleep(1)
        else : 
            print (u"No ack required for {0}".format(self.command_name))
        if self._device and self.command_id :
            cli = MQSyncReq(zmq.Context())
            msg = MQMessage()
            msg.set_action('cmd.send')
            msg.add_data('cmdid', self.command_id)
            msg.add_data('cmdparams', parameters)
            print (u"Send xpl_cmnd {0}".format(self.command_name))
            cli.request('xplgw', msg.get(), timeout=10)
#            if self.get_return_confirmation() :
#                self.assert_get_last_command_in_db(statResult)
#            else : 
#                print (u"No ack required for {0}".format(self.command_name))
            return True
        else : return False
开发者ID:Basilic,项目名称:domogik,代码行数:27,代码来源:testcommand.py

示例12: _mdp_reply_plugin_start

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import get [as 别名]
    def _mdp_reply_plugin_start(self, data):
        """ Reply on the MQ
            @param data : msg REQ received
        """
        msg = MQMessage()
        msg.set_action('plugin.start.result')

        if 'name' not in data.get_data().keys():
            status = False
            reason = "Plugin startup request : missing 'name' field"
            self.log.error(reason)
        else:
            name = data.get_data()['name']
            msg.add_data('name', name)

            # try to start the plugin
            pid = self._plugins[name].start()
            if pid != 0:
                status = True
                reason = ""
            else:
                status = False
                reason = "Plugin '{0}' startup failed".format(name)

        msg.add_data('status', status)
        msg.add_data('reason', reason)
        self.reply(msg.get())
开发者ID:mehrdad-s,项目名称:domogik,代码行数:29,代码来源:manager.py

示例13: reload_stats

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import get [as 别名]
 def reload_stats(self):
     self.log.debug(u"=============== reload stats")
     req = MQSyncReq(self.zmq)
     msg = MQMessage()
     msg.set_action( 'reload' )
     resp = req.request('xplgw', msg.get(), 100)
     self.log.debug(u"Reply from xplgw: {0}".format(resp))
     self.log.debug(u"=============== reload stats END")
开发者ID:Basilic,项目名称:domogik,代码行数:10,代码来源:rest.py

示例14: _mdp_reply_packages_detail

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import get [as 别名]
 def _mdp_reply_packages_detail(self):
     """ Reply on the MQ
     """
     msg = MQMessage()
     msg.set_action('package.detail.result')
     for pkg in self._packages:
         msg.add_data(pkg, self._packages[pkg].get_json())
     self.reply(msg.get())
开发者ID:mehrdad-s,项目名称:domogik,代码行数:10,代码来源:manager.py

示例15: on_message

# 需要导入模块: from domogik.mq.message import MQMessage [as 别名]
# 或者: from domogik.mq.message.MQMessage import get [as 别名]
 def on_message(self, msg, content=None):
     if not content:
         # this is a websocket message
         jsons = json.loads(msg)
         if 'action' in jsons and 'data' in jsons:
             cli = MQSyncReq(zmq.Context())
             msg = MQMessage()
             msg.set_action(str(jsons['action']))
             msg.set_data(jsons['data'])
             if 'dst' in jsons:
                 print cli.request(str(jsons['dst']), msg.get(), timeout=10).get()
             else:
                 print cli.request('manager', msg.get(), timeout=10).get()
     else:
         # this is a mq message
         for cli in AdminWebSocket.clients:
             cli.write_message({"msgid": msg, "content": content})
开发者ID:Dsls,项目名称:domogik,代码行数:19,代码来源:admin.py


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