Mercurial > libervia-backend
comparison sat/plugins/plugin_exp_command_export.py @ 3172:dcebc585c29f
core: renamed "MessageReceived" trigger to "messageReceived" for consistency.
author | Goffi <goffi@goffi.org> |
---|---|
date | Tue, 18 Feb 2020 18:13:19 +0100 |
parents | 559a625a236b |
children | be6d91572633 |
comparison
equal
deleted
inserted
replaced
3171:d073d82d9044 | 3172:dcebc585c29f |
---|---|
90 | 90 |
91 def __init__(self, host): | 91 def __init__(self, host): |
92 log.info(_("Plugin command export initialization")) | 92 log.info(_("Plugin command export initialization")) |
93 self.host = host | 93 self.host = host |
94 self.spawned = {} # key = entity | 94 self.spawned = {} # key = entity |
95 host.trigger.add("MessageReceived", self.MessageReceivedTrigger, priority=10000) | 95 host.trigger.add("messageReceived", self.messageReceivedTrigger, priority=10000) |
96 host.bridge.addMethod( | 96 host.bridge.addMethod( |
97 "exportCommand", | 97 "exportCommand", |
98 ".plugin", | 98 ".plugin", |
99 in_sign="sasasa{ss}s", | 99 in_sign="sasasa{ss}s", |
100 out_sign="", | 100 out_sign="", |
111 if not processes_set: | 111 if not processes_set: |
112 del (self.spawned[(entity, process.client.profile)]) | 112 del (self.spawned[(entity, process.client.profile)]) |
113 except ValueError: | 113 except ValueError: |
114 pass | 114 pass |
115 | 115 |
116 def MessageReceivedTrigger(self, client, message_elt, post_treat): | 116 def messageReceivedTrigger(self, client, message_elt, post_treat): |
117 """ Check if source is linked and repeat message, else do nothing """ | 117 """ Check if source is linked and repeat message, else do nothing """ |
118 from_jid = jid.JID(message_elt["from"]) | 118 from_jid = jid.JID(message_elt["from"]) |
119 spawned_key = (from_jid.userhostJID(), client.profile) | 119 spawned_key = (from_jid.userhostJID(), client.profile) |
120 | 120 |
121 if spawned_key in self.spawned: | 121 if spawned_key in self.spawned: |
146 @param targets: list of allowed entities | 146 @param targets: list of allowed entities |
147 @param options: export options, a dict which can have the following keys ("true" to set booleans): | 147 @param options: export options, a dict which can have the following keys ("true" to set booleans): |
148 - exclusive: if set, skip all other triggers | 148 - exclusive: if set, skip all other triggers |
149 - loop: if set, restart the command once terminated #TODO | 149 - loop: if set, restart the command once terminated #TODO |
150 - pty: if set, launch in a pseudo terminal | 150 - pty: if set, launch in a pseudo terminal |
151 - continue: continue normal MessageReceived handling | 151 - continue: continue normal messageReceived handling |
152 """ | 152 """ |
153 client = self.host.getClient(profile_key) | 153 client = self.host.getClient(profile_key) |
154 for target in targets: | 154 for target in targets: |
155 try: | 155 try: |
156 _jid = jid.JID(target) | 156 _jid = jid.JID(target) |