From ebee8232877ae4d6a297967dad3a9fe7ed40abd6 Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Wed, 22 Sep 2010 21:27:37 +0200 Subject: Added more comments. Cleaner code. --- feedgetter.py | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) (limited to 'feedgetter.py') diff --git a/feedgetter.py b/feedgetter.py index 6b875c64..56e61662 100755 --- a/feedgetter.py +++ b/feedgetter.py @@ -103,15 +103,17 @@ class FeedGetter(object): for article in a_feed['entries']: description = "" try: + # article content description = article.content[0].value.encode('utf-8') except AttributeError: try: + # article description description = article.description.encode('utf-8') except Exception, e: description = "" try: - self.c.execute('insert into articles values (?,?,?,?,?,?,?)', (\ + self.c.execute('insert into articles values (?, ?, ?, ?, ?, ?, ?)', (\ datetime(*article.updated_parsed[:6]), \ utils.clear_string(article.title.encode('utf-8')), \ article.link.encode('utf-8'), \ @@ -123,10 +125,14 @@ class FeedGetter(object): a_feed.feed.link.encode('utf-8') + "'").fetchall() if result[0][0] == "1": # send the article by e-mail - threading.Thread(None, utils.send_mail, \ - None, (utils.mail_from, utils.mail_to, \ - a_feed.feed.title.encode('utf-8'), description) \ - ).start() + try: + threading.Thread(None, utils.send_mail, \ + None, (utils.mail_from, utils.mail_to, \ + a_feed.feed.title.encode('utf-8'), description) \ + ).start() + except Exception, e: + # SMTP acces denied, to many SMTP connections, etc. + print e except sqlite3.IntegrityError: # article already in the base pass -- cgit