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')