Merge lp:~jfb-tempo-consulting/unifield-server/US-7030 into lp:unifield-server

Proposed by jftempo
Status: Merged
Merged at revision: 5630
Proposed branch: lp:~jfb-tempo-consulting/unifield-server/US-7030
Merge into: lp:unifield-server
Diff against target: 76 lines (+14/-5)
2 files modified
bin/addons/sync_client/rpc.py (+9/-4)
bin/addons/sync_client/timeout_transport.py (+5/-1)
To merge this branch: bzr merge lp:~jfb-tempo-consulting/unifield-server/US-7030
Reviewer Review Type Date Requested Status
UniField Reviewer Team Pending
Review via email: mp+378642@code.launchpad.net
To post a comment you must log in.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'bin/addons/sync_client/rpc.py'
--- bin/addons/sync_client/rpc.py 2017-05-09 15:04:38 +0000
+++ bin/addons/sync_client/rpc.py 2020-02-06 09:41:40 +0000
@@ -9,7 +9,7 @@
9import socket9import socket
10import zlib10import zlib
11import xmlrpclib11import xmlrpclib
12from timeout_transport import TimeoutTransport12from timeout_transport import TimeoutTransport, TimeoutSafeTransport
13from osv import osv13from osv import osv
14from tools.translate import _14from tools.translate import _
15import tools15import tools
@@ -106,7 +106,7 @@
106 error = e106 error = e
107 if i < self.retry:107 if i < self.retry:
108 retry = True108 retry = True
109 self._logger.debug("retry to connect %s, error : %s" ,i, e)109 self._logger.warn("retry to connect %s, error : %s" ,i, e)
110 i += 1110 i += 1
111 if error:111 if error:
112 raise osv.except_osv(_('Error!'), "Unable to proceed for the following reason:\n%s" % (e.faultCode if hasattr(e, 'faultCode') else tools.ustr(e)))112 raise osv.except_osv(_('Error!'), "Unable to proceed for the following reason:\n%s" % (e.faultCode if hasattr(e, 'faultCode') else tools.ustr(e)))
@@ -120,16 +120,21 @@
120120
121 def __init__(self, hostname, port=8070, timeout=10.0, retry=0):121 def __init__(self, hostname, port=8070, timeout=10.0, retry=0):
122 XmlRPCConnector.__init__(self, hostname, port, timeout=timeout, retry=retry)122 XmlRPCConnector.__init__(self, hostname, port, timeout=timeout, retry=retry)
123 self.timeout = timeout
123 self.url = 'https://%s:%s/xmlrpc' % (self.hostname, self.port)124 self.url = 'https://%s:%s/xmlrpc' % (self.hostname, self.port)
124125
125 def send(self, service_name, method, *args):126 def send(self, service_name, method, *args):
126 url = '%s/%s' % (self.url, service_name)127 url = '%s/%s' % (self.url, service_name)
127 # Decide whether to accept self-signed certificates128 # Decide whether to accept self-signed certificates
128 ctx = ssl.create_default_context()129 ctx = ssl.create_default_context()
130 transport = TimeoutSafeTransport(timeout=self.timeout)
131 # Enable gzip on all payloads
132 transport.encode_threshold = 0
129 if not tools.config.get('secure_verify', True):133 if not tools.config.get('secure_verify', True):
130 ctx.check_hostname = False134 ctx.check_hostname = False
131 ctx.verify_mode = ssl.CERT_NONE135 ctx.verify_mode = ssl.CERT_NONE
132 service = xmlrpclib.ServerProxy(url, allow_none=1, context=ctx)136 service = xmlrpclib.ServerProxy(url, allow_none=1, context=ctx, transport=transport)
137
133 return self._send(service, method, *args)138 return self._send(service, method, *args)
134139
135class NetRPC_Exception(Exception):140class NetRPC_Exception(Exception):
@@ -392,7 +397,7 @@
392 return arguments397 return arguments
393398
394 def exists(self, oid, context=None):399 def exists(self, oid, context=None):
395 # TODO: Fucking bug, we can't use the read(fields=['id']), 400 # TODO: Fucking bug, we can't use the read(fields=['id']),
396 # because the server returns a positive value but the record does not exist401 # because the server returns a positive value but the record does not exist
397 # into the database402 # into the database
398 value = self.search_count([('id', '=', oid)], context=context)403 value = self.search_count([('id', '=', oid)], context=context)
399404
=== modified file 'bin/addons/sync_client/timeout_transport.py'
--- bin/addons/sync_client/timeout_transport.py 2017-05-09 15:04:38 +0000
+++ bin/addons/sync_client/timeout_transport.py 2020-02-06 09:41:40 +0000
@@ -30,6 +30,9 @@
30 if self.timeout is not None:30 if self.timeout is not None:
31 self.sock.settimeout(self.timeout)31 self.sock.settimeout(self.timeout)
3232
33 def set_timeout(self, timeout):
34 self.timeout = timeout
35
33class TimeoutSafeTransport(xmlrpclib.SafeTransport):36class TimeoutSafeTransport(xmlrpclib.SafeTransport):
3437
35 def __init__(self, timeout=None, *args, **kwargs):38 def __init__(self, timeout=None, *args, **kwargs):
@@ -37,7 +40,8 @@
37 self.timeout = timeout40 self.timeout = timeout
3841
39 def make_connection(self, host):42 def make_connection(self, host):
40 self._connection = host, TimeoutHTTPSConnection(host)43 chost, self._extra_headers, _ = self.get_host_info(host)
44 self._connection = host, TimeoutHTTPSConnection(chost)
41 self._connection[1].set_timeout(self.timeout)45 self._connection[1].set_timeout(self.timeout)
42 return self._connection[1]46 return self._connection[1]
4347

Subscribers

People subscribed via source and target branches