From 0c71eb643d5b82e797b64217a43261a124d3aeb8 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Tue, 13 Apr 2010 10:20:06 +0200 Subject: [PATCH] error messages when backend is not found or if it does not implement ICapMessagesReply --- scripts/monboob | 25 ++++++++++--------------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/scripts/monboob b/scripts/monboob index e69a21e93e..2d0ee9d0aa 100755 --- a/scripts/monboob +++ b/scripts/monboob @@ -29,7 +29,7 @@ import time import re import sys -from weboob.capabilities.messages import ICapMessages +from weboob.capabilities.messages import ICapMessages, ICapMessagesReply from weboob.tools.application import ConsoleApplication from weboob.tools.misc import html2text @@ -77,24 +77,19 @@ class Monboob(ConsoleApplication): content = content.split(u'\n-- \n')[0] bname, id = reply_to.split('.', 1) - backend = self.weboob.backends[bname] + try: + backend = self.weboob.backends[bname] + except KeyError: + print >>sys.stderr, 'Backend %s not found' % bname + return 1 + + if not backend.has_caps(ICapMessagesReply): + print >>sys.stderr, 'The backend %s does not implement ICapMessagesReply' % bname + return 1 thread_id, msg_id = id.rsplit('.', 1) backend.post_reply(thread_id, msg_id, title, content) - MAIL_REGEXP = re.compile('(.*) <(.*)@(.*)>') - def get_mail(self, text): - if not text: - return None - - m = self.MAIL_REGEXP.match(text) - if not m: - to = text.split('@')[0] - else: - to = m.group(2) - - return to - @ConsoleApplication.command("run daemon") def command_run(self): self.weboob.repeat(self.config.get('interval'), self.process) -- GitLab