diff --git a/bin/addons/__init__.py b/bin/addons/__init__.py index 41d47c076e0..3174eb88d19 100644 --- a/bin/addons/__init__.py +++ b/bin/addons/__init__.py @@ -274,7 +274,7 @@ def load_modules(db, force_demo=False, status=None, update_module=False): report = tools.assertion_report() load_module_graph(cr, graph, status, report=report) if report.get_report(): - print report + logger.notifyChannel('init', netsvc.LOG_INFO, 'assert:%s' % report) for kind in ('init', 'demo', 'update'): tools.config[kind]={} diff --git a/bin/tools/config.py b/bin/tools/config.py index 7ae58a8b05c..89bd01508c3 100644 --- a/bin/tools/config.py +++ b/bin/tools/config.py @@ -28,12 +28,11 @@ ############################################################################## import ConfigParser,optparse,os,sys +import netsvc,logging class configmanager(object): def __init__(self, fname=None): - import netsvc, logging - logger = netsvc.Logger() self.options = { 'verbose': False, 'interface': '', # this will bind the server to all interfaces @@ -70,7 +69,7 @@ class configmanager(object): 'assert_exit_level': logging.WARNING, # level above which a failed assert will } - assert_exit_levels = (netsvc.LOG_CRITICAL, netsvc.LOG_DEBUG, netsvc.LOG_ERROR, netsvc.LOG_INFO, netsvc.LOG_WARNING) + assert_exit_levels = (netsvc.LOG_CRITICAL, netsvc.LOG_ERROR, netsvc.LOG_WARNING, netsvc.LOG_INFO, netsvc.LOG_DEBUG) parser = optparse.OptionParser(version=tinyerp_version_string) @@ -125,9 +124,7 @@ class configmanager(object): (opt, args) = parser.parse_args() - if (opt.translate_in or opt.translate_out) and (not opt.language or not opt.db_name): - logger.notifyChannel("init", netsvc.LOG_ERROR, "the i18n-import and i18n-export options cannot be used without the language (-l) and database (-d) options") - sys.exit(2) + assert not ((opt.translate_in or opt.translate_out) and (not opt.language or not opt.db_name)), "the i18n-import and i18n-export options cannot be used without the language (-l) and database (-d) options" # place/search the config file on Win32 near the server installation # (../etc from the server) @@ -160,7 +157,7 @@ class configmanager(object): self.options[arg] = getattr(opt, arg) if opt.assert_exit_level: - assert opt.assert_exit_level in assert_exit_levels + assert opt.assert_exit_level in assert_exit_levels, 'ERROR: The assert-exit-level must be one of those values: '+str(assert_exit_levels) self.options['assert_exit_level'] = getattr(logging, opt.assert_exit_level.upper()) if not self.options['root_path'] or self.options['root_path']=='None': @@ -224,8 +221,6 @@ class configmanager(object): # what to do if impossible? sys.stderr.write("ERROR: couldn't create the config directory\n") - - def get(self, key, default=None): return self.options.get(key, default) diff --git a/bin/tools/convert.py b/bin/tools/convert.py index 28063d0caf1..a8e1481a75c 100644 --- a/bin/tools/convert.py +++ b/bin/tools/convert.py @@ -166,7 +166,7 @@ class assertion_report(object): return self._report def __str__(self): - res = 'Assertions report:\nLevel\tsuccess\tfailed\n' + res = '\nAssertions report:\nLevel\tsuccess\tfailed\n' success = failed = 0 for sev in self._report: res += sev + '\t' + str(self._report[sev][True]) + '\t' + str(self._report[sev][False]) + '\n' @@ -441,7 +441,7 @@ class xml_import(object): severity = rec.getAttribute("severity").encode('ascii') or 'info' - rec_string = rec.getAttribute("string").encode('utf8') or '???' # TODO define a default string + rec_string = rec.getAttribute("string").encode('utf8') or 'unknown' ids = None eval_dict = {'ref': _ref(self, cr)}