From 19a37ccdfa89d724221fcf92818000d9d4f32798 Mon Sep 17 00:00:00 2001 From: Romain Bignon Date: Sun, 28 Feb 2010 11:48:00 +0100 Subject: [PATCH] sqlite is optional with Browser --- weboob/tools/browser.py | 9 +++++++-- weboob2mail | 15 +++++++++------ 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/weboob/tools/browser.py b/weboob/tools/browser.py index 60603f10bb..efa3c93fc5 100644 --- a/weboob/tools/browser.py +++ b/weboob/tools/browser.py @@ -27,7 +27,12 @@ from logging import warning, error from copy import copy -from weboob.tools.firefox_cookies import FirefoxCookieJar +try: + from weboob.tools.firefox_cookies import FirefoxCookieJar + HAVE_COOKIES = True +except ImportError, e: + warning("Unable to store cookies: %s" % e) + HAVE_COOKIES = False class BrowserIncorrectPassword(Exception): pass @@ -86,7 +91,7 @@ def __init__(self, username, password=None, firefox_cookies=None): ] # Share cookies with firefox - if firefox_cookies: + if firefox_cookies and HAVE_COOKIES: self.__cookie = FirefoxCookieJar(self.DOMAIN, firefox_cookies) self.__cookie.load() self.set_cookiejar(self.__cookie) diff --git a/weboob2mail b/weboob2mail index fd2a2bdfe8..9e95d74e2b 100755 --- a/weboob2mail +++ b/weboob2mail @@ -29,6 +29,7 @@ import sys from weboob import Weboob from weboob.capabilities import CAP_MAILS +from weboob.tools.application import BaseApplication class User: def __init__(self, username, password, email): @@ -36,13 +37,15 @@ class User: self.password = password self.email = email -class Application: +class Application(BaseApplication): APPNAME = 'weboob2mail' - def __init__(self): - self.weboob = Weboob(self.APPNAME) - def main(self, argv): + if not self.config.values: + print >>sys.stderr, "Error: %s is not configured yet. Please call 'weboob2mail -c'" % argv[0] + print >>sys.stderr, "Also, you need to use 'weboobcfg' to set backend configs" + return -1 + self.weboob.loadmodules(CAP_MAILS) self.weboob.schedule(interval, self.process) @@ -56,8 +59,8 @@ class Application: self.send_email(m) def send_email(self, mail): - domain = '' - recipient = '' + domain = self.config.items['domain'] + recipient = self.config.items['recipient'] reply_id = '' if mail.getReplyID(): -- GitLab