Compare commits

...

5 Commits

Author SHA1 Message Date
Frédéric Péters e52f6a3b03 greco: set binary parts after mime structure is created (#44555)
gitea-wip/passerelle/pipeline/head There was a failure building this commit Details
gitea/passerelle/pipeline/head Something is wrong with the build of this commit Details
2020-06-29 15:06:04 +02:00
Frédéric Péters 76e3b500e5 greco: don't put filenames as bytes (#44552) 2020-06-29 15:06:04 +02:00
Serghei Mihai d0f2626617 teamnet_axel: use bytes reponse content as suds requires (#44473)
This reverts commit ee615d34d2.
2020-06-26 11:34:26 +02:00
Serghei Mihai c39d864800 teamnet_axel: use text property to retrieve reponse content (#44469) 2020-06-26 09:58:03 +02:00
Frédéric Péters eb80208ec3 solis apa: adapt sort of homonyms to python 3 (#44467) 2020-06-26 09:58:03 +02:00
3 changed files with 14 additions and 10 deletions

View File

@ -16,10 +16,7 @@
import base64
import re
from email import encoders
from email.mime.audio import MIMEAudio
from email.mime.base import MIMEBase
from email.mime.image import MIMEImage
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
@ -125,8 +122,6 @@ class Greco(BaseResource):
soap_headers = []
for num, attachment in enumerate(self.attachments):
filename = attachment.get('filename') or 'file%s.bin' % num
if isinstance(filename, six.text_type):
filename = filename.encode('utf-8', 'ignore')
soap_headers.append('<filename%s>%s</filename%s>' % (num, filename, num))
xml_payload = xml_payload.replace('<SOAP-ENV:Header/>',
'<SOAP-ENV:Header>%s</SOAP-ENV:Header>' % ''.join(soap_headers))
@ -142,9 +137,10 @@ class Greco(BaseResource):
part = MIMEText(content, _subtype=subtype)
else:
part = MIMEBase(maintype, subtype, name=filename)
part.set_payload(content)
attachment['real_bytes'] = content
attachment['fake_bytes'] = '\ue000%s\ue000' % num
part.set_payload(attachment['fake_bytes'])
part.add_header('Content-Transfer-Encoding', 'binary')
encoders.encode_noop(part)
part.add_header('Content-Disposition', 'attachment', name=filename, filename=filename)
part.add_header('Content-ID', '<%s>' % filename)
message.attach(part)
@ -165,6 +161,13 @@ class Greco(BaseResource):
request.message = message.as_string(unixfrom=False
).replace(boundary + '\n', boundary + '\r\n'
).replace('\n--' + boundary, '\r\n--' + boundary).encode('utf-8')
for attachment in attachments:
# substitute binary parts
if attachment.get('fake_bytes'):
request.message = request.message.replace(
attachment['fake_bytes'].encode('utf-8'),
attachment['real_bytes'])
request.headers.update(dict(message._headers))
request.headers['Authorization'] = self.instance.get_token()
resp = self.instance.requests.post(request.url, data=request.message,

View File

@ -268,7 +268,8 @@ class SolisAPA(BaseResource):
' - %(Dossier/Adresse/CpLieu/@V)s %(Dossier/Adresse/Commune/NomCom/@V)s') % i,
'affinity': '%(@affinity)s' % i,
})
ret.sort(lambda x,y: cmp(y['affinity'],x['affinity']))
ret.sort(key=lambda x: x['affinity'])
ret.reverse()
return ret
def _process_common_ref(self, ref_name, q=None):

View File

@ -17,7 +17,7 @@
# borrowed from https://pypi.python.org/pypi/suds_requests
# and https://docs.oracle.com/cd/E50245_01/E50253/html/vmprg-soap-example-authentication-python.html
from django.utils.six import StringIO
from django.utils.six import BytesIO
from suds.transport.http import HttpAuthenticated
from suds.transport import Reply
from suds.client import Client
@ -43,7 +43,7 @@ class Transport(HttpAuthenticated):
resp = self.model.requests.get(
request.url, headers=request.headers,
**self.get_requests_kwargs())
return StringIO(resp.content)
return BytesIO(resp.content)
def send(self, request):
self.addcredentials(request)