Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_file.py @ 3970:4c3361e2bf55
cli (file/send): add `--encrypt` argument to request encryption:
rel 378
author | Goffi <goffi@goffi.org> |
---|---|
date | Mon, 31 Oct 2022 04:09:38 +0100 |
parents | 1877c5c477ec |
children | 524856bd7b19 |
comparison
equal
deleted
inserted
replaced
3969:8e7d5796fb23 | 3970:4c3361e2bf55 |
---|---|
73 "-n", | 73 "-n", |
74 "--name", | 74 "--name", |
75 default="", | 75 default="", |
76 help=("name to use (DEFAULT: use source file name)"), | 76 help=("name to use (DEFAULT: use source file name)"), |
77 ) | 77 ) |
78 self.parser.add_argument( | |
79 "-e", | |
80 "--encrypt", | |
81 action="store_true", | |
82 help=_("end-to-end encrypt the file transfer") | |
83 ) | |
78 | 84 |
79 async def onProgressStarted(self, metadata): | 85 async def onProgressStarted(self, metadata): |
80 self.disp(_("File copy started"), 2) | 86 self.disp(_("File copy started"), 2) |
81 | 87 |
82 async def onProgressFinished(self, metadata): | 88 async def onProgressFinished(self, metadata): |
121 extra = {} | 127 extra = {} |
122 if self.args.path: | 128 if self.args.path: |
123 extra["path"] = self.args.path | 129 extra["path"] = self.args.path |
124 if self.args.namespace: | 130 if self.args.namespace: |
125 extra["namespace"] = self.args.namespace | 131 extra["namespace"] = self.args.namespace |
132 if self.args.encrypt: | |
133 extra["encrypted"] = True | |
126 | 134 |
127 if self.args.bz2: | 135 if self.args.bz2: |
128 with tempfile.NamedTemporaryFile("wb", delete=False) as buf: | 136 with tempfile.NamedTemporaryFile("wb", delete=False) as buf: |
129 self.host.addOnQuitCallback(os.unlink, buf.name) | 137 self.host.addOnQuitCallback(os.unlink, buf.name) |
130 self.disp(_("bz2 is an experimental option, use with caution")) | 138 self.disp(_("bz2 is an experimental option, use with caution")) |
145 send_data = await self.host.bridge.fileSend( | 153 send_data = await self.host.bridge.fileSend( |
146 self.args.jid, | 154 self.args.jid, |
147 buf.name, | 155 buf.name, |
148 self.args.name or archive_name, | 156 self.args.name or archive_name, |
149 "", | 157 "", |
150 extra, | 158 data_format.serialise(extra), |
151 self.profile, | 159 self.profile, |
152 ) | 160 ) |
153 except Exception as e: | 161 except Exception as e: |
154 self.disp(f"can't send file: {e}", error=True) | 162 self.disp(f"can't send file: {e}", error=True) |
155 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 163 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
162 send_data = await self.host.bridge.fileSend( | 170 send_data = await self.host.bridge.fileSend( |
163 self.args.jid, | 171 self.args.jid, |
164 path, | 172 path, |
165 self.args.name, | 173 self.args.name, |
166 "", | 174 "", |
167 extra, | 175 data_format.serialise(extra), |
168 self.profile, | 176 self.profile, |
169 ) | 177 ) |
170 except Exception as e: | 178 except Exception as e: |
171 self.disp(f"can't send file {file_!r}: {e}", error=True) | 179 self.disp(f"can't send file {file_!r}: {e}", error=True) |
172 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 180 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |