Mercurial > libervia-backend
annotate sat_frontends/jp/cmd_file.py @ 3961:a15c171836bb
plugin pubsub signing: fix `gpg_provider` instanciation:
the instance was set at the class level while it is client dependant, resulting in the
instance being overwritten on each client connexion.
rel 381
author | Goffi <goffi@goffi.org> |
---|---|
date | Sun, 30 Oct 2022 01:06:35 +0200 |
parents | 1877c5c477ec |
children | 4c3361e2bf55 |
rev | line source |
---|---|
3137 | 1 #!/usr/bin/env python3 |
2 | |
815 | 3 |
4 # jp: a SAT command line tool | |
3479 | 5 # Copyright (C) 2009-2021 Jérôme Poisson (goffi@goffi.org) |
815 | 6 |
7 # This program is free software: you can redistribute it and/or modify | |
8 # it under the terms of the GNU Affero General Public License as published by | |
9 # the Free Software Foundation, either version 3 of the License, or | |
10 # (at your option) any later version. | |
11 | |
12 # This program is distributed in the hope that it will be useful, | |
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 # GNU Affero General Public License for more details. | |
16 | |
17 # You should have received a copy of the GNU Affero General Public License | |
18 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
19 | |
0 | 20 |
3028 | 21 from . import base |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
22 from . import xmlui_manager |
814 | 23 import sys |
24 import os | |
25 import os.path | |
26 import tarfile | |
771 | 27 from sat.core.i18n import _ |
2932
472fadadefe6
jp (file/invite): added a --thumbnail argument
Goffi <goffi@goffi.org>
parents:
2916
diff
changeset
|
28 from sat.tools.common import data_format |
1606
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
29 from sat_frontends.jp.constants import Const as C |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
30 from sat_frontends.jp import common |
1606
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
31 from sat_frontends.tools import jid |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
32 from sat.tools.common.ansi import ANSI as A |
3524
584379473925
tools (common/utils): new methods to parse and generate file size with symbols:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
33 from sat.tools.common import utils |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
34 from urllib.parse import urlparse |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
35 from pathlib import Path |
1606
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
36 import tempfile |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
37 import xml.etree.ElementTree as ET # FIXME: used temporarily to manage XMLUI |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
38 import json |
402
f03688bdb858
jp: use with statement to open fifo
Goffi <goffi@goffi.org>
parents:
401
diff
changeset
|
39 |
817 | 40 __commands__ = ["File"] |
3926
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
41 DEFAULT_DEST = "downloaded_file" |
0 | 42 |
1606
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
43 |
817 | 44 class Send(base.CommandBase): |
45 def __init__(self, host): | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
46 super(Send, self).__init__( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
47 host, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
48 "send", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
49 use_progress=True, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
50 use_verbose=True, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
51 help=_("send a file to a contact"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
52 ) |
0 | 53 |
817 | 54 def add_parser_options(self): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
55 self.parser.add_argument( |
3028 | 56 "files", type=str, nargs="+", metavar="file", help=_("a list of file") |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
57 ) |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
58 self.parser.add_argument("jid", help=_("the destination jid")) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
59 self.parser.add_argument( |
3028 | 60 "-b", "--bz2", action="store_true", help=_("make a bzip2 tarball") |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
61 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
62 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
63 "-d", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
64 "--path", |
3028 | 65 help=("path to the directory where the file must be stored"), |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
66 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
67 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
68 "-N", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
69 "--namespace", |
3028 | 70 help=("namespace of the file"), |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
71 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
72 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
73 "-n", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
74 "--name", |
3028 | 75 default="", |
76 help=("name to use (DEFAULT: use source file name)"), | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
77 ) |
0 | 78 |
3040 | 79 async def onProgressStarted(self, metadata): |
3028 | 80 self.disp(_("File copy started"), 2) |
1627
5a641e7b858a
jp (base, file): use of new progress API. Progress callbacks are managed through CommandBase.onProgress* method instead of host attributes.
Goffi <goffi@goffi.org>
parents:
1621
diff
changeset
|
81 |
3040 | 82 async def onProgressFinished(self, metadata): |
3028 | 83 self.disp(_("File sent successfully"), 2) |
1627
5a641e7b858a
jp (base, file): use of new progress API. Progress callbacks are managed through CommandBase.onProgress* method instead of host attributes.
Goffi <goffi@goffi.org>
parents:
1621
diff
changeset
|
84 |
3040 | 85 async def onProgressError(self, error_msg): |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
86 if error_msg == C.PROGRESS_ERROR_DECLINED: |
3028 | 87 self.disp(_("The file has been refused by your contact")) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
88 else: |
3028 | 89 self.disp(_("Error while sending file: {}").format(error_msg), error=True) |
1627
5a641e7b858a
jp (base, file): use of new progress API. Progress callbacks are managed through CommandBase.onProgress* method instead of host attributes.
Goffi <goffi@goffi.org>
parents:
1621
diff
changeset
|
90 |
3040 | 91 async def gotId(self, data, file_): |
1606
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
92 """Called when a progress id has been received |
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
93 |
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
94 @param pid(unicode): progress id |
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
95 @param file_(str): file path |
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
96 """ |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
97 # FIXME: this show progress only for last progress_id |
3408
19bc03743aeb
jp (file/send): don't add main resource to bare jid anymore:
Goffi <goffi@goffi.org>
parents:
3325
diff
changeset
|
98 self.disp(_("File request sent to {jid}".format(jid=self.args.jid)), 1) |
1621
a17a91531fbe
jp (file): print a message and quit if progress_id is not received
Goffi <goffi@goffi.org>
parents:
1606
diff
changeset
|
99 try: |
3040 | 100 await self.set_progress_id(data["progress"]) |
1621
a17a91531fbe
jp (file): print a message and quit if progress_id is not received
Goffi <goffi@goffi.org>
parents:
1606
diff
changeset
|
101 except KeyError: |
a17a91531fbe
jp (file): print a message and quit if progress_id is not received
Goffi <goffi@goffi.org>
parents:
1606
diff
changeset
|
102 # TODO: if 'xmlui' key is present, manage xmlui message display |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
103 self.disp(_("Can't send file to {jid}".format(jid=self.args.jid)), error=True) |
1621
a17a91531fbe
jp (file): print a message and quit if progress_id is not received
Goffi <goffi@goffi.org>
parents:
1606
diff
changeset
|
104 self.host.quit(2) |
1606
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
105 |
3040 | 106 async def start(self): |
817 | 107 for file_ in self.args.files: |
108 if not os.path.exists(file_): | |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
109 self.disp( |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
110 _("file {file_} doesn't exist!").format(file_=repr(file_)), error=True |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
111 ) |
3040 | 112 self.host.quit(C.EXIT_BAD_ARG) |
817 | 113 if not self.args.bz2 and os.path.isdir(file_): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
114 self.disp( |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
115 _( |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
116 "{file_} is a dir! Please send files inside or use compression" |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
117 ).format(file_=repr(file_)) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
118 ) |
3040 | 119 self.host.quit(C.EXIT_BAD_ARG) |
817 | 120 |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
121 extra = {} |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
122 if self.args.path: |
3028 | 123 extra["path"] = self.args.path |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
124 if self.args.namespace: |
3028 | 125 extra["namespace"] = self.args.namespace |
817 | 126 |
127 if self.args.bz2: | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
128 with tempfile.NamedTemporaryFile("wb", delete=False) as buf: |
1606
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
129 self.host.addOnQuitCallback(os.unlink, buf.name) |
3028 | 130 self.disp(_("bz2 is an experimental option, use with caution")) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
131 # FIXME: check free space |
3028 | 132 self.disp(_("Starting compression, please wait...")) |
1606
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
133 sys.stdout.flush() |
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
134 bz2 = tarfile.open(mode="w:bz2", fileobj=buf) |
3028 | 135 archive_name = "{}.tar.bz2".format( |
136 os.path.basename(self.args.files[0]) or "compressed_files" | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
137 ) |
1606
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
138 for file_ in self.args.files: |
3028 | 139 self.disp(_("Adding {}").format(file_), 1) |
1606
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
140 bz2.add(file_) |
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
141 bz2.close() |
3028 | 142 self.disp(_("Done !"), 1) |
1606
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
143 |
3040 | 144 try: |
145 send_data = await self.host.bridge.fileSend( | |
3408
19bc03743aeb
jp (file/send): don't add main resource to bare jid anymore:
Goffi <goffi@goffi.org>
parents:
3325
diff
changeset
|
146 self.args.jid, |
3040 | 147 buf.name, |
148 self.args.name or archive_name, | |
149 "", | |
150 extra, | |
151 self.profile, | |
152 ) | |
153 except Exception as e: | |
154 self.disp(f"can't send file: {e}", error=True) | |
155 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
156 else: | |
157 await self.gotId(send_data, file_) | |
0 | 158 else: |
817 | 159 for file_ in self.args.files: |
160 path = os.path.abspath(file_) | |
3040 | 161 try: |
162 send_data = await self.host.bridge.fileSend( | |
3408
19bc03743aeb
jp (file/send): don't add main resource to bare jid anymore:
Goffi <goffi@goffi.org>
parents:
3325
diff
changeset
|
163 self.args.jid, |
3040 | 164 path, |
165 self.args.name, | |
166 "", | |
167 extra, | |
168 self.profile, | |
169 ) | |
170 except Exception as e: | |
171 self.disp(f"can't send file {file_!r}: {e}", error=True) | |
172 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
173 else: | |
174 await self.gotId(send_data, file_) | |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
175 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
176 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
177 class Request(base.CommandBase): |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
178 def __init__(self, host): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
179 super(Request, self).__init__( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
180 host, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
181 "request", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
182 use_progress=True, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
183 use_verbose=True, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
184 help=_("request a file from a contact"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
185 ) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
186 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
187 @property |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
188 def filename(self): |
3028 | 189 return self.args.name or self.args.hash or "output" |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
190 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
191 def add_parser_options(self): |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
192 self.parser.add_argument("jid", help=_("the destination jid")) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
193 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
194 "-D", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
195 "--dest", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
196 help=_( |
3040 | 197 "destination path where the file will be saved (default: " |
198 "[current_dir]/[name|hash])" | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
199 ), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
200 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
201 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
202 "-n", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
203 "--name", |
3028 | 204 default="", |
205 help=_("name of the file"), | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
206 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
207 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
208 "-H", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
209 "--hash", |
3028 | 210 default="", |
211 help=_("hash of the file"), | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
212 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
213 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
214 "-a", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
215 "--hash-algo", |
3028 | 216 default="sha-256", |
217 help=_("hash algorithm use for --hash (default: sha-256)"), | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
218 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
219 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
220 "-d", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
221 "--path", |
3028 | 222 help=("path to the directory containing the file"), |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
223 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
224 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
225 "-N", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
226 "--namespace", |
3028 | 227 help=("namespace of the file"), |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
228 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
229 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
230 "-f", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
231 "--force", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
232 action="store_true", |
3028 | 233 help=_("overwrite existing file without confirmation"), |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
234 ) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
235 |
3040 | 236 async def onProgressStarted(self, metadata): |
3028 | 237 self.disp(_("File copy started"), 2) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
238 |
3040 | 239 async def onProgressFinished(self, metadata): |
3028 | 240 self.disp(_("File received successfully"), 2) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
241 |
3040 | 242 async def onProgressError(self, error_msg): |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
243 if error_msg == C.PROGRESS_ERROR_DECLINED: |
3028 | 244 self.disp(_("The file request has been refused")) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
245 else: |
3028 | 246 self.disp(_("Error while requesting file: {}").format(error_msg), error=True) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
247 |
3040 | 248 async def start(self): |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
249 if not self.args.name and not self.args.hash: |
3028 | 250 self.parser.error(_("at least one of --name or --hash must be provided")) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
251 if self.args.dest: |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
252 path = os.path.abspath(os.path.expanduser(self.args.dest)) |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
253 if os.path.isdir(path): |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
254 path = os.path.join(path, self.filename) |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
255 else: |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
256 path = os.path.abspath(self.filename) |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
257 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
258 if os.path.exists(path) and not self.args.force: |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
259 message = _("File {path} already exists! Do you want to overwrite?").format( |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
260 path=path |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
261 ) |
3040 | 262 await self.host.confirmOrQuit(message, _("file request cancelled")) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
263 |
3040 | 264 self.full_dest_jid = await self.host.get_full_jid(self.args.jid) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
265 extra = {} |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
266 if self.args.path: |
3028 | 267 extra["path"] = self.args.path |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
268 if self.args.namespace: |
3028 | 269 extra["namespace"] = self.args.namespace |
3040 | 270 try: |
271 progress_id = await self.host.bridge.fileJingleRequest( | |
272 self.full_dest_jid, | |
273 path, | |
274 self.args.name, | |
275 self.args.hash, | |
276 self.args.hash_algo if self.args.hash else "", | |
277 extra, | |
278 self.profile, | |
279 ) | |
280 except Exception as e: | |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
281 self.disp(msg=_("can't request file: {e}").format(e=e), error=True) |
3040 | 282 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
283 else: | |
284 await self.set_progress_id(progress_id) | |
587
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
285 |
952322b1d490
Remove trailing whitespaces.
Emmanuel Gil Peyrot <linkmauve@linkmauve.fr>
parents:
572
diff
changeset
|
286 |
817 | 287 class Receive(base.CommandAnswering): |
288 def __init__(self, host): | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
289 super(Receive, self).__init__( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
290 host, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
291 "receive", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
292 use_progress=True, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
293 use_verbose=True, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
294 help=_("wait for a file to be sent by a contact"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
295 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
296 self._overwrite_refused = False # True when one overwrite as already been refused |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
297 self.action_callbacks = { |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
298 C.META_TYPE_FILE: self.onFileAction, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
299 C.META_TYPE_OVERWRITE: self.onOverwriteAction, |
3410
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
300 C.META_TYPE_NOT_IN_ROSTER_LEAK: self.onNotInRosterAction, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
301 } |
1606
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
302 |
817 | 303 def add_parser_options(self): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
304 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
305 "jids", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
306 nargs="*", |
3028 | 307 help=_("jids accepted (accept everything if none is specified)"), |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
308 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
309 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
310 "-m", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
311 "--multiple", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
312 action="store_true", |
3028 | 313 help=_("accept multiple files (you'll have to stop manually)"), |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
314 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
315 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
316 "-f", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
317 "--force", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
318 action="store_true", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
319 help=_( |
3028 | 320 "force overwritting of existing files (/!\\ name is choosed by sender)" |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
321 ), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
322 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
323 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
324 "--path", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
325 default=".", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
326 metavar="DIR", |
3028 | 327 help=_("destination path (default: working directory)"), |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
328 ) |
817 | 329 |
3040 | 330 async def onProgressStarted(self, metadata): |
331 self.disp(_("File copy started"), 2) | |
332 | |
333 async def onProgressFinished(self, metadata): | |
334 self.disp(_("File received successfully"), 2) | |
335 if metadata.get("hash_verified", False): | |
336 try: | |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
337 self.disp( |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
338 _("hash checked: {metadata['hash_algo']}:{metadata['hash']}"), 1 |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
339 ) |
3040 | 340 except KeyError: |
341 self.disp(_("hash is checked but hash value is missing", 1), error=True) | |
342 else: | |
343 self.disp(_("hash can't be verified"), 1) | |
344 | |
345 async def onProgressError(self, e): | |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
346 self.disp(_("Error while receiving file: {e}").format(e=e), error=True) |
3040 | 347 |
348 def getXmluiId(self, action_data): | |
349 # FIXME: we temporarily use ElementTree, but a real XMLUI managing module | |
350 # should be available in the futur | |
351 # TODO: XMLUI module | |
352 try: | |
353 xml_ui = action_data["xmlui"] | |
354 except KeyError: | |
355 self.disp(_("Action has no XMLUI"), 1) | |
356 else: | |
357 ui = ET.fromstring(xml_ui.encode("utf-8")) | |
358 xmlui_id = ui.get("submit") | |
359 if not xmlui_id: | |
360 self.disp(_("Invalid XMLUI received"), error=True) | |
361 return xmlui_id | |
362 | |
363 async def onFileAction(self, action_data, action_id, security_limit, profile): | |
364 xmlui_id = self.getXmluiId(action_data) | |
365 if xmlui_id is None: | |
366 return self.host.quitFromSignal(1) | |
367 try: | |
368 from_jid = jid.JID(action_data["meta_from_jid"]) | |
369 except KeyError: | |
370 self.disp(_("Ignoring action without from_jid data"), 1) | |
371 return | |
372 try: | |
373 progress_id = action_data["meta_progress_id"] | |
374 except KeyError: | |
375 self.disp(_("ignoring action without progress id"), 1) | |
376 return | |
377 | |
378 if not self.bare_jids or from_jid.bare in self.bare_jids: | |
379 if self._overwrite_refused: | |
380 self.disp(_("File refused because overwrite is needed"), error=True) | |
381 await self.host.bridge.launchAction( | |
382 xmlui_id, {"cancelled": C.BOOL_TRUE}, profile_key=profile | |
383 ) | |
384 return self.host.quitFromSignal(2) | |
385 await self.set_progress_id(progress_id) | |
386 xmlui_data = {"path": self.path} | |
387 await self.host.bridge.launchAction(xmlui_id, xmlui_data, profile_key=profile) | |
388 | |
389 async def onOverwriteAction(self, action_data, action_id, security_limit, profile): | |
390 xmlui_id = self.getXmluiId(action_data) | |
391 if xmlui_id is None: | |
392 return self.host.quitFromSignal(1) | |
393 try: | |
394 progress_id = action_data["meta_progress_id"] | |
395 except KeyError: | |
396 self.disp(_("ignoring action without progress id"), 1) | |
397 return | |
398 self.disp(_("Overwriting needed"), 1) | |
399 | |
400 if progress_id == self.progress_id: | |
401 if self.args.force: | |
402 self.disp(_("Overwrite accepted"), 2) | |
403 else: | |
404 self.disp(_("Refused to overwrite"), 2) | |
405 self._overwrite_refused = True | |
406 | |
407 xmlui_data = {"answer": C.boolConst(self.args.force)} | |
408 await self.host.bridge.launchAction(xmlui_id, xmlui_data, profile_key=profile) | |
409 | |
3410
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
410 async def onNotInRosterAction(self, action_data, action_id, security_limit, profile): |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
411 xmlui_id = self.getXmluiId(action_data) |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
412 if xmlui_id is None: |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
413 return self.host.quitFromSignal(1) |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
414 try: |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
415 from_jid = jid.JID(action_data["meta_from_jid"]) |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
416 except ValueError: |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
417 self.disp( |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
418 _('invalid "from_jid" value received, ignoring: {value}').format( |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
419 value=from_jid |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
420 ), |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
421 error=True, |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
422 ) |
3410
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
423 return |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
424 except KeyError: |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
425 self.disp(_('ignoring action without "from_jid" value'), error=True) |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
426 return |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
427 self.disp(_("Confirmation needed for request from an entity not in roster"), 1) |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
428 |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
429 if from_jid.bare in self.bare_jids: |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
430 # if the sender is expected, we can confirm the session |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
431 confirmed = True |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
432 self.disp(_("Sender confirmed because she or he is explicitly expected"), 1) |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
433 else: |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
434 xmlui = xmlui_manager.create(self.host, action_data["xmlui"]) |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
435 confirmed = await self.host.confirm(xmlui.dlg.message) |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
436 |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
437 xmlui_data = {"answer": C.boolConst(confirmed)} |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
438 await self.host.bridge.launchAction(xmlui_id, xmlui_data, profile_key=profile) |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
439 if not confirmed and not self.args.multiple: |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
440 self.disp(_("Session refused for {from_jid}").format(from_jid=from_jid)) |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
441 self.host.quitFromSignal(0) |
55f9a38864af
jp (file/receive): display or answer to C.META_TYPE_NOT_IN_ROSTER_LEAK dialog:
Goffi <goffi@goffi.org>
parents:
3408
diff
changeset
|
442 |
3040 | 443 async def start(self): |
1606
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
444 self.bare_jids = [jid.JID(jid_).bare for jid_ in self.args.jids] |
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
445 self.path = os.path.abspath(self.args.path) |
de785fcf9a7b
jp (base, file): file command and progress fixes and adaptation to new API:
Goffi <goffi@goffi.org>
parents:
1396
diff
changeset
|
446 if not os.path.isdir(self.path): |
3028 | 447 self.disp(_("Given path is not a directory !", error=True)) |
3040 | 448 self.host.quit(C.EXIT_BAD_ARG) |
817 | 449 if self.args.multiple: |
450 self.host.quit_on_progress_end = False | |
3028 | 451 self.disp(_("waiting for incoming file request"), 2) |
3040 | 452 await self.start_answering() |
817 | 453 |
454 | |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
455 class Get(base.CommandBase): |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
456 def __init__(self, host): |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
457 super(Get, self).__init__( |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
458 host, |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
459 "get", |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
460 use_progress=True, |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
461 use_verbose=True, |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
462 help=_("download a file from URI"), |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
463 ) |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
464 |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
465 def add_parser_options(self): |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
466 self.parser.add_argument( |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
467 "-o", |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
468 "--dest-file", |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
469 type=str, |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
470 default="", |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
471 help=_("destination file (DEFAULT: filename from URL)"), |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
472 ) |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
473 self.parser.add_argument( |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
474 "-f", |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
475 "--force", |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
476 action="store_true", |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
477 help=_("overwrite existing file without confirmation"), |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
478 ) |
3926
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
479 self.parser.add_argument( |
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
480 "attachment", type=str, |
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
481 help=_("URI of the file to retrieve or JSON of the whole attachment") |
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
482 ) |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
483 |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
484 async def onProgressStarted(self, metadata): |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
485 self.disp(_("File download started"), 2) |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
486 |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
487 async def onProgressFinished(self, metadata): |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
488 self.disp(_("File downloaded successfully"), 2) |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
489 |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
490 async def onProgressError(self, error_msg): |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
491 self.disp(_("Error while downloading file: {}").format(error_msg), error=True) |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
492 |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
493 async def gotId(self, data): |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
494 """Called when a progress id has been received""" |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
495 try: |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
496 await self.set_progress_id(data["progress"]) |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
497 except KeyError: |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
498 if "xmlui" in data: |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
499 ui = xmlui_manager.create(self.host, data["xmlui"]) |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
500 await ui.show() |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
501 else: |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
502 self.disp(_("Can't download file"), error=True) |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
503 self.host.quit(C.EXIT_ERROR) |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
504 |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
505 async def start(self): |
3926
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
506 try: |
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
507 attachment = json.loads(self.args.attachment) |
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
508 except json.JSONDecodeError: |
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
509 attachment = {"uri": self.args.attachment} |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
510 dest_file = self.args.dest_file |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
511 if not dest_file: |
3926
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
512 try: |
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
513 dest_file = attachment["name"].replace("/", "-").strip() |
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
514 except KeyError: |
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
515 try: |
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
516 dest_file = Path(urlparse(attachment["uri"]).path).name.strip() |
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
517 except KeyError: |
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
518 pass |
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
519 if not dest_file: |
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
520 dest_file = "downloaded_file" |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
521 |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
522 dest_file = Path(dest_file).expanduser().resolve() |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
523 if dest_file.exists() and not self.args.force: |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
524 message = _("File {path} already exists! Do you want to overwrite?").format( |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
525 path=dest_file |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
526 ) |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
527 await self.host.confirmOrQuit(message, _("file download cancelled")) |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
528 |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
529 options = {} |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
530 |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
531 try: |
3926
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
532 download_data_s = await self.host.bridge.fileDownload( |
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
533 data_format.serialise(attachment), |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
534 str(dest_file), |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
535 data_format.serialise(options), |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
536 self.profile, |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
537 ) |
3926
1877c5c477ec
cli (file/get): handle full JSON attachment following change in backend:
Goffi <goffi@goffi.org>
parents:
3568
diff
changeset
|
538 download_data = data_format.deserialise(download_data_s) |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
539 except Exception as e: |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
540 self.disp(f"error while trying to download a file: {e}", error=True) |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
541 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
542 else: |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
543 await self.gotId(download_data) |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
544 |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
545 |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
546 class Upload(base.CommandBase): |
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
547 def __init__(self, host): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
548 super(Upload, self).__init__( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
549 host, "upload", use_progress=True, use_verbose=True, help=_("upload a file") |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
550 ) |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
551 |
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
552 def add_parser_options(self): |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
553 self.parser.add_argument( |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
554 "-e", |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
555 "--encrypt", |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
556 action="store_true", |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
557 help=_("encrypt file using AES-GCM"), |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
558 ) |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
559 self.parser.add_argument("file", type=str, help=_("file to upload")) |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
560 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
561 "jid", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
562 nargs="?", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
563 help=_("jid of upload component (nothing to autodetect)"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
564 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
565 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
566 "--ignore-tls-errors", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
567 action="store_true", |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
568 help=_(r"ignore invalide TLS certificate (/!\ Dangerous /!\)"), |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
569 ) |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
570 |
3040 | 571 async def onProgressStarted(self, metadata): |
3028 | 572 self.disp(_("File upload started"), 2) |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
573 |
3040 | 574 async def onProgressFinished(self, metadata): |
3028 | 575 self.disp(_("File uploaded successfully"), 2) |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
576 try: |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
577 url = metadata["url"] |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
578 except KeyError: |
3028 | 579 self.disp("download URL not found in metadata") |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
580 else: |
3028 | 581 self.disp(_("URL to retrieve the file:"), 1) |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
582 # XXX: url is displayed alone on a line to make parsing easier |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
583 self.disp(url) |
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
584 |
3040 | 585 async def onProgressError(self, error_msg): |
3028 | 586 self.disp(_("Error while uploading file: {}").format(error_msg), error=True) |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
587 |
3040 | 588 async def gotId(self, data, file_): |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
589 """Called when a progress id has been received |
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
590 |
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
591 @param pid(unicode): progress id |
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
592 @param file_(str): file path |
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
593 """ |
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
594 try: |
3040 | 595 await self.set_progress_id(data["progress"]) |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
596 except KeyError: |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
597 if "xmlui" in data: |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
598 ui = xmlui_manager.create(self.host, data["xmlui"]) |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
599 await ui.show() |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
600 else: |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
601 self.disp(_("Can't upload file"), error=True) |
3040 | 602 self.host.quit(C.EXIT_ERROR) |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
603 |
3040 | 604 async def start(self): |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
605 file_ = self.args.file |
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
606 if not os.path.exists(file_): |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
607 self.disp( |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
608 _("file {file_} doesn't exist !").format(file_=repr(file_)), error=True |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
609 ) |
3040 | 610 self.host.quit(C.EXIT_BAD_ARG) |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
611 if os.path.isdir(file_): |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
612 self.disp(_("{file_} is a dir! Can't upload a dir").format(file_=repr(file_))) |
3040 | 613 self.host.quit(C.EXIT_BAD_ARG) |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
614 |
3040 | 615 if self.args.jid is None: |
3068
e189ceca7e8b
jp (file/upload): fixed exception when no jid is specified
Goffi <goffi@goffi.org>
parents:
3040
diff
changeset
|
616 self.full_dest_jid = "" |
3040 | 617 else: |
618 self.full_dest_jid = await self.host.get_full_jid(self.args.jid) | |
619 | |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
620 options = {} |
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
621 if self.args.ignore_tls_errors: |
3089
e75024e41f81
plugin upload, XEP-0363: code modernisation + preparation for extension:
Goffi <goffi@goffi.org>
parents:
3068
diff
changeset
|
622 options["ignore_tls_errors"] = True |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
623 if self.args.encrypt: |
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
624 options["encryption"] = C.ENC_AES_GCM |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
625 |
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
626 path = os.path.abspath(file_) |
3040 | 627 try: |
628 upload_data = await self.host.bridge.fileUpload( | |
629 path, | |
630 "", | |
631 self.full_dest_jid, | |
3089
e75024e41f81
plugin upload, XEP-0363: code modernisation + preparation for extension:
Goffi <goffi@goffi.org>
parents:
3068
diff
changeset
|
632 data_format.serialise(options), |
3040 | 633 self.profile, |
634 ) | |
635 except Exception as e: | |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
636 self.disp(f"error while trying to upload a file: {e}", error=True) |
3040 | 637 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
638 else: | |
639 await self.gotId(upload_data, file_) | |
1643
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
640 |
17f9b911899a
jp (file): new file/upload command
Goffi <goffi@goffi.org>
parents:
1627
diff
changeset
|
641 |
3325
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
642 class ShareAffiliationsSet(base.CommandBase): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
643 def __init__(self, host): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
644 super(ShareAffiliationsSet, self).__init__( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
645 host, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
646 "set", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
647 use_output=C.OUTPUT_DICT, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
648 help=_("set affiliations for a shared file/directory"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
649 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
650 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
651 def add_parser_options(self): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
652 self.parser.add_argument( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
653 "-N", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
654 "--namespace", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
655 default="", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
656 help=_("namespace of the repository"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
657 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
658 self.parser.add_argument( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
659 "-P", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
660 "--path", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
661 default="", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
662 help=_("path to the repository"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
663 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
664 self.parser.add_argument( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
665 "-a", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
666 "--affiliation", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
667 dest="affiliations", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
668 metavar=("JID", "AFFILIATION"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
669 required=True, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
670 action="append", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
671 nargs=2, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
672 help=_("entity/affiliation couple(s)"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
673 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
674 self.parser.add_argument( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
675 "jid", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
676 help=_("jid of file sharing entity"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
677 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
678 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
679 async def start(self): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
680 affiliations = dict(self.args.affiliations) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
681 try: |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
682 affiliations = await self.host.bridge.FISAffiliationsSet( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
683 self.args.jid, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
684 self.args.namespace, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
685 self.args.path, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
686 affiliations, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
687 self.profile, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
688 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
689 except Exception as e: |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
690 self.disp(f"can't set affiliations: {e}", error=True) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
691 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
692 else: |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
693 self.host.quit() |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
694 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
695 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
696 class ShareAffiliationsGet(base.CommandBase): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
697 def __init__(self, host): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
698 super(ShareAffiliationsGet, self).__init__( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
699 host, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
700 "get", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
701 use_output=C.OUTPUT_DICT, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
702 help=_("retrieve affiliations of a shared file/directory"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
703 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
704 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
705 def add_parser_options(self): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
706 self.parser.add_argument( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
707 "-N", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
708 "--namespace", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
709 default="", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
710 help=_("namespace of the repository"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
711 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
712 self.parser.add_argument( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
713 "-P", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
714 "--path", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
715 default="", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
716 help=_("path to the repository"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
717 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
718 self.parser.add_argument( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
719 "jid", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
720 help=_("jid of sharing entity"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
721 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
722 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
723 async def start(self): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
724 try: |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
725 affiliations = await self.host.bridge.FISAffiliationsGet( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
726 self.args.jid, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
727 self.args.namespace, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
728 self.args.path, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
729 self.profile, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
730 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
731 except Exception as e: |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
732 self.disp(f"can't get affiliations: {e}", error=True) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
733 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
734 else: |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
735 await self.output(affiliations) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
736 self.host.quit() |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
737 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
738 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
739 class ShareAffiliations(base.CommandBase): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
740 subcommands = (ShareAffiliationsGet, ShareAffiliationsSet) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
741 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
742 def __init__(self, host): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
743 super(ShareAffiliations, self).__init__( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
744 host, "affiliations", use_profile=False, help=_("affiliations management") |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
745 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
746 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
747 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
748 class ShareConfigurationSet(base.CommandBase): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
749 def __init__(self, host): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
750 super(ShareConfigurationSet, self).__init__( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
751 host, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
752 "set", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
753 use_output=C.OUTPUT_DICT, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
754 help=_("set configuration for a shared file/directory"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
755 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
756 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
757 def add_parser_options(self): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
758 self.parser.add_argument( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
759 "-N", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
760 "--namespace", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
761 default="", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
762 help=_("namespace of the repository"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
763 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
764 self.parser.add_argument( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
765 "-P", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
766 "--path", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
767 default="", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
768 help=_("path to the repository"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
769 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
770 self.parser.add_argument( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
771 "-f", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
772 "--field", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
773 action="append", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
774 nargs=2, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
775 dest="fields", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
776 required=True, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
777 metavar=("KEY", "VALUE"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
778 help=_("configuration field to set (required)"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
779 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
780 self.parser.add_argument( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
781 "jid", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
782 help=_("jid of file sharing entity"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
783 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
784 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
785 async def start(self): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
786 configuration = dict(self.args.fields) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
787 try: |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
788 configuration = await self.host.bridge.FISConfigurationSet( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
789 self.args.jid, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
790 self.args.namespace, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
791 self.args.path, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
792 configuration, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
793 self.profile, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
794 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
795 except Exception as e: |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
796 self.disp(f"can't set configuration: {e}", error=True) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
797 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
798 else: |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
799 self.host.quit() |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
800 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
801 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
802 class ShareConfigurationGet(base.CommandBase): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
803 def __init__(self, host): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
804 super(ShareConfigurationGet, self).__init__( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
805 host, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
806 "get", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
807 use_output=C.OUTPUT_DICT, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
808 help=_("retrieve configuration of a shared file/directory"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
809 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
810 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
811 def add_parser_options(self): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
812 self.parser.add_argument( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
813 "-N", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
814 "--namespace", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
815 default="", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
816 help=_("namespace of the repository"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
817 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
818 self.parser.add_argument( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
819 "-P", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
820 "--path", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
821 default="", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
822 help=_("path to the repository"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
823 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
824 self.parser.add_argument( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
825 "jid", |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
826 help=_("jid of sharing entity"), |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
827 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
828 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
829 async def start(self): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
830 try: |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
831 configuration = await self.host.bridge.FISConfigurationGet( |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
832 self.args.jid, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
833 self.args.namespace, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
834 self.args.path, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
835 self.profile, |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
836 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
837 except Exception as e: |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
838 self.disp(f"can't get configuration: {e}", error=True) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
839 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
840 else: |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
841 await self.output(configuration) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
842 self.host.quit() |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
843 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
844 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
845 class ShareConfiguration(base.CommandBase): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
846 subcommands = (ShareConfigurationGet, ShareConfigurationSet) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
847 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
848 def __init__(self, host): |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
849 super(ShareConfiguration, self).__init__( |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
850 host, |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
851 "configuration", |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
852 use_profile=False, |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
853 help=_("file sharing node configuration"), |
3325
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
854 ) |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
855 |
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
856 |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
857 class ShareList(base.CommandBase): |
817 | 858 def __init__(self, host): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
859 extra_outputs = {"default": self.default_output} |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
860 super(ShareList, self).__init__( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
861 host, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
862 "list", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
863 use_output=C.OUTPUT_LIST_DICT, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
864 extra_outputs=extra_outputs, |
3028 | 865 help=_("retrieve files shared by an entity"), |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
866 use_verbose=True, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
867 ) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
868 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
869 def add_parser_options(self): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
870 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
871 "-d", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
872 "--path", |
3028 | 873 default="", |
874 help=_("path to the directory containing the files"), | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
875 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
876 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
877 "jid", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
878 nargs="?", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
879 default="", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
880 help=_("jid of sharing entity (nothing to check our own jid)"), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
881 ) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
882 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
883 def _name_filter(self, name, row): |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
884 if row.type == C.FILE_TYPE_DIRECTORY: |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
885 return A.color(C.A_DIRECTORY, name) |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
886 elif row.type == C.FILE_TYPE_FILE: |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
887 return A.color(C.A_FILE, name) |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
888 else: |
3028 | 889 self.disp(_("unknown file type: {type}").format(type=row.type), error=True) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
890 return name |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
891 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
892 def _size_filter(self, size, row): |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
893 if not size: |
3028 | 894 return "" |
3524
584379473925
tools (common/utils): new methods to parse and generate file size with symbols:
Goffi <goffi@goffi.org>
parents:
3479
diff
changeset
|
895 return A.color(A.BOLD, utils.getHumanSize(size)) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
896 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
897 def default_output(self, files_data): |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
898 """display files a way similar to ls""" |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
899 files_data.sort(key=lambda d: d["name"].lower()) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
900 show_header = False |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
901 if self.verbosity == 0: |
3040 | 902 keys = headers = ("name", "type") |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
903 elif self.verbosity == 1: |
3040 | 904 keys = headers = ("name", "type", "size") |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
905 elif self.verbosity > 1: |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
906 show_header = True |
3040 | 907 keys = ("name", "type", "size", "file_hash") |
3028 | 908 headers = ("name", "type", "size", "hash") |
3121 | 909 table = common.Table.fromListDict( |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
910 self.host, |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
911 files_data, |
3040 | 912 keys=keys, |
913 headers=headers, | |
3028 | 914 filters={"name": self._name_filter, "size": self._size_filter}, |
3040 | 915 defaults={"size": "", "file_hash": ""}, |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
916 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
917 table.display_blank(show_header=show_header, hide_cols=["type"]) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
918 |
3040 | 919 async def start(self): |
920 try: | |
921 files_data = await self.host.bridge.FISList( | |
922 self.args.jid, | |
923 self.args.path, | |
924 {}, | |
925 self.profile, | |
926 ) | |
927 except Exception as e: | |
928 self.disp(f"can't retrieve shared files: {e}", error=True) | |
929 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
930 |
3040 | 931 await self.output(files_data) |
932 self.host.quit() | |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
933 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
934 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
935 class SharePath(base.CommandBase): |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
936 def __init__(self, host): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
937 super(SharePath, self).__init__( |
3028 | 938 host, "path", help=_("share a file or directory"), use_verbose=True |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
939 ) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
940 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
941 def add_parser_options(self): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
942 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
943 "-n", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
944 "--name", |
3028 | 945 default="", |
946 help=_("virtual name to use (default: use directory/file name)"), | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
947 ) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
948 perm_group = self.parser.add_mutually_exclusive_group() |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
949 perm_group.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
950 "-j", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
951 "--jid", |
3040 | 952 metavar="JID", |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
953 action="append", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
954 dest="jids", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
955 default=[], |
3028 | 956 help=_("jid of contacts allowed to retrieve the files"), |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
957 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
958 perm_group.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
959 "--public", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
960 action="store_true", |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
961 help=_( |
3040 | 962 r"share publicly the file(s) (/!\ *everybody* will be able to access " |
963 r"them)" | |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
964 ), |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
965 ) |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
966 self.parser.add_argument( |
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
967 "path", |
3028 | 968 help=_("path to a file or directory to share"), |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
969 ) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
970 |
3040 | 971 async def start(self): |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
972 self.path = os.path.abspath(self.args.path) |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
973 if self.args.public: |
3028 | 974 access = {"read": {"type": "public"}} |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
975 else: |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
976 jids = self.args.jids |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
977 if jids: |
3028 | 978 access = {"read": {"type": "whitelist", "jids": jids}} |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
979 else: |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
980 access = {} |
3040 | 981 try: |
982 name = await self.host.bridge.FISSharePath( | |
983 self.args.name, | |
984 self.path, | |
985 json.dumps(access, ensure_ascii=False), | |
986 self.profile, | |
987 ) | |
988 except Exception as e: | |
989 self.disp(f"can't share path: {e}", error=True) | |
990 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
991 else: | |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
992 self.disp( |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
993 _('{path} shared under the name "{name}"').format( |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
994 path=self.path, name=name |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
995 ) |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
996 ) |
3040 | 997 self.host.quit() |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
998 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
999 |
2916
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1000 class ShareInvite(base.CommandBase): |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1001 def __init__(self, host): |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1002 super(ShareInvite, self).__init__( |
3028 | 1003 host, "invite", help=_("send invitation for a shared repository") |
2916
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1004 ) |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1005 |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1006 def add_parser_options(self): |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1007 self.parser.add_argument( |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1008 "-n", |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1009 "--name", |
3028 | 1010 default="", |
1011 help=_("name of the repository"), | |
2916
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1012 ) |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1013 self.parser.add_argument( |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1014 "-N", |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1015 "--namespace", |
3028 | 1016 default="", |
1017 help=_("namespace of the repository"), | |
2916
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1018 ) |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1019 self.parser.add_argument( |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1020 "-P", |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1021 "--path", |
3028 | 1022 help=_("path to the repository"), |
2916
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1023 ) |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1024 self.parser.add_argument( |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1025 "-t", |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1026 "--type", |
3028 | 1027 choices=["files", "photos"], |
1028 default="files", | |
1029 help=_("type of the repository"), | |
2916
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1030 ) |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1031 self.parser.add_argument( |
2932
472fadadefe6
jp (file/invite): added a --thumbnail argument
Goffi <goffi@goffi.org>
parents:
2916
diff
changeset
|
1032 "-T", |
472fadadefe6
jp (file/invite): added a --thumbnail argument
Goffi <goffi@goffi.org>
parents:
2916
diff
changeset
|
1033 "--thumbnail", |
3028 | 1034 help=_("https URL of a image to use as thumbnail"), |
2932
472fadadefe6
jp (file/invite): added a --thumbnail argument
Goffi <goffi@goffi.org>
parents:
2916
diff
changeset
|
1035 ) |
472fadadefe6
jp (file/invite): added a --thumbnail argument
Goffi <goffi@goffi.org>
parents:
2916
diff
changeset
|
1036 self.parser.add_argument( |
2916
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1037 "service", |
3028 | 1038 help=_("jid of the file sharing service hosting the repository"), |
2916
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1039 ) |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1040 self.parser.add_argument( |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1041 "jid", |
3028 | 1042 help=_("jid of the person to invite"), |
2916
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1043 ) |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1044 |
3040 | 1045 async def start(self): |
3028 | 1046 self.path = os.path.normpath(self.args.path) if self.args.path else "" |
2932
472fadadefe6
jp (file/invite): added a --thumbnail argument
Goffi <goffi@goffi.org>
parents:
2916
diff
changeset
|
1047 extra = {} |
472fadadefe6
jp (file/invite): added a --thumbnail argument
Goffi <goffi@goffi.org>
parents:
2916
diff
changeset
|
1048 if self.args.thumbnail is not None: |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
1049 if not self.args.thumbnail.startswith("http"): |
3028 | 1050 self.parser.error(_("only http(s) links are allowed with --thumbnail")) |
2932
472fadadefe6
jp (file/invite): added a --thumbnail argument
Goffi <goffi@goffi.org>
parents:
2916
diff
changeset
|
1051 else: |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
1052 extra["thumb_url"] = self.args.thumbnail |
3040 | 1053 try: |
1054 await self.host.bridge.FISInvite( | |
1055 self.args.jid, | |
1056 self.args.service, | |
1057 self.args.type, | |
1058 self.args.namespace, | |
1059 self.path, | |
1060 self.args.name, | |
1061 data_format.serialise(extra), | |
1062 self.profile, | |
1063 ) | |
1064 except Exception as e: | |
1065 self.disp(f"can't send invitation: {e}", error=True) | |
1066 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | |
1067 else: | |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
1068 self.disp(_("invitation sent to {jid}").format(jid=self.args.jid)) |
3040 | 1069 self.host.quit() |
2916
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1070 |
0b9faea5cb58
jp (file/share): added invite command to invite an entity to a file sharing repository
Goffi <goffi@goffi.org>
parents:
2771
diff
changeset
|
1071 |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
1072 class Share(base.CommandBase): |
3325
7ebda4b54170
jp (file/share): added commands to manage affiliations and configuration + documentation
Goffi <goffi@goffi.org>
parents:
3137
diff
changeset
|
1073 subcommands = ( |
3568
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
1074 ShareList, |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
1075 SharePath, |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
1076 ShareInvite, |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
1077 ShareAffiliations, |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
1078 ShareConfiguration, |
04283582966f
core, frontends: fix invalid translatable strings.
Goffi <goffi@goffi.org>
parents:
3524
diff
changeset
|
1079 ) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
1080 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
1081 def __init__(self, host): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
1082 super(Share, self).__init__( |
3028 | 1083 host, "share", use_profile=False, help=_("files sharing management") |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
1084 ) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
1085 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
1086 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
1087 class File(base.CommandBase): |
3094
c3cb18236bdf
jp (file): new `get` command + encryption with upload:
Goffi <goffi@goffi.org>
parents:
3089
diff
changeset
|
1088 subcommands = (Send, Request, Receive, Get, Upload, Share) |
2505
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
1089 |
8e770ac05b0c
jp (file): file sharing + improvments:
Goffi <goffi@goffi.org>
parents:
2483
diff
changeset
|
1090 def __init__(self, host): |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
1091 super(File, self).__init__( |
3028 | 1092 host, "file", use_profile=False, help=_("files sending/receiving/management") |
2624
56f94936df1e
code style reformatting using black
Goffi <goffi@goffi.org>
parents:
2592
diff
changeset
|
1093 ) |