[IMP] use a dedicated logger
parent
1a6e457c8a
commit
a168ef93f5
|
@ -26,6 +26,7 @@ from lxml import etree
|
||||||
from openerp import models, fields, api, exceptions
|
from openerp import models, fields, api, exceptions
|
||||||
from openerp.tools.translate import _
|
from openerp.tools.translate import _
|
||||||
from openerp.tools.misc import UnquoteEvalContext
|
from openerp.tools.misc import UnquoteEvalContext
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class fetchmail_server(models.Model):
|
class fetchmail_server(models.Model):
|
||||||
|
@ -80,21 +81,21 @@ class fetchmail_server(models.Model):
|
||||||
matched_object_ids = []
|
matched_object_ids = []
|
||||||
|
|
||||||
for this in self:
|
for this in self:
|
||||||
logging.info(
|
_logger.info(
|
||||||
'start checking for emails in %s server %s',
|
'start checking for emails in %s server %s',
|
||||||
folder.path, this.name)
|
folder.path, this.name)
|
||||||
|
|
||||||
match_algorithm = folder.get_algorithm()
|
match_algorithm = folder.get_algorithm()
|
||||||
|
|
||||||
if connection.select(folder.path)[0] != 'OK':
|
if connection.select(folder.path)[0] != 'OK':
|
||||||
logging.error(
|
_logger.error(
|
||||||
'Could not open mailbox %s on %s',
|
'Could not open mailbox %s on %s',
|
||||||
folder.path, this.server)
|
folder.path, this.server)
|
||||||
connection.select()
|
connection.select()
|
||||||
continue
|
continue
|
||||||
result, msgids = this.get_msgids(connection)
|
result, msgids = this.get_msgids(connection)
|
||||||
if result != 'OK':
|
if result != 'OK':
|
||||||
logging.error(
|
_logger.error(
|
||||||
'Could not search mailbox %s on %s',
|
'Could not search mailbox %s on %s',
|
||||||
folder.path, this.server)
|
folder.path, this.server)
|
||||||
continue
|
continue
|
||||||
|
@ -103,7 +104,7 @@ class fetchmail_server(models.Model):
|
||||||
matched_object_ids += this.apply_matching(
|
matched_object_ids += this.apply_matching(
|
||||||
connection, folder, msgid, match_algorithm)
|
connection, folder, msgid, match_algorithm)
|
||||||
|
|
||||||
logging.info(
|
_logger.info(
|
||||||
'finished checking for emails in %s server %s',
|
'finished checking for emails in %s server %s',
|
||||||
folder.path, this.name)
|
folder.path, this.name)
|
||||||
|
|
||||||
|
@ -124,7 +125,7 @@ class fetchmail_server(models.Model):
|
||||||
result, msgdata = connection.fetch(msgid, '(RFC822)')
|
result, msgdata = connection.fetch(msgid, '(RFC822)')
|
||||||
|
|
||||||
if result != 'OK':
|
if result != 'OK':
|
||||||
logging.error(
|
_logger.error(
|
||||||
'Could not fetch %s in %s on %s',
|
'Could not fetch %s in %s on %s',
|
||||||
msgid, folder.path, this.server)
|
msgid, folder.path, this.server)
|
||||||
continue
|
continue
|
||||||
|
@ -151,7 +152,7 @@ class fetchmail_server(models.Model):
|
||||||
matched_object_ids += found_ids[:1]
|
matched_object_ids += found_ids[:1]
|
||||||
except Exception:
|
except Exception:
|
||||||
self.env.cr.execute('rollback to savepoint apply_matching')
|
self.env.cr.execute('rollback to savepoint apply_matching')
|
||||||
logging.exception(
|
_logger.exception(
|
||||||
"Failed to fetch mail %s from %s", msgid, this.name)
|
"Failed to fetch mail %s from %s", msgid, this.name)
|
||||||
elif folder.flag_nonmatching:
|
elif folder.flag_nonmatching:
|
||||||
connection.store(msgid, '+FLAGS', '\\FLAGGED')
|
connection.store(msgid, '+FLAGS', '\\FLAGGED')
|
||||||
|
|
|
@ -21,6 +21,7 @@
|
||||||
##############################################################################
|
##############################################################################
|
||||||
from openerp import fields, models
|
from openerp import fields, models
|
||||||
import logging
|
import logging
|
||||||
|
_logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
class attach_mail_manually(models.TransientModel):
|
class attach_mail_manually(models.TransientModel):
|
||||||
|
@ -49,14 +50,14 @@ class attach_mail_manually(models.TransientModel):
|
||||||
None,
|
None,
|
||||||
'FLAGGED' if folder.flag_nonmatching else 'UNDELETED')
|
'FLAGGED' if folder.flag_nonmatching else 'UNDELETED')
|
||||||
if result != 'OK':
|
if result != 'OK':
|
||||||
logging.error('Could not search mailbox %s on %s' % (
|
_logger.error('Could not search mailbox %s on %s',
|
||||||
folder.path, folder.server_id.name))
|
folder.path, folder.server_id.name)
|
||||||
continue
|
continue
|
||||||
for msgid in msgids[0].split():
|
for msgid in msgids[0].split():
|
||||||
result, msgdata = connection.fetch(msgid, '(RFC822)')
|
result, msgdata = connection.fetch(msgid, '(RFC822)')
|
||||||
if result != 'OK':
|
if result != 'OK':
|
||||||
logging.error('Could not fetch %s in %s on %s' % (
|
_logger.error('Could not fetch %s in %s on %s',
|
||||||
msgid, folder.path, folder.server_id.name))
|
msgid, folder.path, folder.server_id.name)
|
||||||
continue
|
continue
|
||||||
mail_message = self.pool.get('mail.thread').message_parse(
|
mail_message = self.pool.get('mail.thread').message_parse(
|
||||||
cr, uid, msgdata[0][1],
|
cr, uid, msgdata[0][1],
|
||||||
|
@ -80,8 +81,8 @@ class attach_mail_manually(models.TransientModel):
|
||||||
connection.select(this.folder_id.path)
|
connection.select(this.folder_id.path)
|
||||||
result, msgdata = connection.fetch(mail.msgid, '(RFC822)')
|
result, msgdata = connection.fetch(mail.msgid, '(RFC822)')
|
||||||
if result != 'OK':
|
if result != 'OK':
|
||||||
logging.error('Could not fetch %s in %s on %s' % (
|
_logger.error('Could not fetch %s in %s on %s',
|
||||||
mail.msgid, this.folder_id.path, this.server))
|
mail.msgid, this.folder_id.path, this.server)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
mail_message = self.pool.get('mail.thread').message_parse(
|
mail_message = self.pool.get('mail.thread').message_parse(
|
||||||
|
|
Loading…
Reference in New Issue