[FIX] better log error, new line

bzr revid: fp@tinyerp.com-20090909145411-8k6rksq74xyz1nw4
This commit is contained in:
Fabien Pinckaers 2009-09-09 16:54:11 +02:00
commit 9513616ae1
6 changed files with 62 additions and 20 deletions

View File

@ -143,6 +143,33 @@ class ir_translation(osv.osv):
res = cr.fetchone()
trad = res and res[0] or ''
return trad
def create(self, cursor, user, vals, context=None):
if not context:
context = {}
ids = super(ir_translation, self).create(cursor, user, vals, context=context)
for trans_obj in self.read(cursor, user, [ids], ['name','type','res_id'], context=context):
self._get_source.clear_cache(cursor.dbname, user, trans_obj['name'], trans_obj['type'], lang=context.get('lang','en_US'))
self._get_ids.clear_cache(cursor.dbname, user, trans_obj['name'], trans_obj['type'], context.get('lang','en_US'), [trans_obj['res_id']])
return ids
def write(self, cursor, user, ids, vals, context=None):
if not context:
context = {}
result = super(ir_translation, self).write(cursor, user, ids, vals, context=context)
for trans_obj in self.read(cursor, user, ids, ['name','type','res_id'], context=context):
self._get_source.clear_cache(cursor.dbname, user, trans_obj['name'], trans_obj['type'], lang=context.get('lang','en_US'))
self._get_ids.clear_cache(cursor.dbname, user, trans_obj['name'], trans_obj['type'], context.get('lang','en_US'), [trans_obj['res_id']])
return result
def unlink(self, cursor, user, ids, context=None):
if not context:
context = {}
for trans_obj in self.read(cursor, user, ids, ['name','type','res_id'], context=context):
self._get_source.clear_cache(cursor.dbname, user, trans_obj['name'], trans_obj['type'], lang=context.get('lang','en_US'))
self._get_ids.clear_cache(cursor.dbname, user, trans_obj['name'], trans_obj['type'], context.get('lang','en_US'), [trans_obj['res_id']])
result = super(ir_translation, self).unlink(cursor, user, ids, context=context)
return result
ir_translation()

View File

@ -34,6 +34,8 @@ import socket
admin_passwd = 'admin'
waittime = 10
wait_count = 0
wait_limit = 12
def start_server(root_path, port, addons_path):
if root_path:
@ -47,19 +49,27 @@ def clean():
ps.close()
if pid:
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')
@ -107,16 +117,16 @@ def check_quality(uri, user, pwd, dbname, modules):
html = '''<html><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 += "<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)
html += "<div id='tabs'>"
html += "<ul>"
for x,y,detail in quality_result['check_detail_ids']:
test = detail.get('name')
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>%s</div>"%(test.replace(' ','-'),test,score,detail.get('detail'))
test_detail[test] = (score,detail.get('detail',''))
html += "</ul>%s</body></html></html></html></html></html>"%(detail_html)
html += "</div>"
final[quality_result['name']] = (quality_result['final_score'],html,test_detail)
fp = open('quality_log.pck','wb')
@ -127,7 +137,7 @@ def check_quality(uri, user, pwd, dbname, modules):
else:
print 'Login Failed...'
clean()
sys.exit(1)
sys.exit(1)

View File

@ -173,7 +173,7 @@ class Logger(object):
msg = tools.ustr(msg).strip()
if level in (LOG_ERROR,LOG_CRITICAL):
msg = common().get_server_environment() + msg
msg = common().get_server_environment() + '\n' + msg
result = msg.split('\n')
if len(result)>1:

View File

@ -497,7 +497,7 @@ class orm_template(object):
for rr in r :
if isinstance(rr.name, browse_record):
rr = rr.name
dt+=rr.name+','
dt += rr.name or '' + ','
data[fpos] = dt[:-1]
break
lines += lines2[1:]

View File

@ -156,7 +156,7 @@ class rml_parse(object):
self.cr = cr
self.uid = uid
self.pool = pooler.get_pool(cr.dbname)
user = self.pool.get('res.users').browse(cr, uid, uid)
user = self.pool.get('res.users').browse(cr, uid, uid, context=context)
self.localcontext = {
'user': user,
'company': user.company_id,

View File

@ -331,7 +331,10 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non
email_bcc = []
if not attach:
msg = MIMEText(body.encode('utf-8') or '',_subtype=subtype,_charset='utf-8')
try:
msg = MIMEText(body.encode('utf8') or '',_subtype=subtype,_charset='utf-8')
except:
msg = MIMEText(body or '',_subtype=subtype,_charset='utf-8')
else:
msg = MIMEMultipart()
@ -362,8 +365,10 @@ def email_send(email_from, email_to, subject, body, email_cc=None, email_bcc=Non
msg['Message-Id'] = "<%s-tinycrm-%s@%s>" % (time.time(), tinycrm, socket.gethostname())
if attach:
msg.attach( MIMEText(body.encode('utf-8') or '', _charset='utf-8', _subtype=subtype) )
try:
msg.attach(MIMEText(body.encode('utf8') or '',_subtype=subtype,_charset='utf-8'))
except:
msg.attach(MIMEText(body or '', _charset='utf-8', _subtype=subtype) )
for (fname,fcontent) in attach:
part = MIMEBase('application', "octet-stream")
part.set_payload( fcontent )