[FIX] avoid a crash when the migration server is not accessible

bzr revid: christophe@tinyerp.com-20090109091555-qipdi2hyrxlqpquc
This commit is contained in:
Christophe Simonis
2009-01-09 10:15:55 +01:00
parent eab8eb27cb
commit f4c1cc32ba
2 changed files with 11 additions and 8 deletions
+5 -7
View File
@@ -301,8 +301,6 @@ class db(netsvc.Service):
return True
db()
class MigrationException(Exception): pass
class common(netsvc.Service):
def __init__(self,name="common"):
netsvc.Service.__init__(self,name)
@@ -384,12 +382,12 @@ GNU Public Licence.
security.check_super(password)
l = netsvc.Logger()
try:
from tools.maintenance import remote_contract
rc = remote_contract(contract_id, contract_password)
import tools.maintenance as tm
rc = tm.remote_contract(contract_id, contract_password)
if not rc.id:
raise MigrationException('This contract does not exist or is not active')
raise tm.RemoteContractException('This contract does not exist or is not active')
if rc.status != 'full':
raise MigrationException('Can not get updates for a partial contract')
raise tm.RemoteContractException('Can not get updates for a partial contract')
l.notifyChannel('migration', netsvc.LOG_INFO, 'starting migration with contract %s' % (rc.name,))
@@ -412,7 +410,7 @@ GNU Public Licence.
zip.close()
return True
except MigrationException, e:
except tm.RemoteContractException, e:
self.abortResponse(1, 'Migration Error', 'warning', str(e))
except Exception, e:
import traceback
+6 -1
View File
@@ -22,6 +22,8 @@
import xmlrpclib
class RemoteContractException(Exception): pass
class remote_contract(object):
def __init__(self, contract_id, contract_password, modules=None):
self.__server = 'http://localhost:8069/xmlrpc/'
@@ -30,7 +32,10 @@ class remote_contract(object):
self.__login = "admin"
rpc = xmlrpclib.ServerProxy(self.__server + 'common')
self.__userid = rpc.login(self.__db, self.__login, self.__password)
try:
self.__userid = rpc.login(self.__db, self.__login, self.__password)
except:
raise RemoteContractException("Unable to contact the migration server")
self.__rpc = xmlrpclib.ServerProxy(self.__server + 'object')