annotate sat_frontends/jp/cmd_pipe.py @ 2646:712cb4ff3e13

core: new EncryptionHandler class which manage encrypted session as a core feature: Plugin handling encryption can now register using host.registerEncryptionPlugin, and an encryption session can now be started using messageEncryptionStart bridge method. This will make encryption handling more easy, as we now know if a session is clear or e2e encrypted, and which plugin handle it.
author Goffi <goffi@goffi.org>
date Sun, 29 Jul 2018 19:22:56 +0200
parents 56f94936df1e
children 003b8b4b56a7
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1960
3e168cde7a7d jp: fixed shebang python call
Goffi <goffi@goffi.org>
parents: 1864
diff changeset
1 #!/usr/bin/env python2
815
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
2 # -*- coding: utf-8 -*-
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
3
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
4 # jp: a SAT command line tool
2483
0046283a285d dates update
Goffi <goffi@goffi.org>
parents: 2414
diff changeset
5 # Copyright (C) 2009-2018 Jérôme Poisson (goffi@goffi.org)
815
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
6
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
7 # This program is free software: you can redistribute it and/or modify
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
8 # it under the terms of the GNU Affero General Public License as published by
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
9 # the Free Software Foundation, either version 3 of the License, or
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
10 # (at your option) any later version.
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
11
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
12 # This program is distributed in the hope that it will be useful,
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
15 # GNU Affero General Public License for more details.
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
16
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
17 # You should have received a copy of the GNU Affero General Public License
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
18 # along with this program. If not, see <http://www.gnu.org/licenses/>.
f8d534ed1d1e jp: added missing license headers
Goffi <goffi@goffi.org>
parents: 814
diff changeset
19
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
20 from sat_frontends.jp import base
0
goffi@necton2
parents:
diff changeset
21
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
22 from sat_frontends.jp.constants import Const as C
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
23 import sys
814
59c7bc51c323 jp: refactoring using ArgParse
Dal <kedals0@gmail.com>
parents: 811
diff changeset
24 from sat.core.i18n import _
1670
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
25 from sat_frontends.tools import jid
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
26 import xml.etree.ElementTree as ET # FIXME: used temporarily to manage XMLUI
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
27 from functools import partial
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
28 import socket
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
29 import SocketServer
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
30 import errno
0
goffi@necton2
parents:
diff changeset
31
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
32 __commands__ = ["Pipe"]
0
goffi@necton2
parents:
diff changeset
33
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
34 START_PORT = 9999
1670
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
35
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
36
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
37 class PipeOut(base.CommandBase):
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
38 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
39 super(PipeOut, self).__init__(host, "out", help=_("send a pipe a stream"))
1864
96ba685162f6 jp: all commands now use the new start method and set need_loop in __init__ when needed
Goffi <goffi@goffi.org>
parents: 1766
diff changeset
40 self.need_loop = True
393
393b35aa86d2 jp: added --connect option
Goffi <goffi@goffi.org>
parents: 391
diff changeset
41
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
42 def add_parser_options(self):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
43 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
44 "jid", type=base.unicode_decoder, help=_("the destination jid")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
45 )
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
46
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
47 def streamOutCb(self, port):
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
48 s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
49 s.connect(("127.0.0.1", int(port)))
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
50 while True:
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
51 buf = sys.stdin.read(4096)
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
52 if not buf:
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
53 break
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
54 try:
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
55 s.sendall(buf)
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
56 except socket.error as e:
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
57 if e.errno == errno.EPIPE:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
58 sys.stderr.write(str(e) + "\n")
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
59 self.host.quit(1)
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
60 else:
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
61 raise e
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
62 self.host.quit()
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
63
1864
96ba685162f6 jp: all commands now use the new start method and set need_loop in __init__ when needed
Goffi <goffi@goffi.org>
parents: 1766
diff changeset
64 def start(self):
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
65 """ Create named pipe, and send stdin to it """
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
66 self.host.bridge.streamOut(
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
67 self.host.get_full_jid(self.args.jid),
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
68 self.profile,
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
69 callback=self.streamOutCb,
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
70 errback=partial(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
71 self.errback,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
72 msg=_(u"can't start stream: {}"),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
73 exit_code=C.EXIT_BRIDGE_ERRBACK,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
74 ),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
75 )
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
76
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
77
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
78 class StreamServer(SocketServer.BaseRequestHandler):
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
79 def handle(self):
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
80 while True:
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
81 data = self.request.recv(4096)
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
82 if not data:
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
83 break
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
84 sys.stdout.write(data)
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
85 try:
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
86 sys.stdout.flush()
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
87 except IOError as e:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
88 sys.stderr.write(str(e) + "\n")
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
89 break
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
90 #  calling shutdown will do a deadlock as we don't use separate thread
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
91 # this is a workaround (cf. https://stackoverflow.com/a/36017741)
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
92 self.server._BaseServer__shutdown_request = True
401
b2caa2615c4c jp roster name manegement + Pipe transfer
Goffi <goffi@goffi.org>
parents: 393
diff changeset
93
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
94
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
95 class PipeIn(base.CommandAnswering):
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
96 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
97 super(PipeIn, self).__init__(host, "in", help=_("receive a pipe stream"))
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
98 self.action_callbacks = {"STREAM": self.onStreamAction}
587
952322b1d490 Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents: 572
diff changeset
99
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
100 def add_parser_options(self):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
101 self.parser.add_argument(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
102 "jids",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
103 type=base.unicode_decoder,
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
104 nargs="*",
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
105 help=_('Jids accepted (none means "accept everything")'),
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
106 )
0
goffi@necton2
parents:
diff changeset
107
1670
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
108 def getXmluiId(self, action_data):
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
109 # FIXME: we temporarily use ElementTree, but a real XMLUI managing module
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
110 # should be available in the future
1670
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
111 # TODO: XMLUI module
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
112 try:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
113 xml_ui = action_data["xmlui"]
1670
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
114 except KeyError:
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
115 self.disp(_(u"Action has no XMLUI"), 1)
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
116 else:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
117 ui = ET.fromstring(xml_ui.encode("utf-8"))
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
118 xmlui_id = ui.get("submit")
1670
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
119 if not xmlui_id:
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
120 self.disp(_(u"Invalid XMLUI received"), error=True)
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
121 return xmlui_id
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
122
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
123 def onStreamAction(self, action_data, action_id, security_limit, profile):
1670
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
124 xmlui_id = self.getXmluiId(action_data)
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
125 if xmlui_id is None:
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
126 return self.host.quitFromSignal(1)
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
127 try:
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
128 from_jid = jid.JID(action_data["meta_from_jid"])
1670
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
129 except KeyError:
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
130 self.disp(_(u"Ignoring action without from_jid data"), 1)
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
131 return
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
132
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
133 if not self.bare_jids or from_jid.bare in self.bare_jids:
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
134 host, port = "localhost", START_PORT
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
135 while True:
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
136 try:
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
137 server = SocketServer.TCPServer((host, port), StreamServer)
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
138 except socket.error as e:
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
139 if e.errno == errno.EADDRINUSE:
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
140 port += 1
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
141 else:
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
142 raise e
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
143 else:
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
144 break
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
145 xmlui_data = {"answer": C.BOOL_TRUE, "port": unicode(port)}
1670
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
146 self.host.bridge.launchAction(xmlui_id, xmlui_data, profile_key=profile)
2489
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
147 server.serve_forever()
e2a7bb875957 plugin pipe/stream, file transfert: refactoring and improvments:
Goffi <goffi@goffi.org>
parents: 2483
diff changeset
148 self.host.quitFromSignal()
1670
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
149
1864
96ba685162f6 jp: all commands now use the new start method and set need_loop in __init__ when needed
Goffi <goffi@goffi.org>
parents: 1766
diff changeset
150 def start(self):
1670
3690b4d4157e jp (pipe): pipe commands now use the new CommandAnswering API (with actionNew)
Goffi <goffi@goffi.org>
parents: 1396
diff changeset
151 self.bare_jids = [jid.JID(jid_).bare for jid_ in self.args.jids]
817
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
152
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
153
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
154 class Pipe(base.CommandBase):
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
155 subcommands = (PipeOut, PipeIn)
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
156
c39117d00f35 jp: refactoring:
Goffi <goffi@goffi.org>
parents: 815
diff changeset
157 def __init__(self, host):
2624
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
158 super(Pipe, self).__init__(
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
159 host, "pipe", use_profile=False, help=_("stream piping through XMPP")
56f94936df1e code style reformatting using black
Goffi <goffi@goffi.org>
parents: 2562
diff changeset
160 )