uco
2010-06-21 10:43:50 +05:30
8 changed files with 311 additions and 295 deletions
+30 -2
View File
@@ -1,15 +1,43 @@
# -*- makefile -*-
addons-path := bin/addons/
extra-addons:= ''
root-path := bin/
port := 8069
net_port := 8070
module := base
database := terp
language := fr_FR
i18n-import := bin/addons/base/i18n/fr_FR.po
interrogation_file := bin/addons/base_quality_interrogation.py
login := admin
password := admin
openerp-test:
python $(interrogation_file) openerp-test --root-path=$(root-path) --addons-path=$(addons-path) --net_port=$(net_port) --port=$(port) --login=$(login) --password=$(password)
start:
python $(interrogation_file) start-server --root-path=$(root-path) --addons-path=$(addons-path) --port=$(port) --net_port=$(net_port)
create-db:
python $(interrogation_file) create-db --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --port=$(port) --net_port=$(net_port) --login=$(login) --password=$(password)
drop-db:
python $(interrogation_file) drop-db --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --port=$(port) --net_port=$(net_port)
install-module:
python $(interrogation_file) install-module --modules=$(module) --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --extra-addons=$(extra-addons) --net_port=$(net_port) --port=$(port) --login=$(login) --password=$(password)
upgrade-module:
python $(interrogation_file) upgrade-module --modules=$(module) --database=$(database) --root-path=$(root-path) --addons-path=$(addons-path) --port=$(port) --net_port=$(net_port) --login=$(login) --password=$(password)
install-translation:
python $(interrogation_file) install-translation --database=$(database) --translate-in=$(i18n-import) --net_port=$(net_port) --port=$(port) --login=$(login) --password=$(password) --root-path=$(root-path) --addons-path=$(addons-path)
version:
python bin/openerp-server.py --version
check-quality:
python $(interrogation_file) check-quality --database=$(database) --modules=$(module) --net_port=$(net_port) --port=$(port) --login=$(login) --password=$(password) --addons-path=$(addons-path) --root-path=$(root-path)
+40 -40
View File
@@ -8,13 +8,13 @@ msgstr ""
"Project-Id-Version: openobject-addons\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2009-12-18 08:39+0000\n"
"PO-Revision-Date: 2009-11-27 17:04+0000\n"
"Last-Translator: Fabien (Open ERP) <fp@tinyerp.com>\n"
"PO-Revision-Date: 2010-06-20 14:33+0000\n"
"Last-Translator: Borja López Soilán (Pexego) <borjals@pexego.es>\n"
"Language-Team: Galician <gl@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-01 03:40+0000\n"
"X-Launchpad-Export-Date: 2010-06-21 03:42+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: base
@@ -69,32 +69,32 @@ msgstr ""
#. module: base
#: selection:module.lang.install,init,lang:0
msgid "Hungarian / Magyar"
msgstr ""
msgstr "Húngaro / Magyar"
#. module: base
#: field:ir.actions.server,wkf_model_id:0
msgid "Workflow On"
msgstr ""
msgstr "Fluxo de traballo en"
#. module: base
#: view:ir.module.module:0
msgid "Created Views"
msgstr ""
msgstr "Vistas creadas"
#. module: base
#: view:workflow.activity:0
msgid "Outgoing transitions"
msgstr ""
msgstr "Transicións saintes"
#. module: base
#: selection:ir.report.custom,frequency:0
msgid "Yearly"
msgstr ""
msgstr "Anual"
#. module: base
#: field:ir.actions.act_window,target:0
msgid "Target Window"
msgstr ""
msgstr "Ventana destino"
#. module: base
#: model:ir.actions.todo,note:base.config_wizard_simple_view
@@ -116,14 +116,14 @@ msgstr ""
#. module: base
#: model:res.country,name:base.kr
msgid "South Korea"
msgstr ""
msgstr "Corea do Sur"
#. module: base
#: model:ir.actions.act_window,name:base.action_workflow_transition_form
#: model:ir.ui.menu,name:base.menu_workflow_transition
#: view:workflow.activity:0
msgid "Transitions"
msgstr ""
msgstr "Transicións"
#. module: base
#: model:ir.model,name:base.model_ir_ui_view_custom
@@ -133,7 +133,7 @@ msgstr ""
#. module: base
#: model:res.country,name:base.sz
msgid "Swaziland"
msgstr ""
msgstr "Suacilandia"
#. module: base
#: model:ir.model,name:base.model_ir_actions_report_custom
@@ -144,12 +144,12 @@ msgstr ""
#. module: base
#: selection:ir.ui.menu,icon:0
msgid "STOCK_CANCEL"
msgstr ""
msgstr "STOCK_CANCEL"
#. module: base
#: field:ir.report.custom,sortby:0
msgid "Sorted By"
msgstr ""
msgstr "Ordeado por"
#. module: base
#: field:ir.sequence,number_increment:0
@@ -176,33 +176,33 @@ msgstr ""
#: code:addons/base/module/wizard/wizard_export_lang.py:0
#, python-format
msgid "new"
msgstr ""
msgstr "novo"
#. module: base
#: selection:ir.ui.menu,icon:0
msgid "STOCK_GOTO_TOP"
msgstr ""
msgstr "STOCK_GOTO_TOP"
#. module: base
#: field:ir.actions.report.custom,multi:0
#: field:ir.actions.report.xml,multi:0
msgid "On multiple doc."
msgstr ""
msgstr "En múltiples doc."
#. module: base
#: field:ir.module.category,module_nr:0
msgid "Number of Modules"
msgstr ""
msgstr "Número de módulos"
#. module: base
#: field:res.partner.bank.type.field,size:0
msgid "Max. Size"
msgstr ""
msgstr "Tamaño máx."
#. module: base
#: field:res.partner.address,name:0
msgid "Contact Name"
msgstr ""
msgstr "Nome de contacto"
#. module: base
#: code:addons/base/module/wizard/wizard_export_lang.py:0
@@ -215,7 +215,7 @@ msgstr ""
#. module: base
#: selection:ir.ui.menu,icon:0
msgid "STOCK_DELETE"
msgstr ""
msgstr "STOCK_DELETE"
#. module: base
#: code:addons/base/ir/ir_model.py:0
@@ -232,12 +232,12 @@ msgstr ""
#. module: base
#: selection:res.request,state:0
msgid "active"
msgstr ""
msgstr "activo"
#. module: base
#: field:ir.actions.wizard,wiz_name:0
msgid "Wizard Name"
msgstr ""
msgstr "Nome do asistente"
#. module: base
#: view:res.lang:0
@@ -247,7 +247,7 @@ msgstr ""
#. module: base
#: selection:ir.ui.menu,icon:0
msgid "STOCK_GOTO_FIRST"
msgstr ""
msgstr "STOCK_GOTO_FIRST"
#. module: base
#: help:ir.rule.group,rules:0
@@ -290,14 +290,14 @@ msgstr ""
#: field:ir.model.access,group_id:0
#: field:ir.rule,rule_group:0
msgid "Group"
msgstr ""
msgstr "Grupo"
#. module: base
#: field:ir.exports.line,name:0
#: field:ir.translation,name:0
#: field:res.partner.bank.type.field,name:0
msgid "Field Name"
msgstr ""
msgstr "Nome do campo"
#. module: base
#: model:ir.actions.act_window,name:base.open_module_tree_uninstall
@@ -308,7 +308,7 @@ msgstr ""
#. module: base
#: selection:ir.actions.report.xml,report_type:0
msgid "txt"
msgstr ""
msgstr "txt"
#. module: base
#: wizard_view:server.action.create,init:0
@@ -319,12 +319,12 @@ msgstr ""
#. module: base
#: selection:ir.actions.todo,type:0
msgid "Configure"
msgstr ""
msgstr "Configurar"
#. module: base
#: model:res.country,name:base.tv
msgid "Tuvalu"
msgstr ""
msgstr "Tuvalu"
#. module: base
#: selection:ir.model,state:0
@@ -335,18 +335,18 @@ msgstr ""
#. module: base
#: field:res.lang,date_format:0
msgid "Date Format"
msgstr ""
msgstr "Formato de data"
#. module: base
#: field:res.bank,email:0
#: field:res.partner.address,email:0
msgid "E-Mail"
msgstr ""
msgstr "Correo electrónico"
#. module: base
#: model:res.country,name:base.an
msgid "Netherlands Antilles"
msgstr ""
msgstr "Antillas Holandesas"
#. module: base
#: code:addons/base/res/res_user.py:0
@@ -359,7 +359,7 @@ msgstr ""
#. module: base
#: model:res.country,name:base.gf
msgid "French Guyana"
msgstr ""
msgstr "Guayana francesa"
#. module: base
#: field:ir.ui.view.custom,ref_id:0
@@ -369,7 +369,7 @@ msgstr ""
#. module: base
#: selection:module.lang.install,init,lang:0
msgid "Bosnian / bosanski jezik"
msgstr ""
msgstr "Bosnia / Bosanski jezik"
#. module: base
#: help:ir.actions.report.xml,attachment_use:0
@@ -386,12 +386,12 @@ msgstr ""
#. module: base
#: selection:ir.ui.menu,icon:0
msgid "STOCK_MEDIA_REWIND"
msgstr ""
msgstr "STOCK_MEDIA_REWIND"
#. module: base
#: field:ir.actions.todo,note:0
msgid "Text"
msgstr ""
msgstr "Texto"
#. module: base
#: field:res.country,name:0
@@ -424,7 +424,7 @@ msgstr ""
#: selection:workflow.activity,join_mode:0
#: selection:workflow.activity,split_mode:0
msgid "Xor"
msgstr ""
msgstr "Xor"
#. module: base
#: view:res.partner:0
@@ -435,19 +435,19 @@ msgstr ""
#: view:ir.actions.wizard:0
#: field:wizard.ir.model.menu.create.line,wizard_id:0
msgid "Wizard"
msgstr ""
msgstr "Asistente"
#. module: base
#: selection:ir.ui.menu,icon:0
msgid "STOCK_CUT"
msgstr ""
msgstr "STOCK_CUT"
#. module: base
#: model:ir.actions.act_window,name:base.ir_action_wizard
#: view:ir.actions.wizard:0
#: model:ir.ui.menu,name:base.menu_ir_action_wizard
msgid "Wizards"
msgstr ""
msgstr "Asistentes"
#. module: base
#: selection:res.config.view,view:0
+2 -2
View File
@@ -7,13 +7,13 @@ msgstr ""
"Project-Id-Version: OpenERP Server 5.0.4\n"
"Report-Msgid-Bugs-To: support@openerp.com\n"
"POT-Creation-Date: 2009-12-18 08:39+0000\n"
"PO-Revision-Date: 2010-06-17 04:04+0000\n"
"PO-Revision-Date: 2010-06-20 03:58+0000\n"
"Last-Translator: Goran Kliska <gkliska@gmail.com>\n"
"Language-Team: openerp-translators\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-18 03:32+0000\n"
"X-Launchpad-Export-Date: 2010-06-21 03:42+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
"Language: hr\n"
+2 -2
View File
@@ -8,13 +8,13 @@ msgstr ""
"Project-Id-Version: openobject-server\n"
"Report-Msgid-Bugs-To: FULL NAME <EMAIL@ADDRESS>\n"
"POT-Creation-Date: 2009-12-18 08:39+0000\n"
"PO-Revision-Date: 2010-06-17 04:06+0000\n"
"PO-Revision-Date: 2010-06-20 03:57+0000\n"
"Last-Translator: Harry (Open ERP) <hmo@tinyerp.com>\n"
"Language-Team: Japanese <ja@li.org>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-18 03:32+0000\n"
"X-Launchpad-Export-Date: 2010-06-21 03:42+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: base
+2 -2
View File
@@ -7,13 +7,13 @@ msgstr ""
"Project-Id-Version: OpenERP Server 5.0.0\n"
"Report-Msgid-Bugs-To: support@openerp.com\n"
"POT-Creation-Date: 2009-12-18 08:39+0000\n"
"PO-Revision-Date: 2010-06-17 04:07+0000\n"
"PO-Revision-Date: 2010-06-20 03:54+0000\n"
"Last-Translator: Anders Wallenquist <anders.wallenquist@vertel.se>\n"
"Language-Team: <>\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-18 03:32+0000\n"
"X-Launchpad-Export-Date: 2010-06-21 03:42+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: base
+2 -2
View File
@@ -7,13 +7,13 @@ msgstr ""
"Project-Id-Version: OpenERP Server 5.0.0\n"
"Report-Msgid-Bugs-To: support@openerp.com\n"
"POT-Creation-Date: 2009-12-18 08:39+0000\n"
"PO-Revision-Date: 2010-06-17 04:03+0000\n"
"PO-Revision-Date: 2010-06-20 03:59+0000\n"
"Last-Translator: Fabien (Open ERP) <fp@tinyerp.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-18 03:32+0000\n"
"X-Launchpad-Export-Date: 2010-06-21 03:42+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: base
+2 -2
View File
@@ -7,13 +7,13 @@ msgstr ""
"Project-Id-Version: OpenERP Server 5.0.4\n"
"Report-Msgid-Bugs-To: support@openerp.com\n"
"POT-Creation-Date: 2009-12-18 08:39+0000\n"
"PO-Revision-Date: 2010-06-17 04:04+0000\n"
"PO-Revision-Date: 2010-06-20 03:56+0000\n"
"Last-Translator: Eleanor Chen <chenyueg@gmail.com>\n"
"Language-Team: \n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Launchpad-Export-Date: 2010-06-18 03:32+0000\n"
"X-Launchpad-Export-Date: 2010-06-21 03:42+0000\n"
"X-Generator: Launchpad (build Unknown)\n"
#. module: base
+231 -243
View File
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
##############################################################################
#
#
# OpenERP, Open Source Management Solution
# Copyright (C) 2004-2009 Tiny SPRL (<http://tiny.be>).
#
@@ -15,11 +15,12 @@
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
import xmlrpclib
import ConfigParser
import optparse
import sys
import thread
@@ -47,118 +48,8 @@ def to_decode(s):
except UnicodeError:
return s
def clear_log_dir(path):
dirpath = os.path.realpath(path)
if os.path.isdir(path):
for file in os.listdir(dirpath):
sub_path = dirpath + os.sep + file
if os.path.isdir(sub_path):
clear_log_dir(sub_path)
else:
os.remove(sub_path)
os.rmdir(path)
return True
def start_server(root_path, port, netport, addons_path):
logfile = 'test_logs/logs.txt'
os.system('python2.5 %sopenerp-server.py --pidfile=openerp.pid --no-xmlrpcs --xmlrpc-port=%s --netrpc-port=%s --addons-path=%s --logfile=%s' %(root_path, str(port),str(netport),addons_path, logfile))
def create_db(url, dbname, user='admin', pwd='admin', lang='en_US'):
conn = xmlrpclib.ServerProxy(url + '/xmlrpc/db')
obj_conn = xmlrpclib.ServerProxy(url + '/xmlrpc/object')
wiz_conn = xmlrpclib.ServerProxy(url + '/xmlrpc/wizard')
login_conn = xmlrpclib.ServerProxy(url + '/xmlrpc/common')
db_list = execute(conn, 'list')
if dbname in db_list:
execute(conn, 'drop', admin_passwd, dbname)
id = execute(conn,'create',admin_passwd, dbname, True, lang)
wait(id,url)
return True
def login(url, dbname, user, pwd):
conn = xmlrpclib.ServerProxy(url + '/xmlrpc/common')
uid = execute(conn,'login',dbname, user, pwd)
return uid
def install_module(url='', uid=1, pwd='admin', dbname='', module=''):
obj_conn = xmlrpclib.ServerProxy(url + '/xmlrpc/object')
wizard_conn = xmlrpclib.ServerProxy(url + '/xmlrpc/wizard')
module_ids = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module',
'search', [('name','in',[module,'base_module_quality'])])
for action in ('button_install','button_upgrade'):
execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', action, module_ids)
wiz_id = execute(wizard_conn, 'create', dbname, uid, pwd, 'module.upgrade.simple')
state = 'init'
datas = {}
while state!='end':
res = execute(wizard_conn, 'execute', dbname, uid, pwd, wiz_id, datas, state, {})
if state == 'init':
state = 'start'
elif state == 'start':
state = 'end'
return True
def check_quality(url, user, pwd, dbname, module, quality_logs):
uid = login(url, dbname, user, pwd)
quality_logs += 'quality-logs'
if uid:
conn = xmlrpclib.ServerProxy(url + '/xmlrpc/object')
final = {}
qualityresult = {}
test_detail = {}
quality_result = execute(conn,'execute', dbname, uid, pwd,'module.quality.check','check_quality',module)
detail_html = ''
html = '''<html><body><a name="TOP"></a>'''
html +="<h1> Module: %s </h1>"%(quality_result['name'])
html += "<h2> Final score: %s</h2>"%(quality_result['final_score'])
html += "<div id='tabs'>"
html += "<ul>"
for x,y,detail in quality_result['check_detail_ids']:
test = detail.get('name')
msg = detail.get('message','')
score = round(float(detail.get('score',0)),2)
html += "<li><a href=\"#%s\">%s</a></li>"%(test.replace(' ','-'),test)
detail_html +='''<div id=\"%s\"><h3>%s (Score : %s)</h3><font color=red><h5>%s</h5></font>%s</div>'''%(test.replace(' ', '-'), test, score, msg, detail.get('detail', ''))
test_detail[test] = (score,msg,detail.get('detail',''))
html += "</ul>"
html += "%s"%(detail_html)
html += "</div></body></html>"
if not os.path.isdir(quality_logs):
os.mkdir(quality_logs)
fp = open('%s/%s.html'%(quality_logs,module),'wb')
fp.write(to_decode(html))
fp.close()
else:
print 'Login Failed...'
return True
def install_translation(url, uid, pwd, dbname, po_files):
conn = xmlrpclib.ServerProxy(url + '/xmlrpc/wizard')
wiz_id = execute(conn,'create', dbname, uid, pwd, 'module.lang.import')
for file in po_files:
lang,ext = os.path.splitext(file.split('/')[-1])
if ext == '.po':
state = 'init'
datas = {'form':{}}
while state!='end':
res = execute(conn,'execute',dbname, uid, pwd, wiz_id, datas, state, {})
if 'datas' in res:
datas['form'].update( res['datas'].get('form',{}) )
if res['type']=='form':
for field in res['fields'].keys():
datas['form'][field] = res['fields'][field].get('value', False)
state = res['state'][-1][0]
trans_obj = open(file)
datas['form'].update({
'name': lang,
'code': lang,
'data' : base64.encodestring(trans_obj.read())
})
trans_obj.close()
elif res['type']=='action':
state = res['state']
os.system('python2.5 %sopenerp-server.py --pidfile=openerp.pid --no-xmlrpcs --xmlrpc-port=%s --netrpc-port=%s --addons-path=%s' %(root_path, str(port),str(netport),addons_path))
def clean():
if os.path.isfile('openerp.pid'):
ps = open('openerp.pid')
@@ -188,181 +79,278 @@ def execute(connector, method, *args):
wait_count = 0
return res
def wait(id, url=''):
def login(uri, dbname, user, pwd):
conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/common')
uid = execute(conn,'login',dbname, user, pwd)
return uid
def import_translate(uri, user, pwd, dbname, translate_in):
uid = login(uri, dbname, user, pwd)
if uid:
conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/wizard')
wiz_id = execute(conn,'create',dbname, uid, pwd, 'module.lang.import')
for trans_in in translate_in:
lang,ext = os.path.splitext(trans_in.split('/')[-1])
state = 'init'
datas = {'form':{}}
while state!='end':
res = execute(conn,'execute',dbname, uid, pwd, wiz_id, datas, state, {})
if 'datas' in res:
datas['form'].update( res['datas'].get('form',{}) )
if res['type']=='form':
for field in res['fields'].keys():
datas['form'][field] = res['fields'][field].get('value', False)
state = res['state'][-1][0]
trans_obj = open(trans_in)
datas['form'].update({
'name': lang,
'code': lang,
'data' : base64.encodestring(trans_obj.read())
})
trans_obj.close()
elif res['type']=='action':
state = res['state']
def check_quality(uri, user, pwd, dbname, modules, quality_logs):
uid = login(uri, dbname, user, pwd)
quality_logs += 'quality-logs'
if uid:
conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/object')
final = {}
for module in modules:
qualityresult = {}
test_detail = {}
quality_result = execute(conn,'execute', dbname, uid, pwd,'module.quality.check','check_quality',module)
detail_html = ''
html = '''<html><body><a name="TOP"></a>'''
html +="<h1> Module: %s </h1>"%(quality_result['name'])
html += "<h2> Final score: %s</h2>"%(quality_result['final_score'])
html += "<div id='tabs'>"
html += "<ul>"
for x,y,detail in quality_result['check_detail_ids']:
test = detail.get('name')
msg = detail.get('message','')
score = round(float(detail.get('score',0)),2)
html += "<li><a href=\"#%s\">%s</a></li>"%(test.replace(' ','-'),test)
detail_html +='''<div id=\"%s\"><h3>%s (Score : %s)</h3><font color=red><h5>%s</h5></font>%s</div>'''%(test.replace(' ', '-'), test, score, msg, detail.get('detail', ''))
test_detail[test] = (score,msg,detail.get('detail',''))
html += "</ul>"
html += "%s"%(detail_html)
html += "</div></body></html>"
if not os.path.isdir(quality_logs):
os.mkdir(quality_logs)
fp = open('%s/%s.html'%(quality_logs,module),'wb')
fp.write(to_decode(html))
fp.close()
#final[quality_result['name']] = (quality_result['final_score'],html,test_detail)
#fp = open('quality_log.pck','wb')
#pck_obj = pickle.dump(final,fp)
#fp.close()
#print "LOG PATH%s"%(os.path.realpath('quality_log.pck'))
return True
else:
print 'Login Failed...'
clean()
sys.exit(1)
def wait(id,url=''):
progress=0.0
sock2 = xmlrpclib.ServerProxy(url+'/xmlrpc/db')
while not progress==1.0:
progress,users = execute(sock2,'get_progress',admin_passwd, id)
return True
def store_logs(module, step, msg='' , want_html_log = False):
logfile = open('test_logs/logs.txt','r')
mod_log = open('test_logs/%s/%s.txt'%(module, step),'w')
mod_log.write(logfile.read() + '\n' + msg)
mod_log.close()
logfile.close()
logfile = open('test_logs/logs.txt','w')
logfile.write('')
logfile.close()
if want_html_log:
store_html_logs(module)
def create_db(uri, dbname, user='admin', pwd='admin', lang='en_US'):
conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/db')
obj_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/object')
wiz_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/wizard')
login_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/common')
db_list = execute(conn, 'list')
if dbname in db_list:
drop_db(uri, dbname)
id = execute(conn,'create',admin_passwd, dbname, True, lang)
wait(id,uri)
install_module(uri, dbname, ['base_module_quality'],user=user,pwd=pwd)
return True
def store_html_logs(module):
html = '''<html><body><a name="TOP"></a>'''
html +="<h1> Module: %s </h1>"%(module)
html += "<div id='tabs'>"
html += "<ul>"
detail_html = ''
path = os.path.realpath('test_logs') + os.sep + module
for log in os.listdir(path):
log_fp = open(path + os.sep + log, 'r')
step_name, ext = os.path.splitext(log)
data = ''
for line in log_fp.readlines():
data += line + '<br>'
html += "<li><a href=\"#%s\">%s</a></li>"%(step_name, step_name)
detail_html += '''<div id=\"%s\"><h3>%s</h3>%s</div>'''%(step_name, step_name, data)
log_fp.close()
html += "</ul>"
html += "%s"%(detail_html)
html += "</div></body></html>"
html_fp = open(path + os.sep + module +'.html','wb')
html_fp.write(to_decode(html))
html_fp.close()
def drop_db(uri, dbname):
conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/db')
db_list = execute(conn,'list')
if dbname in db_list:
execute(conn, 'drop', admin_passwd, dbname)
return True
def openerp_test(url, rootpath = '', addons='', user='admin', pwd='admin', quality_log='', port=8069, netport=8070):
modules = os.listdir(addons)
for module in modules:
print "Testing Module: ", module
if module == '.bzr':
continue
dbname = module
try:
os.mkdir('test_logs' + os.sep + module)
except OSError:
os.remove('test_logs' + os.sep + module)
os.mkdir('test_logs' + os.sep + module)
# 1: Create Database also drop the database if it exists !:
try:
create_db(url, dbname, user, pwd)
store_logs(module, 'createDB')
except xmlrpclib.Fault, e:
print e.faultString
store_logs(module, 'createDB', want_html_log=True)
continue
except Exception, e:
print e
store_logs(module, 'createDB', want_html_log=True)
continue
def make_links(uri, uid, dbname, source, destination, module, user, pwd):
if module in ('base','quality_integration_server'):
return True
if os.path.islink(destination + '/' + module):
os.unlink(destination + '/' + module)
for path in source:
if os.path.isdir(path + '/' + module):
os.symlink(path + '/' + module, destination + '/' + module)
obj_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/object')
execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'update_list')
module_ids = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'search', [('name','=',module)])
if len(module_ids):
data = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'read', module_ids[0],['name','dependencies_id'])
dep_datas = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module.dependency', 'read', data['dependencies_id'],['name'])
for dep_data in dep_datas:
make_links(uri, uid, dbname, source, destination, dep_data['name'], user, pwd)
return False
uid = login(url, dbname, user, pwd)
# 2: Install the module
try:
install_module(url, uid, pwd, dbname, module)
store_logs(module, 'Install_module', )
except xmlrpclib.Fault, e:
print e.faultString
store_logs(module, 'Install_module', want_html_log=True)
continue
except Exception, e:
print e
store_logs(module, 'Install_module', want_html_log=True)
continue
def install_module(uri, dbname, modules, addons='', extra_addons='', user='admin', pwd='admin'):
uid = login(uri, dbname, user, pwd)
if extra_addons:
extra_addons = extra_addons.split(',')
if uid:
if addons and extra_addons:
for module in modules:
make_links(uri, uid, dbname, extra_addons, addons, module, user, pwd)
# 3: Check Quality of the module
try:
check_quality(url, user, pwd, dbname, module, quality_log)
except xmlrpclib.Fault, e:
print e.faultString
store_logs(module, 'Check_quality', want_html_log=True)
continue
except Exception, e:
print e
store_logs(module, 'Check_quality', want_html_log=True)
continue
#4:Install Translations for the module
try:
if os.path.isdir(addons+'/'+module+'/'+'i18n'):
po_files = os.listdir(addons+'/'+module+'/'+'i18n')
po_file_paths = []
for po_file in po_files:
if module == 'base':
po_link = '%saddons/%s/i18n/%s'%(rootpath, module, po_file)
else:
po_link = '%s/%s/i18n/%s'%(addons, module, po_file)
po_file_paths.append(po_link)
install_translation(url, uid, pwd, dbname, po_file_paths)
store_logs(module, 'Install_translation')
else:
msg = "Translations Not Available for %s! "%(module)
store_logs(module, 'Install_translation', msg)
except xmlrpclib.Fault, e:
print e.faultString
store_logs(module, 'Install_translation', want_html_log=True)
continue
except Exception, e:
print e
store_logs(module, 'Install_translation', want_html_log=True)
continue
store_html_logs(module)
sys.exit(0)
obj_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/object')
wizard_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/wizard')
module_ids = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'search', [('name','in',modules)])
execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'button_install', module_ids)
wiz_id = execute(wizard_conn, 'create', dbname, uid, pwd, 'module.upgrade.simple')
state = 'init'
datas = {}
#while state!='menu':
while state!='end':
res = execute(wizard_conn, 'execute', dbname, uid, pwd, wiz_id, datas, state, {})
if state == 'init':
state = 'start'
elif state == 'start':
state = 'end'
return True
def upgrade_module(uri, dbname, modules, user='admin', pwd='admin'):
uid = login(uri, dbname, user, pwd)
if uid:
obj_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/object')
wizard_conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/wizard')
module_ids = execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'search', [('name','in',modules)])
execute(obj_conn, 'execute', dbname, uid, pwd, 'ir.module.module', 'button_upgrade', module_ids)
wiz_id = execute(wizard_conn, 'create', dbname, uid, pwd, 'module.upgrade.simple')
state = 'init'
datas = {}
#while state!='menu':
while state!='end':
res = execute(wizard_conn, 'execute', dbname, uid, pwd, wiz_id, datas, state, {})
if state == 'init':
state = 'start'
elif state == 'start':
state = 'end'
return True
usage = """%prog command [options]
Basic Command:
This command will do the following tests on the modules:
openerp-test:
1: Start Server
2: Create new database
3: Drop database if it exists
4: Install module from addons one by one.
5: Install translation file for each module.
6: Calculate quality and dump quality result into quality_log.pck using pickle
Basic Commands:
start-server Start Server
create-db Create new database
drop-db Drop database
install-module Install module
upgrade-module Upgrade module
install-translation Install translation file
check-quality Calculate quality and dump quality result into quality_log.pck using pickle
"""
parser = optparse.OptionParser(usage)
parser.add_option("--modules", dest="modules",
help="specify modules to install or check quality")
parser.add_option("--addons-path", dest="addons_path", help="specify the addons path")
parser.add_option("--root-path", dest="root_path", help="specify the root path")
parser.add_option("--quality-logs", dest="quality_logs", help="specify the path of quality logs files which has to stores")
parser.add_option("--root-path", dest="root_path", help="specify the root path")
parser.add_option("-p", "--port", dest="port", help="specify the TCP port", type="int")
parser.add_option("--net_port", dest="netport",help="specify the TCP port for netrpc")
parser.add_option("-d", "--database", dest="db_name", help="specify the database name")
parser.add_option("--login", dest="login", help="specify the User Login")
parser.add_option("--password", dest="pwd", help="specify the User Password")
parser.add_option("--translate-in", dest="translate_in",
help="specify .po files to import translation terms")
parser.add_option("--extra-addons", dest="extra_addons",
help="specify extra_addons and trunkCommunity modules path ")
(opt, args) = parser.parse_args()
if len(args) != 1:
parser.error("incorrect number of arguments")
command = args[0]
if not command == 'openerp-test':
if command not in ('start-server','create-db','drop-db','install-module','upgrade-module','check-quality','install-translation'):
parser.error("incorrect command")
def die(cond, msg):
if cond:
print msg
sys.exit(1)
die(opt.modules and (not opt.db_name),
"the modules option cannot be used without the database (-d) option")
die(opt.translate_in and (not opt.db_name),
"the translate-in option cannot be used without the database (-d) option")
options = {
'addons-path' : opt.addons_path or 'addons',
'quality-logs' : opt.quality_logs or '',
'root-path' : opt.root_path or '',
'translate-in': [],
'port' : opt.port or 8069,
'netport':opt.netport or 8070,
'database': opt.db_name or 'terp',
'modules' : opt.modules or [],
'login' : opt.login or 'admin',
'pwd' : opt.pwd or '',
'extra-addons':opt.extra_addons or []
}
url = 'http://localhost:' + str(options['port'])
options['modules'] = opt.modules and map(lambda m: m.strip(), opt.modules.split(',')) or []
# Hint:i18n-import=purchase:ar_AR.po+sale:fr_FR.po,nl_BE.po
if opt.translate_in:
translate = opt.translate_in
for module_name,po_files in map(lambda x:tuple(x.split(':')),translate.split('+')):
for po_file in po_files.split(','):
if module_name == 'base':
po_link = '%saddons/%s/i18n/%s'%(options['root-path'],module_name,po_file)
else:
po_link = '%s/%s/i18n/%s'%(options['addons-path'], module_name, po_file)
options['translate-in'].append(po_link)
uri = 'http://localhost:' + str(options['port'])
server_thread = threading.Thread(target=start_server,
args=(options['root-path'], options['port'],options['netport'], options['addons-path']))
try:
server_thread.start()
if command == 'create-db':
create_db(uri, options['database'], options['login'], options['pwd'])
if command == 'drop-db':
drop_db(uri, options['database'])
if command == 'install-module':
install_module(uri, options['database'], options['modules'],options['addons-path'],options['extra-addons'],options['login'], options['pwd'])
if command == 'upgrade-module':
upgrade_module(uri, options['database'], options['modules'], options['login'], options['pwd'])
if command == 'check-quality':
check_quality(uri, options['login'], options['pwd'], options['database'], options['modules'], options['quality-logs'])
if command == 'install-translation':
import_translate(uri, options['login'], options['pwd'], options['database'], options['translate-in'])
clean()
sys.exit(0)
clear_log_dir('test_logs')
os.mkdir('test_logs')
server_thread.start()
except xmlrpclib.Fault, e:
print e.faultString
clean()
sys.exit(1)
except Exception, e:
print e
clean()
sys.exit(1)
openerp_test(url, options['root-path'], options['addons-path'],
options['login'], options['pwd'], options['quality-logs'], options['port'],options['netport'])
clean()
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4: