summaryrefslogtreecommitdiff
path: root/bin
diff options
context:
space:
mode:
authorChristophe Simonis <christophe@tinyerp.com>2009-01-09 10:15:55 +0100
committerChristophe Simonis <christophe@tinyerp.com>2009-01-09 10:15:55 +0100
commitf4c1cc32bacfce01fbafa1fe47fef925b7d33b4d (patch)
treef76264e5bc48ae034fbc7821541adab3f6683167 /bin
parenteab8eb27cb4f1500463cfd7e4205297212bcc0cf (diff)
[FIX] avoid a crash when the migration server is not accessible
bzr revid: christophe@tinyerp.com-20090109091555-qipdi2hyrxlqpquc
Diffstat (limited to 'bin')
-rw-r--r--bin/service/web_services.py12
-rw-r--r--bin/tools/maintenance.py7
2 files changed, 11 insertions, 8 deletions
diff --git a/bin/service/web_services.py b/bin/service/web_services.py
index ef0dedc551e..489879559e1 100644
--- a/bin/service/web_services.py
+++ b/bin/service/web_services.py
@@ -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
diff --git a/bin/tools/maintenance.py b/bin/tools/maintenance.py
index 959d9f7bf3c..aa3e6b50ad9 100644
--- a/bin/tools/maintenance.py
+++ b/bin/tools/maintenance.py
@@ -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')