# -*- encoding: utf-8 -*-
##############################################################################
#
-# OpenERP, Open Source Management Solution
+# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>). All Rights Reserved
# $Id$
#
#
##############################################################################
-import base64
+import base64
import logging
import os
import security
fs = os.path.join(tools.config['root_path'], 'filestore')
if os.path.exists(os.path.join(fs, old_name)):
os.rename(os.path.join(fs, old_name), os.path.join(fs, new_name))
-
+
logger.notifyChannel("web-services", netsvc.LOG_INFO,
'RENAME DB: %s -> %s' % (old_name, new_name))
finally:
try:
l.notifyChannel('migration', netsvc.LOG_INFO, 'migrate database %s' % (db,))
tools.config['update']['base'] = True
- pooler.restart_pool(db, force_demo=False, update_module=True)
+ pooler.restart_pool(db, force_demo=False, update_module=True)
except except_orm, inst:
self.abortResponse(1, inst.name, 'warning', inst.value)
except except_osv, inst:
self.exportMethod(self.timezone_get)
self.exportMethod(self.get_available_updates)
self.exportMethod(self.get_migration_scripts)
+ self.exportMethod(self.get_server_environment)
def ir_set(self, db, uid, password, keys, args, name, value, replace=True, isobject=False):
security.check(db, uid, password)
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')
-
+ 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:
+ 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')
+ raise tm.RemoteContractException('This contract does not exist or is not active')
if rc.status != 'full':
raise tm.RemoteContractException('Can not get updates for a partial contract')
l.notifyChannel('migration', netsvc.LOG_INFO, 'starting migration with contract %s' % (rc.name,))
zips = rc.retrieve_updates(rc.id, addons.get_modules_with_version())
-
+
from shutil import rmtree, copytree, copy
backup_directory = os.path.join(tools.config['root_path'], 'backup', time.strftime('%Y-%m-%d-%H-%M'))
tb_s = reduce(lambda x, y: x+y, traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback))
l.notifyChannel('migration', netsvc.LOG_ERROR, tb_s)
raise
-
+
+ def get_server_environment(self):
+ try:
+ revno = os.popen('bzr revno').read()
+ rev_log = ''
+ cnt = 0
+ for line in os.popen('bzr log -r %s'%(int(revno))).readlines():
+ if line.find(':')!=-1:
+ if not cnt == 4:
+ rev_log += '\t' + line
+ cnt += 1
+ else:
+ break
+ except Exception,e:
+ rev_log = 'Exception: %s\n' % (str(e))
+
+ os_lang = os.environ.get('LANG', '').split('.')[0]
+ environment = '\nEnvironment_Information : \n' \
+ 'PlatForm : %s\n' \
+ 'Operating System : %s\n' \
+ 'Operating System Version : %s\n' \
+ 'Operating System Locale : %s\n'\
+ 'Python Version : %s\n'\
+ 'OpenERP-Server Version : %s\n'\
+ 'Last revision Details: \n%s' \
+ %(sys.platform,os.name,str(sys.version.split('\n')[1]),os_lang,str(sys.version[0:5]),release.version,rev_log)
+ return environment
common()
class objects_proxy(netsvc.Service):