summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVo Minh Thu <vmt@openerp.com>2011-01-26 15:42:55 +0100
committerVo Minh Thu <vmt@openerp.com>2011-01-26 15:42:55 +0100
commit0e39f07490d625f8720a1818cfe1a0f5aa4544e9 (patch)
treeab2184d0a7910a70a63b081cb94ee7372e862305
parent7bf401381db1ba2bbed032e394d9ae8a11fb180b (diff)
[IMP] tools/netsvc: removed direct dependency of tools on netsvc
bzr revid: vmt@openerp.com-20110126144255-t8p6g1ggjb7f1dmt
-rw-r--r--bin/tools/amount_to_text_en.py4
-rw-r--r--bin/tools/convert.py11
-rw-r--r--bin/tools/misc.py16
-rw-r--r--bin/tools/translate.py2
-rw-r--r--bin/tools/yaml_import.py2
5 files changed, 18 insertions, 17 deletions
diff --git a/bin/tools/amount_to_text_en.py b/bin/tools/amount_to_text_en.py
index 66d749e5fb3..1b452d50ccb 100644
--- a/bin/tools/amount_to_text_en.py
+++ b/bin/tools/amount_to_text_en.py
@@ -99,13 +99,13 @@ def amount_to_text(nbr, lang='en', currency='euro'):
Example:
1654: thousands six cent cinquante-quatre.
"""
- import netsvc
+ import loglevels
# if nbr > 10000000:
# netsvc.Logger().notifyChannel('translate', netsvc.LOG_WARNING, _("Number too large '%d', can not translate it"))
# return str(nbr)
if not _translate_funcs.has_key(lang):
- netsvc.Logger().notifyChannel('translate', netsvc.LOG_WARNING, _("no translation function found for lang: '%s'" % (lang,)))
+ loglevels.Logger().notifyChannel('translate', loglevels.LOG_WARNING, _("no translation function found for lang: '%s'" % (lang,)))
#TODO: (default should be en) same as above
lang = 'en'
return _translate_funcs[lang](abs(nbr), currency)
diff --git a/bin/tools/convert.py b/bin/tools/convert.py
index db8d71843ba..dcfc2d815b5 100644
--- a/bin/tools/convert.py
+++ b/bin/tools/convert.py
@@ -41,7 +41,7 @@ except:
from datetime import datetime, timedelta
from lxml import etree
import misc
-import netsvc
+import loglevels
import osv
import pooler
from config import config
@@ -541,6 +541,7 @@ form: module.record_id""" % (xml_id,)
id = _eval_xml(self, rec[0], self.pool, cr, self.uid, self.idref)
uid = self.get_uid(cr, self.uid, data_node, rec)
+ import netsvc
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, model,
id,
@@ -688,7 +689,7 @@ form: module.record_id""" % (xml_id,)
rec_src = rec.get("search",'').encode('utf8')
rec_src_count = rec.get("count")
- severity = rec.get("severity",'').encode('ascii') or netsvc.LOG_ERROR
+ severity = rec.get("severity",'').encode('ascii') or loglevels.LOG_ERROR
rec_string = rec.get("string",'').encode('utf8') or 'unknown'
ids = None
@@ -964,9 +965,9 @@ def convert_xml_import(cr, module, xmlfile, idref=None, mode='init', noupdate=Fa
try:
relaxng.assert_(doc)
except Exception:
- logger = netsvc.Logger()
- logger.notifyChannel('init', netsvc.LOG_ERROR, 'The XML file does not fit the required schema !')
- logger.notifyChannel('init', netsvc.LOG_ERROR, misc.ustr(relaxng.error_log.last_error))
+ logger = loglevels.Logger()
+ logger.notifyChannel('init', loglevels.LOG_ERROR, 'The XML file does not fit the required schema !')
+ logger.notifyChannel('init', loglevels.LOG_ERROR, misc.ustr(relaxng.error_log.last_error))
raise
if idref is None:
diff --git a/bin/tools/misc.py b/bin/tools/misc.py
index 615893ef238..26ed090edc8 100644
--- a/bin/tools/misc.py
+++ b/bin/tools/misc.py
@@ -55,7 +55,7 @@ try:
except ImportError:
html2text = None
-import netsvc
+import loglevels
from config import config
from lru import LRU
@@ -434,10 +434,10 @@ def _email_send(smtp_from, smtp_to_list, message, openobject_id=None, ssl=False,
"""
class WriteToLogger(object):
def __init__(self):
- self.logger = netsvc.Logger()
+ self.logger = loglevels.Logger()
def write(self, s):
- self.logger.notifyChannel('email_send', netsvc.LOG_DEBUG, s)
+ self.logger.notifyChannel('email_send', loglevels.LOG_DEBUG, s)
if openobject_id:
message['Message-Id'] = generate_tracking_message_id(openobject_id)
@@ -1094,7 +1094,7 @@ def logged(f):
vector.append(' result: %s' % pformat(res))
vector.append(' time delta: %s' % (time.time() - timeb4))
- netsvc.Logger().notifyChannel('logged', netsvc.LOG_DEBUG, '\n'.join(vector))
+ loglevels.Logger().notifyChannel('logged', loglevels.LOG_DEBUG, '\n'.join(vector))
return res
return wrapper
@@ -1300,7 +1300,7 @@ def detect_server_timezone():
try:
import pytz
except Exception:
- netsvc.Logger().notifyChannel("detect_server_timezone", netsvc.LOG_WARNING,
+ loglevels.Logger().notifyChannel("detect_server_timezone", loglevels.LOG_WARNING,
"Python pytz module is not available. Timezone will be set to UTC by default.")
return 'UTC'
@@ -1334,14 +1334,14 @@ def detect_server_timezone():
if value:
try:
tz = pytz.timezone(value)
- netsvc.Logger().notifyChannel("detect_server_timezone", netsvc.LOG_INFO,
+ loglevels.Logger().notifyChannel("detect_server_timezone", loglevels.LOG_INFO,
"Using timezone %s obtained from %s." % (tz.zone,source))
return value
except pytz.UnknownTimeZoneError:
- netsvc.Logger().notifyChannel("detect_server_timezone", netsvc.LOG_WARNING,
+ loglevels.Logger().notifyChannel("detect_server_timezone", loglevels.LOG_WARNING,
"The timezone specified in %s (%s) is invalid, ignoring it." % (source,value))
- netsvc.Logger().notifyChannel("detect_server_timezone", netsvc.LOG_WARNING,
+ loglevels.Logger().notifyChannel("detect_server_timezone", loglevels.LOG_WARNING,
"No valid timezone could be detected, using default UTC timezone. You can specify it explicitly with option 'timezone' in the server configuration.")
return 'UTC'
diff --git a/bin/tools/translate.py b/bin/tools/translate.py
index 510ae71ab1f..e63de663a73 100644
--- a/bin/tools/translate.py
+++ b/bin/tools/translate.py
@@ -38,7 +38,6 @@ from datetime import datetime
from lxml import etree
import tools
-import netsvc
from tools.misc import UpdateableStr
from tools.misc import SKIPPED_ELEMENT_TYPES
@@ -587,6 +586,7 @@ def trans_generate(lang, modules, cr):
push_translation(module, 'view', encode(obj.model), 0, t)
elif model=='ir.actions.wizard':
service_name = 'wizard.'+encode(obj.wiz_name)
+ import netsvc
if netsvc.Service._services.get(service_name):
obj2 = netsvc.Service._services[service_name]
for state_name, state_def in obj2.states.iteritems():
diff --git a/bin/tools/yaml_import.py b/bin/tools/yaml_import.py
index 2b5c982ca7b..53bcebacabc 100644
--- a/bin/tools/yaml_import.py
+++ b/bin/tools/yaml_import.py
@@ -5,7 +5,6 @@ from datetime import datetime, timedelta
import logging
import pooler
-import netsvc
import misc
from config import config
import yaml_tag
@@ -448,6 +447,7 @@ class YamlInterpreter(object):
signals=[x['signal'] for x in self.cr.dictfetchall()]
if workflow.action not in signals:
raise YamlImportException('Incorrect action %s. No such action defined' % workflow.action)
+ import netsvc
wf_service = netsvc.LocalService("workflow")
wf_service.trg_validate(uid, workflow.model, id, workflow.action, self.cr)