Mercurial > libervia-backend
comparison sat_frontends/jp/cmd_invitation.py @ 3573:813595f88612
merge changes from main branch
author | Goffi <goffi@goffi.org> |
---|---|
date | Thu, 17 Jun 2021 13:05:58 +0200 |
parents | 04283582966f |
children | 524856bd7b19 |
comparison
equal
deleted
inserted
replaced
3541:888109774673 | 3573:813595f88612 |
---|---|
160 use_output=C.OUTPUT_DICT, | 160 use_output=C.OUTPUT_DICT, |
161 help=_("get invitation data"), | 161 help=_("get invitation data"), |
162 ) | 162 ) |
163 | 163 |
164 def add_parser_options(self): | 164 def add_parser_options(self): |
165 self.parser.add_argument( | 165 self.parser.add_argument("id", help=_("invitation UUID")) |
166 "id", help=_("invitation UUID") | |
167 ) | |
168 self.parser.add_argument( | 166 self.parser.add_argument( |
169 "-j", | 167 "-j", |
170 "--with-jid", | 168 "--with-jid", |
171 action="store_true", | 169 action="store_true", |
172 help=_("start profile session and retrieve jid"), | 170 help=_("start profile session and retrieve jid"), |
182 try: | 180 try: |
183 invitation_data = await self.host.bridge.invitationGet( | 181 invitation_data = await self.host.bridge.invitationGet( |
184 self.args.id, | 182 self.args.id, |
185 ) | 183 ) |
186 except Exception as e: | 184 except Exception as e: |
187 self.disp(msg=_(f"can't get invitation data: {e}"), error=True) | 185 self.disp(msg=_("can't get invitation data: {e}").format(e=e), error=True) |
188 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 186 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
189 | 187 |
190 if not self.args.with_jid: | 188 if not self.args.with_jid: |
191 await self.output_data(invitation_data) | 189 await self.output_data(invitation_data) |
192 else: | 190 else: |
195 await self.host.bridge.profileStartSession( | 193 await self.host.bridge.profileStartSession( |
196 invitation_data["password"], | 194 invitation_data["password"], |
197 profile, | 195 profile, |
198 ) | 196 ) |
199 except Exception as e: | 197 except Exception as e: |
200 self.disp(msg=_(f"can't start session: {e}"), error=True) | 198 self.disp(msg=_("can't start session: {e}").format(e=e), error=True) |
201 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 199 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
202 | 200 |
203 try: | 201 try: |
204 jid_ = await self.host.bridge.asyncGetParamA( | 202 jid_ = await self.host.bridge.asyncGetParamA( |
205 "JabberID", | 203 "JabberID", |
206 "Connection", | 204 "Connection", |
207 profile_key=profile, | 205 profile_key=profile, |
208 ) | 206 ) |
209 except Exception as e: | 207 except Exception as e: |
210 self.disp(msg=_(f"can't retrieve jid: {e}"), error=True) | 208 self.disp(msg=_("can't retrieve jid: {e}").format(e=e), error=True) |
211 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 209 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
212 | 210 |
213 await self.output_data(invitation_data, jid_) | 211 await self.output_data(invitation_data, jid_) |
214 | 212 |
215 | 213 |
222 use_profile=False, | 220 use_profile=False, |
223 help=_("delete guest account"), | 221 help=_("delete guest account"), |
224 ) | 222 ) |
225 | 223 |
226 def add_parser_options(self): | 224 def add_parser_options(self): |
227 self.parser.add_argument( | 225 self.parser.add_argument("id", help=_("invitation UUID")) |
228 "id", help=_("invitation UUID") | |
229 ) | |
230 | 226 |
231 async def start(self): | 227 async def start(self): |
232 try: | 228 try: |
233 await self.host.bridge.invitationDelete( | 229 await self.host.bridge.invitationDelete( |
234 self.args.id, | 230 self.args.id, |
235 ) | 231 ) |
236 except Exception as e: | 232 except Exception as e: |
237 self.disp(msg=_(f"can't delete guest account: {e}"), error=True) | 233 self.disp(msg=_("can't delete guest account: {e}").format(e=e), error=True) |
238 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 234 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
239 | 235 |
240 self.host.quit() | 236 self.host.quit() |
241 | 237 |
242 | 238 |
288 "-p", | 284 "-p", |
289 "--profile", | 285 "--profile", |
290 default="", | 286 default="", |
291 help="profile doing the invitation (default: don't associate profile", | 287 help="profile doing the invitation (default: don't associate profile", |
292 ) | 288 ) |
293 self.parser.add_argument( | 289 self.parser.add_argument("id", help=_("invitation UUID")) |
294 "id", help=_("invitation UUID") | |
295 ) | |
296 | 290 |
297 async def start(self): | 291 async def start(self): |
298 extra = dict(self.args.extra) | 292 extra = dict(self.args.extra) |
299 for arg_name in ("name", "host_name", "email", "language", "profile"): | 293 for arg_name in ("name", "host_name", "email", "language", "profile"): |
300 value = getattr(self.args, arg_name) | 294 value = getattr(self.args, arg_name) |
301 if not value: | 295 if not value: |
302 continue | 296 continue |
303 if arg_name in extra: | 297 if arg_name in extra: |
304 self.parser.error( | 298 self.parser.error( |
305 _(f"you can't set {arg_name} in both optional argument and extra") | 299 _( |
300 "you can't set {arg_name} in both optional argument and extra" | |
301 ).format(arg_name=arg_name) | |
306 ) | 302 ) |
307 extra[arg_name] = value | 303 extra[arg_name] = value |
308 try: | 304 try: |
309 await self.host.bridge.invitationModify( | 305 await self.host.bridge.invitationModify( |
310 self.args.id, | 306 self.args.id, |
311 extra, | 307 extra, |
312 self.args.replace, | 308 self.args.replace, |
313 ) | 309 ) |
314 except Exception as e: | 310 except Exception as e: |
315 self.disp( | 311 self.disp(f"can't modify invitation: {e}", error=True) |
316 f"can't modify invitation: {e}", error=True | |
317 ) | |
318 self.host.quit(C.EXIT_BRIDGE_ERRBACK) | 312 self.host.quit(C.EXIT_BRIDGE_ERRBACK) |
319 else: | 313 else: |
320 self.disp(_("invitations have been modified successfuly")) | 314 self.disp(_("invitations have been modified successfuly")) |
321 self.host.quit(C.EXIT_OK) | 315 self.host.quit(C.EXIT_OK) |
322 | 316 |