[MERGE] report & netrpc protocol: Use the cPickle 2.0 protocol and clean the code of report
bzr revid: stw@openerp.com-20120911091836-ac0wdxqslcwwbku6
This commit is contained in:
commit
c735a2c0ec
|
@ -30,7 +30,6 @@ GNU Public Licence.
|
|||
(c) 2003-TODAY, Fabien Pinckaers - OpenERP SA
|
||||
"""
|
||||
|
||||
import imp
|
||||
import logging
|
||||
import os
|
||||
import signal
|
||||
|
@ -203,7 +202,7 @@ def quit_on_signals():
|
|||
try:
|
||||
while quit_signals_received == 0:
|
||||
time.sleep(60)
|
||||
except KeyboardInterrupt, e:
|
||||
except KeyboardInterrupt:
|
||||
pass
|
||||
|
||||
if config['pidfile']:
|
||||
|
|
|
@ -86,12 +86,12 @@ class Service(object):
|
|||
cls._services.pop(name)
|
||||
|
||||
def LocalService(name):
|
||||
# Special case for addons support, will be removed in a few days when addons
|
||||
# are updated to directly use openerp.osv.osv.service.
|
||||
if name == 'object_proxy':
|
||||
return openerp.osv.osv.service
|
||||
# Special case for addons support, will be removed in a few days when addons
|
||||
# are updated to directly use openerp.osv.osv.service.
|
||||
if name == 'object_proxy':
|
||||
return openerp.osv.osv.service
|
||||
|
||||
return Service._services[name]
|
||||
return Service._services[name]
|
||||
|
||||
class ExportService(object):
|
||||
""" Proxy for exported services.
|
||||
|
@ -238,9 +238,9 @@ def init_logger():
|
|||
# server intended to test it.
|
||||
def init_alternative_logger():
|
||||
class H(logging.Handler):
|
||||
def emit(self, record):
|
||||
if record.levelno > 20:
|
||||
print record.levelno, record.pathname, record.msg
|
||||
def emit(self, record):
|
||||
if record.levelno > 20:
|
||||
print record.levelno, record.pathname, record.msg
|
||||
handler = H()
|
||||
# Add the handler to the 'openerp' logger.
|
||||
logger = logging.getLogger('openerp')
|
||||
|
|
|
@ -892,8 +892,8 @@ class BaseModel(object):
|
|||
for c in cls.__dict__.get(s, []):
|
||||
exist = False
|
||||
for c2 in range(len(new)):
|
||||
#For _constraints, we should check field and methods as well
|
||||
if new[c2][2]==c[2] and (new[c2][0] == c[0] \
|
||||
#For _constraints, we should check field and methods as well
|
||||
if new[c2][2]==c[2] and (new[c2][0] == c[0] \
|
||||
or getattr(new[c2][0],'__name__', True) == \
|
||||
getattr(c[0],'__name__', False)):
|
||||
# If new class defines a constraint with
|
||||
|
@ -1308,7 +1308,7 @@ class BaseModel(object):
|
|||
if not line[i]:
|
||||
continue
|
||||
|
||||
if field[:len(prefix)] <> prefix:
|
||||
if field[:len(prefix)] != prefix:
|
||||
if line[i] and skip:
|
||||
return False
|
||||
continue
|
||||
|
@ -2709,7 +2709,7 @@ class BaseModel(object):
|
|||
# if val is a many2one, just write the ID
|
||||
if type(val) == tuple:
|
||||
val = val[0]
|
||||
if (val<>False) or (type(val)<>bool):
|
||||
if val is not False:
|
||||
cr.execute(update_query, (ss[1](val), key))
|
||||
|
||||
def _check_selection_field_value(self, cr, uid, field, value, context=None):
|
||||
|
@ -2733,7 +2733,7 @@ class BaseModel(object):
|
|||
elif val in dict(self._columns[field].selection(self, cr, uid, context=context)):
|
||||
return
|
||||
raise except_orm(_('ValidateError'),
|
||||
_('The value "%s" for the field "%s.%s" is not in the selection') % (value, self._table, field))
|
||||
_('The value "%s" for the field "%s.%s" is not in the selection') % (value, self._table, field))
|
||||
|
||||
def _check_removed_columns(self, cr, log=False):
|
||||
# iterate on the database columns to drop the NOT NULL constraints
|
||||
|
|
|
@ -21,7 +21,6 @@
|
|||
|
||||
import os
|
||||
import time
|
||||
import openerp.netsvc as netsvc
|
||||
|
||||
import openerp.tools as tools
|
||||
from openerp.tools.safe_eval import safe_eval as eval
|
||||
|
@ -67,7 +66,6 @@ class report_custom(report_int):
|
|||
#
|
||||
def _row_get(self, cr, uid, objs, fields, conditions, row_canvas=None, group_by=None):
|
||||
result = []
|
||||
tmp = []
|
||||
for obj in objs:
|
||||
tobreak = False
|
||||
for cond in conditions:
|
||||
|
@ -108,7 +106,7 @@ class report_custom(report_int):
|
|||
key = levels.keys()
|
||||
for l in key:
|
||||
objs = eval('obj.'+l,{'obj': obj})
|
||||
if not isinstance(objs, browse_record_list) and type(objs) <> type([]):
|
||||
if not isinstance(objs, (browse_record_list, list)):
|
||||
objs = [objs]
|
||||
field_new = []
|
||||
cond_new = []
|
||||
|
@ -221,11 +219,9 @@ class report_custom(report_int):
|
|||
res_dic[prev].append(line)
|
||||
else:
|
||||
prev = line[groupby]
|
||||
if res_dic.has_key(line[groupby]):
|
||||
res_dic[line[groupby]].append(line)
|
||||
else:
|
||||
res_dic[line[groupby]] = []
|
||||
res_dic[line[groupby]].append(line)
|
||||
res_dic.setdefault(line[groupby], [])
|
||||
res_dic[line[groupby]].append(line)
|
||||
|
||||
#we use the keys in results since they are ordered, whereas in res_dic.heys() they aren't
|
||||
for key in filter(None, [x[groupby] for x in results]):
|
||||
row = []
|
||||
|
@ -267,7 +263,7 @@ class report_custom(report_int):
|
|||
else:
|
||||
try:
|
||||
row.append(float(r[j]))
|
||||
except:
|
||||
except Exception:
|
||||
row.append(r[j])
|
||||
results2.append(row)
|
||||
if report['type']=='pie':
|
||||
|
@ -365,7 +361,6 @@ class report_custom(report_int):
|
|||
order_date['Y'] = lambda x : x
|
||||
|
||||
abscissa = []
|
||||
tmp = {}
|
||||
|
||||
idx = 0
|
||||
date_idx = None
|
||||
|
@ -389,7 +384,7 @@ class report_custom(report_int):
|
|||
if date_idx != None:
|
||||
for r in results:
|
||||
key = process_date['Y'](r[date_idx])
|
||||
if not data_by_year.has_key(key):
|
||||
if key not in data_by_year:
|
||||
data_by_year[key] = []
|
||||
for i in range(len(r)):
|
||||
r[i] = fct[i](r[i])
|
||||
|
@ -407,14 +402,14 @@ class report_custom(report_int):
|
|||
for d in data_by_year[line]:
|
||||
for idx in range(len(fields)-1):
|
||||
fields_bar.append({})
|
||||
if fields_bar[idx].has_key(d[0]):
|
||||
if d[0] in fields_bar[idx]:
|
||||
fields_bar[idx][d[0]] += d[idx+1]
|
||||
else:
|
||||
fields_bar[idx][d[0]] = d[idx+1]
|
||||
for idx in range(len(fields)-1):
|
||||
data = {}
|
||||
for k in fields_bar[idx].keys():
|
||||
if data.has_key(k):
|
||||
if k in data:
|
||||
data[k] += fields_bar[idx][k]
|
||||
else:
|
||||
data[k] = fields_bar[idx][k]
|
||||
|
@ -488,7 +483,7 @@ class report_custom(report_int):
|
|||
if date_idx != None:
|
||||
for r in results:
|
||||
key = process_date['Y'](r[date_idx])
|
||||
if not data_by_year.has_key(key):
|
||||
if key not in data_by_year:
|
||||
data_by_year[key] = []
|
||||
for i in range(len(r)):
|
||||
r[i] = fct[i](r[i])
|
||||
|
@ -507,14 +502,14 @@ class report_custom(report_int):
|
|||
for d in data_by_year[line]:
|
||||
for idx in range(len(fields)-1):
|
||||
fields_bar.append({})
|
||||
if fields_bar[idx].has_key(d[0]):
|
||||
if d[0] in fields_bar[idx]:
|
||||
fields_bar[idx][d[0]] += d[idx+1]
|
||||
else:
|
||||
fields_bar[idx][d[0]] = d[idx+1]
|
||||
for idx in range(len(fields)-1):
|
||||
data = {}
|
||||
for k in fields_bar[idx].keys():
|
||||
if data.has_key(k):
|
||||
if k in data:
|
||||
data[k] += fields_bar[idx][k]
|
||||
else:
|
||||
data[k] = fields_bar[idx][k]
|
||||
|
|
|
@ -44,8 +44,8 @@ class report_int(netsvc.Service):
|
|||
def __init__(self, name):
|
||||
assert not self.exists(name), 'The report "%s" already exists!' % name
|
||||
super(report_int, self).__init__(name)
|
||||
if name[0:7]<>'report.':
|
||||
raise Exception, 'ConceptionError, bad report name, should start with "report."'
|
||||
if not name.startswith('report.'):
|
||||
raise Exception('ConceptionError, bad report name, should start with "report."')
|
||||
self.name = name
|
||||
self.id = 0
|
||||
self.name2 = '.'.join(name.split('.')[1:])
|
||||
|
@ -181,7 +181,7 @@ class report_rml(report_int):
|
|||
|
||||
def create_pdf(self, rml, localcontext = None, logo=None, title=None):
|
||||
if not localcontext:
|
||||
localcontext={}
|
||||
localcontext = {}
|
||||
localcontext.update({'internal_header':self.internal_header})
|
||||
if logo:
|
||||
self.bin_datas['logo'] = logo
|
||||
|
|
|
@ -48,7 +48,7 @@ class report(object):
|
|||
try:
|
||||
while n.tag != txt.group(3):
|
||||
n = n.getparent()
|
||||
except:
|
||||
except Exception:
|
||||
n = node
|
||||
else:
|
||||
n = node.getparent()
|
||||
|
|
|
@ -200,7 +200,7 @@ class document(object):
|
|||
else:
|
||||
args = []
|
||||
# get the object
|
||||
if attrs.has_key('model'):
|
||||
if 'model' in attrs:
|
||||
obj = self.pool.get(attrs['model'])
|
||||
else:
|
||||
if isinstance(browser, list):
|
||||
|
@ -209,7 +209,7 @@ class document(object):
|
|||
obj = browser._table
|
||||
|
||||
# get the ids
|
||||
if attrs.has_key('ids'):
|
||||
if 'ids' in attrs:
|
||||
ids = self.eval(browser, attrs['ids'])
|
||||
else:
|
||||
if isinstance(browser, list):
|
||||
|
@ -228,7 +228,7 @@ class document(object):
|
|||
if not isinstance(datas[atr['value']], (str, unicode)):
|
||||
txt = str(datas[atr['value']])
|
||||
else:
|
||||
txt = datas[atr['value']]
|
||||
txt = datas[atr['value']]
|
||||
el.text = txt
|
||||
else:
|
||||
for el_cld in node:
|
||||
|
|
|
@ -120,7 +120,7 @@ class report_printscreen_list(report_int):
|
|||
line[f]=round(line[f],precision)
|
||||
col = etree.SubElement(node_line, 'col', tree='no')
|
||||
if line[f] != None:
|
||||
col.text = tools.ustr(line[f] or '')
|
||||
col.text = tools.ustr(line[f] or '')
|
||||
else:
|
||||
col.text = '/'
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ class report_printscreen_list(report_int):
|
|||
def _parse_string(self, view):
|
||||
try:
|
||||
dom = etree.XML(view.encode('utf-8'))
|
||||
except:
|
||||
except Exception:
|
||||
dom = etree.XML(view)
|
||||
return self._parse_node(dom)
|
||||
|
||||
|
|
|
@ -20,9 +20,7 @@
|
|||
##############################################################################
|
||||
|
||||
from openerp.report.render.rml2pdf import utils
|
||||
from lxml import etree
|
||||
import copy
|
||||
import openerp.pooler as pooler
|
||||
import base64
|
||||
import cStringIO
|
||||
import re
|
||||
|
|
|
@ -23,8 +23,7 @@ import mako
|
|||
from lxml import etree
|
||||
from mako.template import Template
|
||||
from mako.lookup import TemplateLookup
|
||||
import openerp.netsvc as netsvc
|
||||
import traceback, sys, os
|
||||
import os
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -126,9 +125,8 @@ class makohtml2html(object):
|
|||
final_html += self.format_header(etree_obj)
|
||||
final_html += self.format_body(etree_obj)
|
||||
return final_html
|
||||
except Exception,e:
|
||||
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||
_logger.error('report :\n%s\n%s\n', tb_s, str(e))
|
||||
except Exception:
|
||||
_logger.exception('report :')
|
||||
|
||||
def parseNode(html, localcontext = {}):
|
||||
r = makohtml2html(html, localcontext)
|
||||
|
|
|
@ -20,7 +20,6 @@
|
|||
##############################################################################
|
||||
|
||||
from openerp.report.render.rml2pdf import utils
|
||||
from lxml import etree
|
||||
import copy
|
||||
|
||||
class odt2odt(object):
|
||||
|
|
|
@ -39,7 +39,7 @@ import sys
|
|||
import cStringIO
|
||||
from lxml import etree
|
||||
import copy
|
||||
import utils
|
||||
|
||||
from openerp.report.render.rml2pdf import utils
|
||||
|
||||
class _flowable(object):
|
||||
|
@ -98,7 +98,7 @@ class _flowable(object):
|
|||
try:
|
||||
if new_child.get('style').find('terp_tblheader')!= -1:
|
||||
new_node.tag = 'th'
|
||||
except:
|
||||
except Exception:
|
||||
pass
|
||||
process(node,new_node)
|
||||
if new_node.get('colWidths',False):
|
||||
|
@ -232,7 +232,7 @@ class _rml_stylesheet(object):
|
|||
attr = {}
|
||||
attrs = ps.attrib
|
||||
for key, val in attrs.items():
|
||||
attr[key] = val
|
||||
attr[key] = val
|
||||
attrs = []
|
||||
for a in attr:
|
||||
if a in self._tags:
|
||||
|
@ -296,13 +296,13 @@ class _rml_template(object):
|
|||
frames[(posy,posx,tmpl.get('id'))] = _rml_tmpl_frame(posx, utils.unit_get(tmpl.get('width')))
|
||||
for tmpl in pt.findall('pageGraphics'):
|
||||
for n in tmpl:
|
||||
if n.tag == 'image':
|
||||
self.data = rc + utils._process_text(self, n.text)
|
||||
if n.tag in self._tags:
|
||||
t = self._tags[n.tag](n, self.style,self.localcontext)
|
||||
frames[(t.posy,t.posx,n.tag)] = t
|
||||
else:
|
||||
self.style.update(n)
|
||||
if n.tag == 'image':
|
||||
self.data = rc + utils._process_text(self, n.text)
|
||||
if n.tag in self._tags:
|
||||
t = self._tags[n.tag](n, self.style,self.localcontext)
|
||||
frames[(t.posy,t.posx,n.tag)] = t
|
||||
else:
|
||||
self.style.update(n)
|
||||
keys = frames.keys()
|
||||
keys.sort()
|
||||
keys.reverse()
|
||||
|
|
|
@ -82,7 +82,7 @@ class NumberedCanvas(canvas.Canvas):
|
|||
def showPage(self):
|
||||
self._currentPage +=1
|
||||
if not self._flag:
|
||||
self._pageCount += 1
|
||||
self._pageCount += 1
|
||||
else:
|
||||
self.pages.update({self._currentPage:self._pageCount})
|
||||
self._codes.append({'code': self._code, 'stack': self._codeStack})
|
||||
|
@ -424,7 +424,7 @@ class _rml_canvas(object):
|
|||
flow.drawOn(self.canvas,infos['x'],infos['y'])
|
||||
infos['height']-=h
|
||||
else:
|
||||
raise ValueError, "Not enough space"
|
||||
raise ValueError("Not enough space")
|
||||
|
||||
def _line_mode(self, node):
|
||||
ljoin = {'round':1, 'mitered':0, 'bevelled':2}
|
||||
|
|
|
@ -22,9 +22,7 @@
|
|||
|
||||
import sys
|
||||
import StringIO
|
||||
import copy
|
||||
from lxml import etree
|
||||
import base64
|
||||
|
||||
import utils
|
||||
|
||||
|
@ -336,8 +334,8 @@ class _rml_stylesheet(object):
|
|||
attr = {}
|
||||
attrs = ps.attributes
|
||||
for i in range(attrs.length):
|
||||
name = attrs.item(i).localName
|
||||
attr[name] = ps.get(name)
|
||||
name = attrs.item(i).localName
|
||||
attr[name] = ps.get(name)
|
||||
attrs = []
|
||||
for a in attr:
|
||||
if a in self._tags:
|
||||
|
|
|
@ -23,7 +23,6 @@ import copy
|
|||
import re
|
||||
import reportlab
|
||||
import reportlab.lib.units
|
||||
from lxml import etree
|
||||
from openerp.tools.safe_eval import safe_eval as eval
|
||||
|
||||
_regex = re.compile('\[\[(.+?)\]\]')
|
||||
|
@ -38,7 +37,7 @@ def _child_get(node, self=None, tagname=None):
|
|||
if n.get('rml_except', False):
|
||||
try:
|
||||
eval(n.get('rml_except'), {}, self.localcontext)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
if n.get('rml_tag'):
|
||||
try:
|
||||
|
@ -47,7 +46,7 @@ def _child_get(node, self=None, tagname=None):
|
|||
n2.tag = tag
|
||||
n2.attrib.update(attr)
|
||||
yield n2
|
||||
except:
|
||||
except Exception:
|
||||
yield n
|
||||
else:
|
||||
yield n
|
||||
|
@ -56,7 +55,7 @@ def _child_get(node, self=None, tagname=None):
|
|||
if self and self.localcontext and n.get('rml_except', False):
|
||||
try:
|
||||
eval(n.get('rml_except'), {}, self.localcontext)
|
||||
except:
|
||||
except Exception:
|
||||
continue
|
||||
if (tagname is None) or (n.tag==tagname):
|
||||
yield n
|
||||
|
@ -74,11 +73,11 @@ def _process_text(self, txt):
|
|||
if sps:
|
||||
try:
|
||||
txt2 = eval(sps.pop(0),self.localcontext)
|
||||
except:
|
||||
except Exception:
|
||||
txt2 = ''
|
||||
if type(txt2) == type(0) or type(txt2) == type(0.0):
|
||||
if isinstance(txt2, (int, float)):
|
||||
txt2 = str(txt2)
|
||||
if type(txt2)==type('') or type(txt2)==type(u''):
|
||||
if isinstance(txt2, basestring):
|
||||
result += txt2
|
||||
return result
|
||||
|
||||
|
|
|
@ -66,7 +66,6 @@ class simple(render.render):
|
|||
return self.result.getvalue()
|
||||
|
||||
if __name__=='__main__':
|
||||
import time
|
||||
s = simple()
|
||||
s.xml = '''<test>
|
||||
<author-list>
|
||||
|
@ -82,7 +81,7 @@ if __name__=='__main__':
|
|||
</author-list>
|
||||
</test>'''
|
||||
if s.render():
|
||||
print s.get()
|
||||
print s.get()
|
||||
|
||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||
|
||||
|
|
|
@ -44,10 +44,8 @@ import posixpath
|
|||
import urllib
|
||||
import os
|
||||
import logging
|
||||
from SimpleXMLRPCServer import SimpleXMLRPCDispatcher
|
||||
|
||||
from websrv_lib import *
|
||||
import openerp.netsvc as netsvc
|
||||
import openerp.tools as tools
|
||||
|
||||
try:
|
||||
|
|
|
@ -126,12 +126,12 @@ class TinySocketServerThread(threading.Thread,netsvc.Server):
|
|||
ct.start()
|
||||
lt = len(self.threads)
|
||||
if (lt > 10) and (lt % 10 == 0):
|
||||
# Not many threads should be serving at the same time, so log
|
||||
# their abuse.
|
||||
_logger.debug("Netrpc: %d threads", len(self.threads))
|
||||
# Not many threads should be serving at the same time, so log
|
||||
# their abuse.
|
||||
_logger.debug("Netrpc: %d threads", len(self.threads))
|
||||
self.socket.close()
|
||||
except Exception, e:
|
||||
_logger.warning("Netrpc: closing because of exception %s" % str(e))
|
||||
_logger.warning("Netrpc: closing because of exception %s", e)
|
||||
self.socket.close()
|
||||
return False
|
||||
|
||||
|
|
|
@ -238,9 +238,9 @@ class db(netsvc.ExportService):
|
|||
|
||||
if not data or res:
|
||||
_logger.error(
|
||||
'DUMP DB: %s failed! Please verify the configuration of the database password on the server. '\
|
||||
'It should be provided as a -w <PASSWD> command-line option, or as `db_password` in the '\
|
||||
'server configuration file.\n %s' % (db_name, data))
|
||||
'DUMP DB: %s failed! Please verify the configuration of the database password on the server. '
|
||||
'It should be provided as a -w <PASSWD> command-line option, or as `db_password` in the '
|
||||
'server configuration file.\n %s', db_name, data)
|
||||
raise Exception, "Couldn't dump database"
|
||||
_logger.info('DUMP DB successful: %s', db_name)
|
||||
|
||||
|
@ -253,7 +253,7 @@ class db(netsvc.ExportService):
|
|||
self._set_pg_psw_env_var()
|
||||
|
||||
if self.exp_db_exist(db_name):
|
||||
_logger.warning('RESTORE DB: %s already exists' % (db_name,))
|
||||
_logger.warning('RESTORE DB: %s already exists', db_name)
|
||||
raise Exception, "Database already exists"
|
||||
|
||||
self._create_empty_database(db_name)
|
||||
|
@ -282,7 +282,7 @@ class db(netsvc.ExportService):
|
|||
res = stdout.close()
|
||||
if res:
|
||||
raise Exception, "Couldn't restore database"
|
||||
_logger.info('RESTORE DB: %s' % (db_name))
|
||||
_logger.info('RESTORE DB: %s', db_name)
|
||||
|
||||
return True
|
||||
finally:
|
||||
|
@ -465,8 +465,7 @@ GNU Public Licence.
|
|||
|
||||
backup_directory = os.path.join(tools.config['root_path'], 'backup', time.strftime('%Y-%m-%d-%H-%M'))
|
||||
if zips and not os.path.isdir(backup_directory):
|
||||
_logger.info('create a new backup directory to \
|
||||
store the old modules: %s', backup_directory)
|
||||
_logger.info('create a new backup directory to store the old modules: %s', backup_directory)
|
||||
os.makedirs(backup_directory)
|
||||
|
||||
for module in zips:
|
||||
|
@ -526,11 +525,11 @@ GNU Public Licence.
|
|||
'OS Name : %s\n' \
|
||||
%(platform.platform(), platform.os.name)
|
||||
if os.name == 'posix':
|
||||
if platform.system() == 'Linux':
|
||||
lsbinfo = os.popen('lsb_release -a').read()
|
||||
environment += '%s'%(lsbinfo)
|
||||
else:
|
||||
environment += 'Your System is not lsb compliant\n'
|
||||
if platform.system() == 'Linux':
|
||||
lsbinfo = os.popen('lsb_release -a').read()
|
||||
environment += '%s'%(lsbinfo)
|
||||
else:
|
||||
environment += 'Your System is not lsb compliant\n'
|
||||
environment += 'Operating System Release : %s\n' \
|
||||
'Operating System Version : %s\n' \
|
||||
'Operating System Architecture : %s\n' \
|
||||
|
@ -695,7 +694,7 @@ class report_spool(netsvc.ExportService):
|
|||
self._reports[id]['state'] = True
|
||||
except Exception, exception:
|
||||
|
||||
_logger.exception('Exception: %s\n', str(exception))
|
||||
_logger.exception('Exception: %s\n', exception)
|
||||
if hasattr(exception, 'name') and hasattr(exception, 'value'):
|
||||
self._reports[id]['exception'] = openerp.exceptions.DeferredException(tools.ustr(exception.name), tools.ustr(exception.value))
|
||||
else:
|
||||
|
@ -732,7 +731,7 @@ class report_spool(netsvc.ExportService):
|
|||
self._reports[id]['format'] = format
|
||||
self._reports[id]['state'] = True
|
||||
except Exception, exception:
|
||||
_logger.exception('Exception: %s\n', str(exception))
|
||||
_logger.exception('Exception: %s\n', exception)
|
||||
if hasattr(exception, 'name') and hasattr(exception, 'value'):
|
||||
self._reports[id]['exception'] = openerp.exceptions.DeferredException(tools.ustr(exception.name), tools.ustr(exception.value))
|
||||
else:
|
||||
|
|
|
@ -27,7 +27,6 @@ class m(openerp.osv.osv.Model):
|
|||
return True
|
||||
|
||||
def consume_cpu_time(self, cr, uid, seconds, context=None):
|
||||
import os
|
||||
t0 = time.clock()
|
||||
t1 = time.clock()
|
||||
while t1 - t0 < seconds:
|
||||
|
|
|
@ -1,4 +1,3 @@
|
|||
import os
|
||||
import unittest2
|
||||
|
||||
import openerp
|
||||
|
|
|
@ -22,12 +22,15 @@
|
|||
import socket
|
||||
import cPickle
|
||||
import cStringIO
|
||||
import marshal
|
||||
|
||||
import netsvc
|
||||
|
||||
#.apidoc title: Net-RPC classes
|
||||
|
||||
# Pickle protocol version 2 is optimized compared to default (version 0)
|
||||
PICKLE_PROTOCOL = 2
|
||||
|
||||
|
||||
class Myexception(Exception):
|
||||
"""
|
||||
custom exception object store
|
||||
|
@ -63,20 +66,19 @@ class mysocket:
|
|||
netsvc.close_socket(self.sock)
|
||||
|
||||
def mysend(self, msg, exception=False, traceback=None):
|
||||
msg = cPickle.dumps([msg,traceback])
|
||||
self.sock.sendall('%8d%s%s' % (len(msg), exception and "1" or "0", msg))
|
||||
msg = cPickle.dumps([msg, traceback], PICKLE_PROTOCOL)
|
||||
self.sock.sendall('%8d%d%s' % (len(msg), bool(exception), msg))
|
||||
|
||||
def myreceive(self):
|
||||
buf=''
|
||||
while len(buf) < 8:
|
||||
chunk = self.sock.recv(8 - len(buf))
|
||||
while len(buf) < 9:
|
||||
chunk = self.sock.recv(9 - len(buf))
|
||||
if not chunk:
|
||||
raise socket.timeout
|
||||
buf += chunk
|
||||
size = int(buf)
|
||||
buf = self.sock.recv(1)
|
||||
if buf != "0":
|
||||
exception = buf
|
||||
size = int(buf[:8])
|
||||
if buf[8] != "0":
|
||||
exception = buf[8]
|
||||
else:
|
||||
exception = False
|
||||
msg = ''
|
||||
|
|
|
@ -31,7 +31,6 @@ import openerp.pooler as pooler
|
|||
|
||||
from openerp.osv.osv import except_osv
|
||||
from openerp.osv.orm import except_orm
|
||||
import sys
|
||||
|
||||
_logger = logging.getLogger(__name__)
|
||||
|
||||
|
@ -168,10 +167,7 @@ class interface(netsvc.Service):
|
|||
or isinstance(e, except_orm):
|
||||
netsvc.abort_response(2, e.name, 'warning', e.value)
|
||||
else:
|
||||
import traceback
|
||||
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(
|
||||
sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||
_logger.error('Exception in call: ' + tb_s)
|
||||
_logger.exception('Exception in call:')
|
||||
raise
|
||||
|
||||
return res
|
||||
|
|
Loading…
Reference in New Issue