annotate sat/plugins/plugin_exp_command_export.py @ 2846:58ea675d0f05

quick frontend (app): added AUTO_RESYNC attribute in QuickApp, when set (default) the resync method is called on all widgets automatically: if AUTO_RESYNC is False, frontend must call itself the resync method. This is useful to improve performance, resynchronising all widgets at once may be resource intensive, and it may be more efficient to resync a widget only when it is visible.
author Goffi <goffi@goffi.org>
date Sun, 10 Mar 2019 18:02:42 +0100
parents 003b8b4b56a7
children ab2696e34d29
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1934
2daf7b4c6756 use of /usr/bin/env instead of /usr/bin/python in shebang
Goffi <goffi@goffi.org>
parents: 1766
diff changeset
1 #!/usr/bin/env python2
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
2 # -*- coding: utf-8 -*-
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
3
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 604
diff changeset
4 # SAT plugin to export commands (experimental)
2771
003b8b4b56a7 date update
Goffi <goffi@goffi.org>
parents: 2624
diff changeset
5 # Copyright (C) 2009-2019 Jérôme Poisson (goffi@goffi.org)
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
6
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 604
diff changeset
7 # This program is free software: you can redistribute it and/or modify
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 604
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 604
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 604
diff changeset
10 # (at your option) any later version.
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
11
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 604
diff changeset
12 # This program is distributed in the hope that it will be useful,
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 604
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 604
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 604
diff changeset
15 # GNU Affero General Public License for more details.
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
16
609
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 604
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
84a6e83157c2 fixed licences in docstrings (they are now in comments)
Goffi <goffi@goffi.org>
parents: 604
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
19
771
bfabeedbf32e core: i18n refactoring:
Goffi <goffi@goffi.org>
parents: 663
diff changeset
20 from sat.core.i18n import _
1955
633b5c21aefd backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
21 from sat.core.constants import Const as C
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 811
diff changeset
22 from sat.core.log import getLogger
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
23
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 811
diff changeset
24 log = getLogger(__name__)
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
25 from twisted.words.protocols.jabber import jid
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
26 from twisted.internet import reactor, protocol
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
27
1374
0befb14ecf62 renamed tools.misc to tools.trigger
Goffi <goffi@goffi.org>
parents: 993
diff changeset
28 from sat.tools import trigger
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
29 from sat.tools.utils import clean_ustr
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
30
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
31 PLUGIN_INFO = {
2145
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 2144
diff changeset
32 C.PI_NAME: "Command export plugin",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 2144
diff changeset
33 C.PI_IMPORT_NAME: "EXP-COMMANS-EXPORT",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 2144
diff changeset
34 C.PI_TYPE: "EXP",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 2144
diff changeset
35 C.PI_PROTOCOLS: [],
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 2144
diff changeset
36 C.PI_DEPENDENCIES: [],
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 2144
diff changeset
37 C.PI_MAIN: "CommandExport",
33c8c4973743 core (plugins): added missing contants + use of new constants in PLUGIN_INFO
Goffi <goffi@goffi.org>
parents: 2144
diff changeset
38 C.PI_HANDLER: "no",
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
39 C.PI_DESCRIPTION: _("""Implementation of command export"""),
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
40 }
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
41
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
42
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
43 class ExportCommandProtocol(protocol.ProcessProtocol):
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
44 """ Try to register an account with prosody """
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
45
2144
1d3f73e065e1 core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents: 1963
diff changeset
46 def __init__(self, parent, client, target, options):
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
47 self.parent = parent
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
48 self.target = target
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
49 self.options = options
2144
1d3f73e065e1 core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents: 1963
diff changeset
50 self.client = client
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
51
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
52 def _clean(self, data):
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
53 if not data:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
54 log.error("data should not be empty !")
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
55 return u""
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
56 decoded = data.decode("utf-8", "ignore")[: -1 if data[-1] == "\n" else None]
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
57 return clean_ustr(decoded)
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
58
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
59 def connectionMade(self):
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 811
diff changeset
60 log.info("connectionMade :)")
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
61
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
62 def outReceived(self, data):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
63 self.client.sendMessage(self.target, {"": self._clean(data)}, no_trigger=True)
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
64
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
65 def errReceived(self, data):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
66 self.client.sendMessage(self.target, {"": self._clean(data)}, no_trigger=True)
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
67
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
68 def processEnded(self, reason):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
69 log.info(u"process finished: %d" % (reason.value.exitCode,))
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
70 self.parent.removeProcess(self.target, self)
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
71
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
72 def write(self, message):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
73 self.transport.write(message.encode("utf-8"))
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
74
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
75 def boolOption(self, key):
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
76 """ Get boolean value from options
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
77 @param key: name of the option
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
78 @return: True if key exists and set to "true" (case insensitive),
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
79 False in all other cases """
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
80 value = self.options.get(key, "")
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
81 return value.lower() == "true"
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
82
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
83
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
84 class CommandExport(object):
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
85 """Command export plugin: export a command to an entity"""
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
86
2144
1d3f73e065e1 core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents: 1963
diff changeset
87 # XXX: This plugin can be potentially dangerous if we don't trust entities linked
1d3f73e065e1 core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents: 1963
diff changeset
88 # this is specially true if we have other triggers.
1d3f73e065e1 core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents: 1963
diff changeset
89 # FIXME: spawned should be a client attribute, not a class one
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
90
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
91 def __init__(self, host):
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 811
diff changeset
92 log.info(_("Plugin command export initialization"))
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
93 self.host = host
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
94 self.spawned = {} # key = entity
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
95 host.trigger.add("MessageReceived", self.MessageReceivedTrigger, priority=10000)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
96 host.bridge.addMethod(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
97 "exportCommand",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
98 ".plugin",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
99 in_sign="sasasa{ss}s",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
100 out_sign="",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
101 method=self._exportCommand,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
102 )
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
103
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
104 def removeProcess(self, entity, process):
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
105 """ Called when the process is finished
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
106 @param entity: jid.JID attached to the process
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
107 @param process: process to remove"""
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
108 try:
2144
1d3f73e065e1 core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents: 1963
diff changeset
109 processes_set = self.spawned[(entity, process.client.profile)]
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
110 processes_set.discard(process)
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
111 if not processes_set:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
112 del (self.spawned[(entity, process.client.profile)])
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
113 except ValueError:
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
114 pass
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
115
1963
a2bc5089c2eb backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents: 1955
diff changeset
116 def MessageReceivedTrigger(self, client, message_elt, post_treat):
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
117 """ Check if source is linked and repeat message, else do nothing """
1963
a2bc5089c2eb backend, frontends: message refactoring (huge commit):
Goffi <goffi@goffi.org>
parents: 1955
diff changeset
118 from_jid = jid.JID(message_elt["from"])
1955
633b5c21aefd backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
119 spawned_key = (from_jid.userhostJID(), client.profile)
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
120
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
121 if spawned_key in self.spawned:
1955
633b5c21aefd backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
122 try:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
123 body = message_elt.elements(C.NS_CLIENT, "body").next()
1955
633b5c21aefd backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
124 except StopIteration:
633b5c21aefd backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
125 # do not block message without body (chat state notification...)
633b5c21aefd backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
126 return True
633b5c21aefd backend, frontend: messages refactoring (huge commit, not finished):
Goffi <goffi@goffi.org>
parents: 1934
diff changeset
127
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
128 mess_data = unicode(body) + "\n"
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
129 processes_set = self.spawned[spawned_key]
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
130 _continue = False
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
131 exclusive = False
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
132 for process in processes_set:
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
133 process.write(mess_data)
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
134 _continue &= process.boolOption("continue")
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
135 exclusive |= process.boolOption("exclusive")
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
136 if exclusive:
1374
0befb14ecf62 renamed tools.misc to tools.trigger
Goffi <goffi@goffi.org>
parents: 993
diff changeset
137 raise trigger.SkipOtherTriggers
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
138 return _continue
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
139
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
140 return True
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
141
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
142 def _exportCommand(self, command, args, targets, options, profile_key):
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
143 """ Export a commands to authorised targets
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
144 @param command: full path of the command to execute
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
145 @param args: list of arguments, with command name as first one
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
146 @param targets: list of allowed entities
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
147 @param options: export options, a dict which can have the following keys ("true" to set booleans):
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
148 - exclusive: if set, skip all other triggers
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
149 - loop: if set, restart the command once terminated #TODO
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
150 - pty: if set, launch in a pseudo terminal
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
151 - continue: continue normal MessageReceived handling
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
152 """
2144
1d3f73e065e1 core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents: 1963
diff changeset
153 client = self.host.getClient(profile_key)
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
154 for target in targets:
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
155 try:
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
156 _jid = jid.JID(target)
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
157 if not _jid.user or not _jid.host:
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
158 raise jid.InvalidFormat
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
159 _jid = _jid.userhostJID()
1742
244a605623d6 complete the Exception's list when catching JID error:
souliane <souliane@mailoo.org>
parents: 1654
diff changeset
160 except (RuntimeError, jid.InvalidFormat, AttributeError):
993
301b342c697a core: use of the new core.log module:
Goffi <goffi@goffi.org>
parents: 811
diff changeset
161 log.info(u"invalid target ignored: %s" % (target,))
604
16a9affc49cf plugin export command: first draft
Goffi <goffi@goffi.org>
parents:
diff changeset
162 continue
2144
1d3f73e065e1 core, jp: component handling + client handling refactoring:
Goffi <goffi@goffi.org>
parents: 1963
diff changeset
163 process_prot = ExportCommandProtocol(self, client, _jid, options)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
164 self.spawned.setdefault((_jid, client.profile), set()).add(process_prot)
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
165 reactor.spawnProcess(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
166 process_prot, command, args, usePTY=process_prot.boolOption("pty")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
167 )