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. --- README | 3 +- feedgetter.py | 16 +++++++---- pyAggr3g470r.py | 11 ++++++++ tuxdroid.py | 88 --------------------------------------------------------- utils.py | 15 ++++++++-- 5 files changed, 36 insertions(+), 97 deletions(-) delete mode 100755 tuxdroid.py diff --git a/README b/README index 3be66923..b725dba6 100644 --- a/README +++ b/README @@ -9,8 +9,7 @@ based on CherryPy. Articles are stored in a SQLite base. * export articles (HTML and raw text); * mark or unmark an article as favorites; * share an article on Google Buzz, del.icio.us, Digg, reddit, Scoopeo and Blogmarks; -* language detection and search articles by language; -* TuxDroid support (for the notification of unread articles). +* language detection and search articles by language. 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 diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index 85605b88..1d530137 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -24,6 +24,7 @@ bindhost = "0.0.0.0" cherrypy.config.update({ 'server.socket_port': 12556, 'server.socket_host': bindhost}) +# static files path = {'/css/style.css': {'tools.staticfile.on': True, \ 'tools.staticfile.filename':utils.path+'/css/style.css'}, \ '/css/img/feed-icon-28x28.png': {'tools.staticfile.on': True, \ @@ -56,6 +57,10 @@ path = {'/css/style.css': {'tools.staticfile.on': True, \ 'tools.staticdir.dir': os.path.join(utils.path, './var/qrcode')}} def htmlheader(nb_unread_articles=""): + """ + Return the header of the HTML page with the number of unread articles + in the 'title' HTML tag.. + """ return '\n' + \ '' + \ '\n\t'+ nb_unread_articles +'pyAggr3g470r - RSS Feed Reader\n' + \ @@ -76,6 +81,10 @@ htmlnav = '\n