[IMP] maintenance: new method allowing to get available updates from maintenance server

bzr revid: christophe@tinyerp.com-20090211161906-ktc9z1me1gav7erq
This commit is contained in:
Christophe Simonis 2009-02-11 17:19:06 +01:00
parent c046bc9920
commit 1f89f49e75
2 changed files with 27 additions and 1 deletions

View File

@ -272,6 +272,17 @@ def get_modules():
return list(set(listdir(ad) + listdir(_ad)))
def get_modules_with_version():
modules = get_modules()
res = {}
for module in modules:
terp = get_module_resource(module, '__terp__.py')
try:
info = eval(tools.file_open(terp).read())
res[module] = "%s.%s" % (release.major_version, info['version'])
except Exception, e:
continue
return res
def create_graph(cr, module_list, force=None):
graph = Graph()

View File

@ -320,6 +320,7 @@ class common(netsvc.Service):
self.exportMethod(self.login)
self.exportMethod(self.logout)
self.exportMethod(self.timezone_get)
self.exportMethod(self.get_available_updates)
self.exportMethod(self.get_migration_scripts)
def ir_set(self, db, uid, password, keys, args, name, value, replace=True, isobject=False):
@ -385,12 +386,26 @@ GNU Public Licence.
def timezone_get(self, db, login, password):
return time.tzname[0]
def get_available_updates(self, password, contract_id, contract_password):
security.check_super(password)
import tools.maintenance as tm
try:
rc = tm.remote_contract(contract_id, contract_password)
if not rc.id:
raise tm.RemoteContractException('This contract does not exist or is not active')
return rc.get_available_updates(rc.id, addons.get_modules_with_version())
except tm.RemoteContractException, e:
self.abortResponse(1, 'Migration Error', 'warning', str(e))
def get_migration_scripts(self, password, contract_id, contract_password):
security.check_super(password)
l = netsvc.Logger()
import tools.maintenance as tm
try:
import tools.maintenance as tm
rc = tm.remote_contract(contract_id, contract_password)
if not rc.id:
raise tm.RemoteContractException('This contract does not exist or is not active')