~ubuntu-branches/ubuntu/trusty/openerp-client/trusty

« back to all changes in this revision

Viewing changes to bin/rpc.py

  • Committer: Bazaar Package Importer
  • Author(s): Daniel Baumann
  • Date: 2009-01-09 18:18:00 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20090109181800-p6t4lx2fbr0q3562
Tags: 5.0.0~rc3-1
* Merging upstream version 5.0.0~rc3.
* Using quilt rather than dpatch.
* Updating menu file.
* Updating year in copyright file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
235
235
        self.context_reload()
236
236
        return 1
237
237
 
 
238
    def migrate_databases(self, url, password, databases):
 
239
        m = re.match('^(http[s]?://|socket://)([\w.\-]+):(\d{1,5})$', url or '')
 
240
        if not m:
 
241
            raise Exception("This URL is not Error in the URL")
 
242
        if m.group(1) == 'http://' or m.group(1) == 'https://':
 
243
            sock = xmlrpclib.ServerProxy(url + '/xmlrpc/db')
 
244
            return sock.migrate_databases(password, databases)
 
245
        else:
 
246
            sock = tiny_socket.mysocket()
 
247
            sock.sock.settimeout(None)
 
248
            sock.connect(m.group(2), int(m.group(3)))
 
249
            sock.mysend(('db', 'migrate_databases', password, databases))
 
250
            res = sock.myreceive()
 
251
            sock.disconnect()
 
252
            return res
 
253
 
 
254
    def get_migration_scripts(self, url, password, contract_id, contract_password):
 
255
        m = re.match('^(http[s]?://|socket://)([\w.\-]+):(\d{1,5})$', url or '')
 
256
        if not m:
 
257
            raise Exception("This URL is not Error in the URL")
 
258
        if m.group(1) == 'http://' or m.group(1) == 'https://':
 
259
            sock = xmlrpclib.ServerProxy(url + '/xmlrpc/common')
 
260
            sock.get_migration_scripts(password, contract_id, contract_password)
 
261
        else:
 
262
            sock = tiny_socket.mysocket()
 
263
            sock.connect(m.group(2), int(m.group(3)))
 
264
            sock.mysend(('common', 'get_migration_scripts', password, contract_id, contract_password))
 
265
            res = sock.myreceive()
 
266
            sock.disconnect()
 
267
 
 
268
    def about(self, url):
 
269
        m = re.match('^(http[s]?://|socket://)([\w.\-]+):(\d{1,5})$', url or '')
 
270
        if not m:
 
271
            raise Exception("This URL is not Error in the URL")
 
272
        if m.group(1) == 'http://' or m.group(1) == 'https://':
 
273
            sock = xmlrpclib.ServerProxy(url + '/xmlrpc/common')
 
274
            return sock.about()
 
275
        else:
 
276
            sock = tiny_socket.mysocket()
 
277
            sock.connect(m.group(2), int(m.group(3)))
 
278
            sock.mysend(('common', 'about'))
 
279
            res = sock.myreceive()
 
280
            sock.disconnect()
 
281
            return res
 
282
 
238
283
    def list_db(self, url):
239
284
        m = re.match('^(http[s]?://|socket://)([\w.\-]+):(\d{1,5})$', url or '')
240
285
        if not m:
243
288
            try:
244
289
                sock = xmlrpclib.ServerProxy(url + '/xmlrpc/db')
245
290
                return sock.list()
246
 
            except:
 
291
            except Exception, ex:
247
292
                return -1
248
293
        else:
249
294
            sock = tiny_socket.mysocket()