comparison sat/plugins/plugin_xep_0363.py @ 3040:fee60f17ebac

jp: jp asyncio port: /!\ this commit is huge. Jp is temporarily not working with `dbus` bridge /!\ This patch implements the port of jp to asyncio, so it is now correctly using the bridge asynchronously, and it can be used with bridges like `pb`. This also simplify the code, notably for things which were previously implemented with many callbacks (like pagination with RSM). During the process, some behaviours have been modified/fixed, in jp and backends, check diff for details.
author Goffi <goffi@goffi.org>
date Wed, 25 Sep 2019 08:56:41 +0200
parents ab2696e34d29
children e75024e41f81
comparison
equal deleted inserted replaced
3039:a1bc34f90fa5 3040:fee60f17ebac
34 from twisted.web import client as http_client 34 from twisted.web import client as http_client
35 from twisted.web import http_headers 35 from twisted.web import http_headers
36 from twisted.web import iweb 36 from twisted.web import iweb
37 from twisted.python import failure 37 from twisted.python import failure
38 from collections import namedtuple 38 from collections import namedtuple
39 from zope.interface import implementer
40 from OpenSSL import SSL 39 from OpenSSL import SSL
41 import os.path 40 import os.path
42 import mimetypes 41 import mimetypes
43 42
44 43
202 @param path(str): path to the file to upload 201 @param path(str): path to the file to upload
203 @param size(int): size of the file to upload 202 @param size(int): size of the file to upload
204 @param ignore_tls_errors(bool): ignore TLS certificate is True 203 @param ignore_tls_errors(bool): ignore TLS certificate is True
205 @return (tuple 204 @return (tuple
206 """ 205 """
207 log.debug("Got upload slot: {}".format(slot)) 206 log.debug(f"Got upload slot: {slot}")
208 sat_file = self.host.plugins["FILE"].File( 207 sat_file = self.host.plugins["FILE"].File(
209 self.host, client, path, size=size, auto_end_signals=False 208 self.host, client, path, size=size, auto_end_signals=False
210 ) 209 )
211 progress_id_d.callback(sat_file.uid) 210 progress_id_d.callback(sat_file.uid)
212 file_producer = http_client.FileBodyProducer(sat_file) 211 file_producer = http_client.FileBodyProducer(sat_file)
220 name = name.encode('utf-8') 219 name = name.encode('utf-8')
221 value = value.encode('utf-8') 220 value = value.encode('utf-8')
222 headers[name] = value 221 headers[name] = value
223 222
224 d = agent.request( 223 d = agent.request(
225 "PUT", 224 b"PUT",
226 slot.put.encode("utf-8"), 225 slot.put.encode("utf-8"),
227 http_headers.Headers(headers), 226 http_headers.Headers(headers),
228 file_producer, 227 file_producer,
229 ) 228 )
230 d.addCallbacks( 229 d.addCallbacks(