~jfb-tempo-consulting/unifield-wm/sync-env-py3

« back to all changes in this revision

Viewing changes to openerplib103/main.py

  • Committer: jf
  • Date: 2022-02-01 10:24:52 UTC
  • mfrom: (173.1.1 sync-env)
  • Revision ID: jfb@tempo-consulting.fr-20220201102452-rndr3uvmo030kqlf
[MERGE] US-9423: instance registration: do not validate an instance with no group on the sync server

Show diffs side-by-side

added added

removed removed

Lines of Context:
37
37
Code repository: https://code.launchpad.net/~niv-openerp/openerp-client-lib/trunk
38
38
"""
39
39
 
40
 
import xmlrpc.client
 
40
import xmlrpclib
41
41
import logging 
42
42
import socket
43
43
 
44
44
try:
45
 
    import pickle as pickle
 
45
    import cPickle as pickle
46
46
except ImportError:
47
47
    import pickle
48
48
 
49
49
try:
50
 
    import io as StringIO
 
50
    import cStringIO as StringIO
51
51
except ImportError:
52
 
    import io
 
52
    import StringIO
53
53
 
54
54
_logger = logging.getLogger(__name__)
55
55
 
91
91
 
92
92
    def send(self, service_name, method, *args):
93
93
        url = '%s/%s' % (self.url, service_name)
94
 
        service = xmlrpc.client.ServerProxy(url)
 
94
        service = xmlrpclib.ServerProxy(url)
95
95
        return getattr(service, method)(*args)
96
96
 
97
97
class NetRPC_Exception(Exception):
133
133
        while totalsent < size:
134
134
            sent = self.sock.send(msg[totalsent:])
135
135
            if sent == 0:
136
 
                raise RuntimeError("socket connection broken")
 
136
                raise RuntimeError, "socket connection broken"
137
137
            totalsent = totalsent + sent
138
138
 
139
139
    def myreceive(self):
141
141
        while len(buf) < 8:
142
142
            chunk = self.sock.recv(8 - len(buf))
143
143
            if chunk == '':
144
 
                raise RuntimeError("socket connection broken")
 
144
                raise RuntimeError, "socket connection broken"
145
145
            buf += chunk
146
146
        size = int(buf)
147
147
        buf = self.sock.recv(1)
153
153
        while len(msg) < size:
154
154
            chunk = self.sock.recv(size-len(msg))
155
155
            if chunk == '':
156
 
                raise RuntimeError("socket connection broken")
 
156
                raise RuntimeError, "socket connection broken"
157
157
            msg = msg + chunk
158
 
        msgio = io.StringIO(msg)
 
158
        msgio = StringIO.StringIO(msg)
159
159
        unpickler = pickle.Unpickler(msgio)
160
160
        unpickler.find_global = None
161
161
        res = unpickler.load()