diff options
| author | P. Christeas <p_christ@hol.gr> | 2009-09-25 23:49:10 +0300 |
|---|---|---|
| committer | P. Christeas <p_christ@hol.gr> | 2009-09-25 23:49:10 +0300 |
| commit | afd06e6bf2f2b5be4b0de9b5056ace5c36f134fc (patch) | |
| tree | a74fcdf376891f0ad3170f3195a8dcc948ecac92 /bin/addons/quality_integration_server/base_quality_interrogation.py | |
| parent | 0e20fddb08e411de92cde6be4f68c029c7aac863 (diff) | |
| parent | 244de09ee563f0e72fa6330c71f316415bb690ad (diff) | |
Merge remote branch 'origin/master' v5.0.6 into xrg
Conflicts:
bin/addons/base/ir/ir_cron.py
bin/netsvc.py
bzr revid: p_christ@hol.gr-20090925204910-uhwimwgfgm94hujn
Diffstat (limited to 'bin/addons/quality_integration_server/base_quality_interrogation.py')
| -rwxr-xr-x | bin/addons/quality_integration_server/base_quality_interrogation.py | 132 |
1 files changed, 94 insertions, 38 deletions
diff --git a/bin/addons/quality_integration_server/base_quality_interrogation.py b/bin/addons/quality_integration_server/base_quality_interrogation.py index 2df0af247c7..3f3010350f3 100755 --- a/bin/addons/quality_integration_server/base_quality_interrogation.py +++ b/bin/addons/quality_integration_server/base_quality_interrogation.py @@ -34,11 +34,11 @@ import socket admin_passwd = 'admin' waittime = 10 +wait_count = 0 +wait_limit = 12 -def start_server(root_path, port, addons_path): - if root_path: - root_path += '/' - os.system('python2.5 '+root_path+'openerp-server.py --pidfile=openerp.pid --port=%s --no-netrpc --addons-path=%s' %(str(port),addons_path)) +def start_server(root_path, port, addons_path): + os.system('python2.5 %sopenerp-server.py --pidfile=openerp.pid --port=%s --no-netrpc --addons-path=%s' %(root_path, str(port), addons_path)) def clean(): if os.path.isfile('openerp.pid'): ps = open('openerp.pid') @@ -49,17 +49,24 @@ def clean(): os.kill(pid,9) def execute(connector, method, *args): + global wait_count res = False try: res = getattr(connector,method)(*args) except socket.error,e: - if e.args[0] == 111: + if e.args[0] == 111: + if wait_count > wait_limit: + print "Server is taking too long to start, it has exceeded the maximum limit of %d seconds."%(wait_limit) + clean() + sys.exit(1) print 'Please wait %d sec to start server....'%(waittime) + wait_count += 1 time.sleep(waittime) res = execute(connector, method, *args) else: raise e - return res + wait_count = 0 + return res def login(uri, dbname, user, pwd): conn = xmlrpclib.ServerProxy(uri + '/xmlrpc/common') @@ -94,40 +101,51 @@ def import_translate(uri, user, pwd, dbname, translate_in): state = res['state'] -def check_quality(uri, user, pwd, dbname, modules): +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') - qualityresult = {} final = {} - test_detail = {} - for module in modules: + 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><html><html><html><body><a name="TOP"></a>''' + 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 += "<oi>" - for x,y,detail in quality_result['check_detail_ids']: - if detail.get('detail') != '': - test = detail.get('name') - score = round(float(detail.get('score',0)),2) - html += "<li><a href=\"#%s\">%s (%.2f)</a></li>"%(test,test,score) - detail_html +="<a name=\"%s\"><h3>%s (Score : %s)</h3>%s</a>"%(test,test,score,detail.get('detail')) - detail_html +='''<a href="#TOP">Go to Top</a>''' - test_detail[test] = (score,detail.get('detail','')) - html += "</oi>%s</body></html></html></html></html></html>"%(detail_html) - 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 final + 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) + if test == 'Unit Test': + if not detail.get('detail',''): + detail['detail'] = '''<html><body><b>%s</b></body></html>'''%(detail.get('summary','')) + detail_html +="<div id=\"%s\"><h3>%s (Score : %s)</h3>%s</div>"%(test.replace(' ','-'),test,score,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(str(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) + sys.exit(1) @@ -169,7 +187,7 @@ def create_db(uri, dbname, user='admin', pwd='admin', lang='en_US'): elif res['type']=='state': state = res['state'] res = execute(wiz_conn, 'execute', dbname, uid, pwd, wiz_id, datas, state, {}) - install_module(uri, dbname, ['base_module_quality'],user,pwd) + install_module(uri, dbname, ['base_module_quality'],user=user,pwd=pwd) return True def drop_db(uri, dbname): @@ -178,13 +196,38 @@ def drop_db(uri, dbname): if dbname in db_list: execute(conn, 'drop', admin_passwd, dbname) return True - -def install_module(uri, dbname, modules, user='admin', pwd='admin'): + +def make_links(uri, uid, dbname, source, destination, module, user, pwd): + if module in ('base','quality_integration_server'): + return True + if not os.path.islink(destination + '/' + module): + if not os.path.isdir(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 True + return False + +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) + 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)]) + 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' @@ -237,6 +280,7 @@ 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("--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("-d", "--database", dest="db_name", help="specify the database name") @@ -244,6 +288,9 @@ 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") @@ -264,17 +311,26 @@ die(opt.translate_in and (not opt.db_name), options = { 'addons-path' : opt.addons_path or 'addons', + 'quality-logs' : opt.quality_logs or '', 'root-path' : opt.root_path or '', - 'translate-in': opt.translate_in, + 'translate-in': [], 'port' : opt.port or 8069, '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 [] } options['modules'] = opt.modules and map(lambda m: m.strip(), opt.modules.split(',')) or [] -options['translate_in'] = opt.translate_in and map(lambda m: m.strip(), opt.translate_in.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(','): + 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, @@ -286,13 +342,13 @@ try: if command == 'drop-db': drop_db(uri, options['database']) if command == 'install-module': - install_module(uri, options['database'], options['modules'], options['login'], options['pwd']) + 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']) + 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']) + import_translate(uri, options['login'], options['pwd'], options['database'], options['translate-in']) clean() sys.exit(0) |
