[IMP] openerp.loglevels: removed calls to openerp.loglevels.Logger().
bzr revid: vmt@openerp.com-20120124173017-c66z3kq11wmbrrke
This commit is contained in:
parent
402bddc06a
commit
f057f2afa5
|
@ -19,12 +19,15 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
import logging
|
||||||
import time, os
|
import time, os
|
||||||
|
|
||||||
import netsvc
|
import netsvc
|
||||||
import report,pooler,tools
|
import report,pooler,tools
|
||||||
from operator import itemgetter
|
from operator import itemgetter
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
def graph_get(cr, graph, wkf_ids, nested, workitem, processed_subflows):
|
def graph_get(cr, graph, wkf_ids, nested, workitem, processed_subflows):
|
||||||
import pydot
|
import pydot
|
||||||
cr.execute('select * from wkf_activity where wkf_id in ('+','.join(['%s']*len(wkf_ids))+')', wkf_ids)
|
cr.execute('select * from wkf_activity where wkf_id in ('+','.join(['%s']*len(wkf_ids))+')', wkf_ids)
|
||||||
|
@ -126,13 +129,12 @@ def graph_instance_get(cr, graph, inst_id, nested=False):
|
||||||
|
|
||||||
class report_graph_instance(object):
|
class report_graph_instance(object):
|
||||||
def __init__(self, cr, uid, ids, data):
|
def __init__(self, cr, uid, ids, data):
|
||||||
logger = netsvc.Logger()
|
|
||||||
try:
|
try:
|
||||||
import pydot
|
import pydot
|
||||||
except Exception,e:
|
except Exception,e:
|
||||||
logger.notifyChannel('workflow', netsvc.LOG_WARNING,
|
_logger.warning(
|
||||||
'Import Error for pydot, you will not be able to render workflows\n'
|
'Import Error for pydot, you will not be able to render workflows.\n'
|
||||||
'Consider Installing PyDot or dependencies: http://dkbza.org/pydot.html')
|
'Consider Installing PyDot or dependencies: http://dkbza.org/pydot.html.')
|
||||||
raise e
|
raise e
|
||||||
self.done = False
|
self.done = False
|
||||||
|
|
||||||
|
@ -170,7 +172,7 @@ showpage'''
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
import traceback, sys
|
import traceback, sys
|
||||||
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||||
logger.notifyChannel('workflow', netsvc.LOG_ERROR, 'Exception in call: ' + tb_s)
|
_logger.error('Exception in call: ' + tb_s)
|
||||||
# string is in PS, like the success message would have been
|
# string is in PS, like the success message would have been
|
||||||
ps_string = '''%PS-Adobe-3.0
|
ps_string = '''%PS-Adobe-3.0
|
||||||
/inch {72 mul} def
|
/inch {72 mul} def
|
||||||
|
|
|
@ -1797,7 +1797,7 @@ class BaseModel(object):
|
||||||
res.insert(0, ("Can't find field '%s' in the following view parts composing the view of object model '%s':" % (field, model), None))
|
res.insert(0, ("Can't find field '%s' in the following view parts composing the view of object model '%s':" % (field, model), None))
|
||||||
msg = "\n * ".join([r[0] for r in res])
|
msg = "\n * ".join([r[0] for r in res])
|
||||||
msg += "\n\nEither you wrongly customized this view, or some modules bringing those views are not compatible with your current data model"
|
msg += "\n\nEither you wrongly customized this view, or some modules bringing those views are not compatible with your current data model"
|
||||||
netsvc.Logger().notifyChannel('orm', netsvc.LOG_ERROR, msg)
|
_logger.error(msg)
|
||||||
raise except_orm('View error', msg)
|
raise except_orm('View error', msg)
|
||||||
return arch, fields
|
return arch, fields
|
||||||
|
|
||||||
|
@ -2970,7 +2970,7 @@ class BaseModel(object):
|
||||||
query = 'UPDATE "%s" SET "%s"=%s' % (self._table, k, ss[0])
|
query = 'UPDATE "%s" SET "%s"=%s' % (self._table, k, ss[0])
|
||||||
cr.execute(query, (ss[1](default),))
|
cr.execute(query, (ss[1](default),))
|
||||||
cr.commit()
|
cr.commit()
|
||||||
netsvc.Logger().notifyChannel('data', netsvc.LOG_DEBUG, "Table '%s': setting default value of new column %s" % (self._table, k))
|
_logger.debug("Table '%s': setting default value of new column %s", self._table, k)
|
||||||
|
|
||||||
# remember the functions to call for the stored fields
|
# remember the functions to call for the stored fields
|
||||||
if isinstance(f, fields.function):
|
if isinstance(f, fields.function):
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
# 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 logging
|
||||||
import mako
|
import mako
|
||||||
from lxml import etree
|
from lxml import etree
|
||||||
from mako.template import Template
|
from mako.template import Template
|
||||||
|
@ -25,6 +26,8 @@ from mako.lookup import TemplateLookup
|
||||||
import openerp.netsvc as netsvc
|
import openerp.netsvc as netsvc
|
||||||
import traceback, sys, os
|
import traceback, sys, os
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class makohtml2html(object):
|
class makohtml2html(object):
|
||||||
def __init__(self, html, localcontext):
|
def __init__(self, html, localcontext):
|
||||||
self.localcontext = localcontext
|
self.localcontext = localcontext
|
||||||
|
@ -125,8 +128,7 @@ class makohtml2html(object):
|
||||||
return final_html
|
return final_html
|
||||||
except Exception,e:
|
except Exception,e:
|
||||||
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||||
netsvc.Logger().notifyChannel('report', netsvc.LOG_ERROR,
|
_logger.error('report :\n%s\n%s\n', tb_s, str(e))
|
||||||
'report :\n%s\n%s\n' % (tb_s, str(e)))
|
|
||||||
|
|
||||||
def parseNode(html, localcontext = {}):
|
def parseNode(html, localcontext = {}):
|
||||||
r = makohtml2html(html, localcontext)
|
r = makohtml2html(html, localcontext)
|
||||||
|
|
|
@ -110,8 +110,7 @@ class TinySocketServerThread(threading.Thread,netsvc.Server):
|
||||||
self.socket.bind((self.__interface, self.__port))
|
self.socket.bind((self.__interface, self.__port))
|
||||||
self.socket.listen(5)
|
self.socket.listen(5)
|
||||||
self.threads = []
|
self.threads = []
|
||||||
netsvc.Logger().notifyChannel("web-services", netsvc.LOG_INFO,
|
_logger.info("starting NET-RPC service on %s:%s", interface or '0.0.0.0', port)
|
||||||
"starting NET-RPC service on %s:%s" % (interface or '0.0.0.0', port,))
|
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
|
|
|
@ -339,10 +339,9 @@ class db(netsvc.ExportService):
|
||||||
from openerp.osv.orm import except_orm
|
from openerp.osv.orm import except_orm
|
||||||
from openerp.osv.osv import except_osv
|
from openerp.osv.osv import except_osv
|
||||||
|
|
||||||
l = netsvc.Logger()
|
|
||||||
for db in databases:
|
for db in databases:
|
||||||
try:
|
try:
|
||||||
l.notifyChannel('migration', netsvc.LOG_INFO, 'migrate database %s' % (db,))
|
_logger.info('migrate database %s', db)
|
||||||
tools.config['update']['base'] = True
|
tools.config['update']['base'] = True
|
||||||
pooler.restart_pool(db, force_demo=False, update_module=True)
|
pooler.restart_pool(db, force_demo=False, update_module=True)
|
||||||
except except_orm, inst:
|
except except_orm, inst:
|
||||||
|
@ -352,7 +351,7 @@ class db(netsvc.ExportService):
|
||||||
except Exception:
|
except Exception:
|
||||||
import traceback
|
import traceback
|
||||||
tb_s = reduce(lambda x, y: x+y, traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback))
|
tb_s = reduce(lambda x, y: x+y, traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||||
l.notifyChannel('web-services', netsvc.LOG_ERROR, tb_s)
|
_logger.error(tb_s)
|
||||||
raise
|
raise
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
@ -428,7 +427,6 @@ GNU Public Licence.
|
||||||
|
|
||||||
|
|
||||||
def exp_get_migration_scripts(self, contract_id, contract_password):
|
def exp_get_migration_scripts(self, contract_id, contract_password):
|
||||||
l = netsvc.Logger()
|
|
||||||
import openerp.tools.maintenance as tm
|
import openerp.tools.maintenance as tm
|
||||||
try:
|
try:
|
||||||
rc = tm.remote_contract(contract_id, contract_password)
|
rc = tm.remote_contract(contract_id, contract_password)
|
||||||
|
@ -437,7 +435,7 @@ GNU Public Licence.
|
||||||
if rc.status != 'full':
|
if rc.status != 'full':
|
||||||
raise tm.RemoteContractException('Can not get updates for a partial contract')
|
raise tm.RemoteContractException('Can not get updates for a partial contract')
|
||||||
|
|
||||||
l.notifyChannel('migration', netsvc.LOG_INFO, 'starting migration with contract %s' % (rc.name,))
|
_logger.info('starting migration with contract %s', rc.name)
|
||||||
|
|
||||||
zips = rc.retrieve_updates(rc.id, openerp.modules.get_modules_with_version())
|
zips = rc.retrieve_updates(rc.id, openerp.modules.get_modules_with_version())
|
||||||
|
|
||||||
|
@ -445,12 +443,12 @@ GNU Public Licence.
|
||||||
|
|
||||||
backup_directory = os.path.join(tools.config['root_path'], 'backup', time.strftime('%Y-%m-%d-%H-%M'))
|
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):
|
if zips and not os.path.isdir(backup_directory):
|
||||||
l.notifyChannel('migration', netsvc.LOG_INFO, 'create a new backup directory to \
|
_logger.info('create a new backup directory to \
|
||||||
store the old modules: %s' % (backup_directory,))
|
store the old modules: %s', backup_directory)
|
||||||
os.makedirs(backup_directory)
|
os.makedirs(backup_directory)
|
||||||
|
|
||||||
for module in zips:
|
for module in zips:
|
||||||
l.notifyChannel('migration', netsvc.LOG_INFO, 'upgrade module %s' % (module,))
|
_logger.info('upgrade module %s', module)
|
||||||
mp = openerp.modules.get_module_path(module)
|
mp = openerp.modules.get_module_path(module)
|
||||||
if mp:
|
if mp:
|
||||||
if os.path.isdir(mp):
|
if os.path.isdir(mp):
|
||||||
|
@ -467,7 +465,7 @@ GNU Public Licence.
|
||||||
try:
|
try:
|
||||||
base64_decoded = base64.decodestring(zips[module])
|
base64_decoded = base64.decodestring(zips[module])
|
||||||
except Exception:
|
except Exception:
|
||||||
l.notifyChannel('migration', netsvc.LOG_ERROR, 'unable to read the module %s' % (module,))
|
_logger.error('unable to read the module %s', module)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
zip_contents = StringIO(base64_decoded)
|
zip_contents = StringIO(base64_decoded)
|
||||||
|
@ -476,13 +474,13 @@ GNU Public Licence.
|
||||||
try:
|
try:
|
||||||
tools.extract_zip_file(zip_contents, tools.config['addons_path'] )
|
tools.extract_zip_file(zip_contents, tools.config['addons_path'] )
|
||||||
except Exception:
|
except Exception:
|
||||||
l.notifyChannel('migration', netsvc.LOG_ERROR, 'unable to extract the module %s' % (module, ))
|
_logger.error('unable to extract the module %s', module)
|
||||||
rmtree(module)
|
rmtree(module)
|
||||||
raise
|
raise
|
||||||
finally:
|
finally:
|
||||||
zip_contents.close()
|
zip_contents.close()
|
||||||
except Exception:
|
except Exception:
|
||||||
l.notifyChannel('migration', netsvc.LOG_ERROR, 'restore the previous version of the module %s' % (module, ))
|
_logger.error('restore the previous version of the module %s', module)
|
||||||
nmp = os.path.join(backup_directory, module)
|
nmp = os.path.join(backup_directory, module)
|
||||||
if os.path.isdir(nmp):
|
if os.path.isdir(nmp):
|
||||||
copytree(nmp, tools.config['addons_path'])
|
copytree(nmp, tools.config['addons_path'])
|
||||||
|
@ -496,7 +494,7 @@ GNU Public Licence.
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
import traceback
|
import traceback
|
||||||
tb_s = reduce(lambda x, y: x+y, traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback))
|
tb_s = reduce(lambda x, y: x+y, traceback.format_exception( sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||||
l.notifyChannel('migration', netsvc.LOG_ERROR, tb_s)
|
_logger.error(tb_s)
|
||||||
raise
|
raise
|
||||||
|
|
||||||
def exp_get_server_environment(self):
|
def exp_get_server_environment(self):
|
||||||
|
@ -527,8 +525,8 @@ GNU Public Licence.
|
||||||
return tools.config.get('login_message', False)
|
return tools.config.get('login_message', False)
|
||||||
|
|
||||||
def exp_set_loglevel(self, loglevel, logger=None):
|
def exp_set_loglevel(self, loglevel, logger=None):
|
||||||
l = netsvc.Logger()
|
# TODO Previously, the level was set on the now deprecated
|
||||||
l.set_loglevel(int(loglevel), logger)
|
# `openerp.netsvc.Logger` class.
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def exp_get_stats(self):
|
def exp_get_stats(self):
|
||||||
|
|
|
@ -19,10 +19,14 @@
|
||||||
#
|
#
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
|
import logging
|
||||||
|
from translate import _
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
#-------------------------------------------------------------
|
#-------------------------------------------------------------
|
||||||
#ENGLISH
|
#ENGLISH
|
||||||
#-------------------------------------------------------------
|
#-------------------------------------------------------------
|
||||||
from translate import _
|
|
||||||
|
|
||||||
to_19 = ( 'Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six',
|
to_19 = ( 'Zero', 'One', 'Two', 'Three', 'Four', 'Five', 'Six',
|
||||||
'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen',
|
'Seven', 'Eight', 'Nine', 'Ten', 'Eleven', 'Twelve', 'Thirteen',
|
||||||
|
@ -105,11 +109,11 @@ def amount_to_text(nbr, lang='en', currency='euro'):
|
||||||
"""
|
"""
|
||||||
import openerp.loglevels as loglevels
|
import openerp.loglevels as loglevels
|
||||||
# if nbr > 10000000:
|
# if nbr > 10000000:
|
||||||
# netsvc.Logger().notifyChannel('translate', netsvc.LOG_WARNING, _("Number too large '%d', can not translate it"))
|
# _logger.warning(_("Number too large '%d', can not translate it"))
|
||||||
# return str(nbr)
|
# return str(nbr)
|
||||||
|
|
||||||
if not _translate_funcs.has_key(lang):
|
if not _translate_funcs.has_key(lang):
|
||||||
loglevels.Logger().notifyChannel('translate', loglevels.LOG_WARNING, _("no translation function found for lang: '%s'" % (lang,)))
|
_logger.warning(_("no translation function found for lang: '%s'"), lang)
|
||||||
#TODO: (default should be en) same as above
|
#TODO: (default should be en) same as above
|
||||||
lang = 'en'
|
lang = 'en'
|
||||||
return _translate_funcs[lang](abs(nbr), currency)
|
return _translate_funcs[lang](abs(nbr), currency)
|
||||||
|
|
|
@ -20,6 +20,7 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
|
|
||||||
import copy
|
import copy
|
||||||
|
import logging
|
||||||
|
|
||||||
import openerp.netsvc as netsvc
|
import openerp.netsvc as netsvc
|
||||||
from openerp.tools.misc import UpdateableStr, UpdateableDict
|
from openerp.tools.misc import UpdateableStr, UpdateableDict
|
||||||
|
@ -30,10 +31,11 @@ import openerp.pooler as pooler
|
||||||
|
|
||||||
from openerp.osv.osv import except_osv
|
from openerp.osv.osv import except_osv
|
||||||
from openerp.osv.orm import except_orm
|
from openerp.osv.orm import except_orm
|
||||||
from openerp.netsvc import Logger, LOG_ERROR
|
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
|
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
class except_wizard(Exception):
|
class except_wizard(Exception):
|
||||||
def __init__(self, name, value):
|
def __init__(self, name, value):
|
||||||
self.name = name
|
self.name = name
|
||||||
|
@ -170,9 +172,7 @@ class interface(netsvc.Service):
|
||||||
import traceback
|
import traceback
|
||||||
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(
|
tb_s = reduce(lambda x, y: x+y, traceback.format_exception(
|
||||||
sys.exc_type, sys.exc_value, sys.exc_traceback))
|
sys.exc_type, sys.exc_value, sys.exc_traceback))
|
||||||
logger = Logger()
|
_logger.error('Exception in call: ' + tb_s)
|
||||||
logger.notifyChannel("web-services", LOG_ERROR,
|
|
||||||
'Exception in call: ' + tb_s)
|
|
||||||
raise
|
raise
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
|
@ -34,8 +34,6 @@ def log(cr,ident,act_id,info=''):
|
||||||
#info: %s
|
#info: %s
|
||||||
#""" % (ident[1], ident[2], ident[0], act_id, info)
|
#""" % (ident[1], ident[2], ident[0], act_id, info)
|
||||||
|
|
||||||
#netsvc.Logger().notifyChannel('wkf_log', netsvc.LOG_DEBUG, msg)
|
|
||||||
|
|
||||||
#cr.execute('insert into wkf_logs (res_type, res_id, uid, act_id, time, info) values (%s,%s,%s,%s,current_time,%s)', (ident[1],int(ident[2]),int(ident[0]),int(act_id),info))
|
#cr.execute('insert into wkf_logs (res_type, res_id, uid, act_id, time, info) values (%s,%s,%s,%s,current_time,%s)', (ident[1],int(ident[2]),int(ident[0]),int(act_id),info))
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
Loading…
Reference in New Issue