1 # -*- encoding: utf-8 -*-
2 ##############################################################################
4 # OpenERP, Open Source Management Solution
5 # Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
8 # This program is free software: you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation, either version 3 of the License, or
11 # (at your option) any later version.
13 # This program is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program. If not, see <http://www.gnu.org/licenses/>.
21 ##############################################################################
25 class RemoteContractException(Exception): pass
27 class remote_contract(object):
28 def __init__(self, contract_id, contract_password, modules=None):
29 self.__server = 'http://192.168.0.127:8072/xmlrpc/'
30 self.__db = "maintenance"
31 self.__password = "admin"
32 self.__login = "admin"
34 rpc = xmlrpclib.ServerProxy(self.__server + 'common')
36 self.__userid = rpc.login(self.__db, self.__login, self.__password)
38 raise RemoteContractException("Unable to contact the migration server")
40 self.__rpc = xmlrpclib.ServerProxy(self.__server + 'object')
45 'password': contract_password,
50 info = self.check_contract(modules, contract)
52 setattr(self, n, info[n])
54 self.name = contract_id
55 self.contract_id = self.name
56 self.password = contract_password
58 def __getattr__(self, fun):
59 def remote_call(*args, **kwargs):
60 return self.__rpc.execute(self.__db, self.__userid, self.__password, 'maintenance.maintenance', fun, *args, **kwargs)
63 def __getitem__(self, item):
64 return getattr(self, item)
66 # vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: