send a mail when an error occured while posting a message

This commit is contained in:
Romain Bignon 2010-05-20 14:31:26 +02:00
commit bbca6f3f81

View file

@ -1,6 +1,4 @@
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vim: ft=python et softtabstop=4 cinoptions=4 shiftwidth=4 ts=4 ai
# Copyright(C) 2009-2010 Romain Bignon, Christophe Benz
#
@ -27,7 +25,7 @@ import time
import re
import sys
from weboob.capabilities.messages import ICapMessages, ICapMessagesReply
from weboob.capabilities.messages import ICapMessages, ICapMessagesReply, Message
from weboob.tools.application import ConsoleApplication
from weboob.tools.misc import html2text
@ -100,8 +98,15 @@ class Monboob(ConsoleApplication):
return 1
thread_id, msg_id = id.rsplit('.', 1)
for m in backend.post_reply(thread_id, msg_id, title, content):
self.send_email(backend, m)
try:
backend.post_reply(thread_id, msg_id, title, content)
except Exception, e:
self.send_email(backend, Message(thread_id,
0,
title='Unable to send message',
sender='Monboob',
reply_id=msg_id,
content='Unable to send message to %s:\n\n\t%s' % (thread_id, e)))
@ConsoleApplication.command("run daemon")
def command_run(self):