diff options
| author | Harry (OpenERP) <hmo@tinyerp.com> | 2011-03-01 11:44:40 +0530 |
|---|---|---|
| committer | Harry (OpenERP) <hmo@tinyerp.com> | 2011-03-01 11:44:40 +0530 |
| commit | f475de6717b58871c562eacd3c990ba4e63b595d (patch) | |
| tree | 2f10f6c5f8768ae0589f943acb5ecb46b3ad2f52 /addons/fetchmail/fetchmail.py | |
| parent | ec73645c4c7d4b160d54156b0e1f10c514e5dfc8 (diff) | |
| parent | 7d782c5f6396e21dd13aa8a88a0d4c53dea7a238 (diff) | |
[MERGE] merged from ysa-emails-addons-development branch
bzr revid: hmo@tinyerp.com-20110301061440-j1luxnpck3490d2r
Diffstat (limited to 'addons/fetchmail/fetchmail.py')
| -rw-r--r-- | addons/fetchmail/fetchmail.py | 27 |
1 files changed, 14 insertions, 13 deletions
diff --git a/addons/fetchmail/fetchmail.py b/addons/fetchmail/fetchmail.py index 892313c0102..e69bbdf87a2 100644 --- a/addons/fetchmail/fetchmail.py +++ b/addons/fetchmail/fetchmail.py @@ -116,7 +116,7 @@ class email_server(osv.osv): if context is None: context = {} for server in self.browse(cr, uid, ids, context=context): - logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name)) + logger.notifyChannel(server.type, netsvc.LOG_INFO, 'fetchmail start checking for new emails on %s' % (server.name)) context.update({'server_id': server.id, 'server_type': server.type}) try: if server.type == 'imap': @@ -167,8 +167,8 @@ class email_server(osv.osv): for server in self.browse(cr, uid, ids, context=context): count = 0 user = server.user_id.id or uid - try: - if server.type == 'imap': + if server.type == 'imap': + try: imap_server = self.button_confirm_login(cr, uid, [server.id], context=context) imap_server.select() result, data = imap_server.search(None, '(UNSEEN)') @@ -180,14 +180,18 @@ class email_server(osv.osv): imap_server.store(num, '+FLAGS', '\\Seen') count += 1 - logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch/process %s email(s) from %s' % (count, server.name)) + logger.notifyChannel(server.type, netsvc.LOG_INFO, 'fetchmail fetch/process %s email(s) from %s' % (count, server.name)) + except Exception, e: + logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e))) + finally: imap_server.close() imap_server.logout() - elif server.type == 'pop': + elif server.type == 'pop': + try: pop_server = self.button_confirm_login(cr, uid, [server.id], context=context) - pop_server.list() (numMsgs, totalSize) = pop_server.stat() + pop_server.list() for num in range(1, numMsgs + 1): (header, msges, octets) = pop_server.retr(num) msg = '\n'.join(msges) @@ -196,14 +200,11 @@ class email_server(osv.osv): action_pool.run(cr, user, [server.action_id.id], {'active_id': res_id, 'active_ids':[res_id]}) pop_server.dele(num) - + logger.notifyChannel(server.type, netsvc.LOG_INFO, 'fetchmail fetch %s email(s) from %s' % (numMsgs, server.name)) + except Exception, e: + logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e))) + finally: pop_server.quit() - - logger.notifyChannel('imap', netsvc.LOG_INFO, 'fetchmail fetch %s email(s) from %s' % (numMsgs, server.name)) - - except Exception, e: - logger.notifyChannel(server.type, netsvc.LOG_WARNING, '%s' % (tools.ustr(e))) - return True email_server() |
