From 49f8d24d4a77f634125cb2b8c24c0be96e31e33c Mon Sep 17 00:00:00 2001 From: "P. Christeas" <> Date: Tue, 7 Sep 2010 15:20:55 +0530 Subject: [FIX]module_quality: trivial logging, multi-addons paths, Fix exceptions, use separate db cursors. Log some of the exceptions that occur, so that we can understand why our tests fail. Run each test on its own cursor, don't let SQL errors render the whole bzr revid: hmo@tinyerp.com-20100907095055-9sa11rnvir8y7npw --- addons/base_module_quality/base_module_quality.py | 41 ++++++++++++++--------- 1 file changed, 25 insertions(+), 16 deletions(-) (limited to 'addons/base_module_quality/base_module_quality.py') diff --git a/addons/base_module_quality/base_module_quality.py b/addons/base_module_quality/base_module_quality.py index 637eb9e22b6..d7ac2f77700 100644 --- a/addons/base_module_quality/base_module_quality.py +++ b/addons/base_module_quality/base_module_quality.py @@ -21,13 +21,10 @@ import os import pooler -import osv -import tools -from tools import config from tools.translate import _ from osv import osv, fields import logging - +import addons class abstract_quality_check(object): ''' This Class is abstract class for all test @@ -86,12 +83,10 @@ class abstract_quality_check(object): #The tests have to subscribe itselfs in this list, that contains #all the test that have to be performed. self.tests = [] - self.list_folders = os.listdir(config['addons_path'] + - '/base_module_quality/') - for item in self.list_folders: - self.item = item - path = config['addons_path']+'/base_module_quality/'+item - if os.path.exists(path + '/' + item + '.py') and item not in ['report', 'wizard', 'security']: + module_path = addons.get_module_path('base_module_quality') + for item in os.listdir(module_path): + path = module_path + '/' + item + if os.path.isdir(path) and os.path.exists(path + '/' + item + '.py') and item not in ['report', 'wizard', 'security']: item2 = 'base_module_quality.' + item +'.' + item x_module = __import__(item2) x_file = getattr(x_module, item) @@ -216,6 +211,7 @@ class module_quality_check(osv.osv): So here the detail result is in html format and summary will be in text_wiki format. ''' pool = pooler.get_pool(cr.dbname) + log = logging.getLogger('module.quality') obj_module = pool.get('ir.module.module') if not module_state: module_id = obj_module.search(cr, uid, [('name', '=', module_name)]) @@ -226,15 +222,22 @@ class module_quality_check(osv.osv): score_sum = 0.0 ponderation_sum = 0.0 create_ids = [] + module_path = addons.get_module_path(module_name) + log.info('Performing quality tests for %s', module_name) for test in abstract_obj.tests: - ad = tools.config['addons_path'] - if module_name == 'base': - ad = tools.config['root_path']+'/addons' - module_path = os.path.join(ad, module_name) val = test.quality_test() - if val.active: + if not val.active: + log.info('Skipping inactive step %s for %s', val.name, module_name) + continue + + log.info('Performing step %s for %s', val.name, module_name) + # Get a separate cursor per test, so that an SQL error in one + # will not block the others. + cr2 = pooler.get_db(cr.dbname).cursor() + + try: if not val.bool_installed_only or module_state == "installed": - val.run_test(cr, uid, str(module_path)) + val.run_test(cr2, uid, str(module_path)) if not val.error: data = { 'name': val.name, @@ -266,6 +269,12 @@ class module_quality_check(osv.osv): 'summary': _("The module has to be installed before running this test.") } create_ids.append((0, 0, data)) + log.info('Finished quality test step') + except Exception, e: + log.exception("Could not finish test step %s due to %s", val.name, e) + finally: + cr2.rollback() + cr2.close() final_score = ponderation_sum and '%.2f' % (score_sum / ponderation_sum * 100) or 0 data = { 'name': module_name, -- cgit v1.2.3