comparison sat_frontends/jp/cmd_file.py @ 3089:e75024e41f81

plugin upload, XEP-0363: code modernisation + preparation for extension: - use of async/await syntax - fileUpload's options are now serialised, allowing non string values - (XEP-0363) Slot is now a dataclass, so it can be modified by other plugins - (XEP-0363) Moved SSL related code to the new tools.web module - (XEP-0363) added `XEP-0363_upload_size` and `XEP-0363_upload` trigger points - a Deferred is not used anymore for `progress_id`, the value is directly returned
author Goffi <goffi@goffi.org>
date Fri, 20 Dec 2019 12:28:04 +0100
parents e189ceca7e8b
children c3cb18236bdf
comparison
equal deleted inserted replaced
3088:d1464548055a 3089:e75024e41f81
476 else: 476 else:
477 self.full_dest_jid = await self.host.get_full_jid(self.args.jid) 477 self.full_dest_jid = await self.host.get_full_jid(self.args.jid)
478 478
479 options = {} 479 options = {}
480 if self.args.ignore_tls_errors: 480 if self.args.ignore_tls_errors:
481 options["ignore_tls_errors"] = C.BOOL_TRUE 481 options["ignore_tls_errors"] = True
482 482
483 path = os.path.abspath(file_) 483 path = os.path.abspath(file_)
484 try: 484 try:
485 upload_data = await self.host.bridge.fileUpload( 485 upload_data = await self.host.bridge.fileUpload(
486 path, 486 path,
487 "", 487 "",
488 self.full_dest_jid, 488 self.full_dest_jid,
489 options, 489 data_format.serialise(options),
490 self.profile, 490 self.profile,
491 ) 491 )
492 except Exception as e: 492 except Exception as e:
493 self.disp(f"can't while trying to upload a file: {e}", error=True) 493 self.disp(f"can't while trying to upload a file: {e}", error=True)
494 self.host.quit(C.EXIT_BRIDGE_ERRBACK) 494 self.host.quit(C.EXIT_BRIDGE_ERRBACK)