comparison src/plugins/plugin_exp_command_export.py @ 1374:0befb14ecf62

renamed tools.misc to tools.trigger
author Goffi <goffi@goffi.org>
date Thu, 19 Mar 2015 19:44:37 +0100
parents 301b342c697a
children 069ad98b360d
comparison
equal deleted inserted replaced
1373:6d0e01809893 1374:0befb14ecf62
21 from sat.core.log import getLogger 21 from sat.core.log import getLogger
22 log = getLogger(__name__) 22 log = getLogger(__name__)
23 from twisted.words.protocols.jabber import jid 23 from twisted.words.protocols.jabber import jid
24 from twisted.internet import reactor, protocol 24 from twisted.internet import reactor, protocol
25 25
26 from sat.tools.misc import SkipOtherTriggers 26 from sat.tools import trigger
27 from sat.tools.utils import clean_ustr 27 from sat.tools.utils import clean_ustr
28 28
29 PLUGIN_INFO = { 29 PLUGIN_INFO = {
30 "name": "Command export plugin", 30 "name": "Command export plugin",
31 "import_name": "EXP-COMMANS-EXPORT", 31 "import_name": "EXP-COMMANS-EXPORT",
55 55
56 def connectionMade(self): 56 def connectionMade(self):
57 log.info("connectionMade :)") 57 log.info("connectionMade :)")
58 58
59 def outReceived(self, data): 59 def outReceived(self, data):
60 self.parent.host.sendMessage(self.target, self._clean(data), no_trigger=True, profile_key=self.profile) 60 self.parent.host.sendMessage(self.target, self._clean(data), no_trigger=True, profile_key=self.profile)
61 61
62 def errReceived(self, data): 62 def errReceived(self, data):
63 self.parent.host.sendMessage(self.target, self._clean(data), no_trigger=True, profile_key=self.profile) 63 self.parent.host.sendMessage(self.target, self._clean(data), no_trigger=True, profile_key=self.profile)
64 64
65 def processEnded(self, reason): 65 def processEnded(self, reason):
66 log.info (u"process finished: %d" % (reason.value.exitCode,)) 66 log.info (u"process finished: %d" % (reason.value.exitCode,))
67 self.parent.removeProcess(self.target, self) 67 self.parent.removeProcess(self.target, self)
68 68
122 for process in processes_set: 122 for process in processes_set:
123 process.write(mess_data) 123 process.write(mess_data)
124 _continue &= process.boolOption("continue") 124 _continue &= process.boolOption("continue")
125 exclusive |= process.boolOption("exclusive") 125 exclusive |= process.boolOption("exclusive")
126 if exclusive: 126 if exclusive:
127 raise SkipOtherTriggers 127 raise trigger.SkipOtherTriggers
128 return _continue 128 return _continue
129 129
130 return True 130 return True
131 131
132 def _exportCommand(self, command, args, targets, options, profile_key): 132 def _exportCommand(self, command, args, targets, options, profile_key):
142 """ 142 """
143 profile = self.host.memory.getProfileName(profile_key) 143 profile = self.host.memory.getProfileName(profile_key)
144 if not profile: 144 if not profile:
145 log.warning("Unknown profile [%s]" % (profile,)) 145 log.warning("Unknown profile [%s]" % (profile,))
146 return 146 return
147 147
148 for target in targets: 148 for target in targets:
149 try: 149 try:
150 _jid = jid.JID(target) 150 _jid = jid.JID(target)
151 if not _jid.user or not _jid.host: 151 if not _jid.user or not _jid.host:
152 raise jid.InvalidFormat 152 raise jid.InvalidFormat