From ea01b913b3a508ad6c45d999eca19a0d1cf5fddc Mon Sep 17 00:00:00 2001 From: cedricbonhomme Date: Fri, 26 Mar 2010 08:22:06 +0100 Subject: Some improvements and one bug fix. --- feedgetter.py | 2 +- pyAggr3g470r.py | 46 +++++++++++++++++++++++++++++----------------- 2 files changed, 30 insertions(+), 18 deletions(-) diff --git a/feedgetter.py b/feedgetter.py index 3dbe2e4c..278cc58d 100755 --- a/feedgetter.py +++ b/feedgetter.py @@ -75,7 +75,7 @@ class FeedGetter(object): # Protect this part of code. self.locker.acquire() - self.conn = sqlite3.connect("./var/feed.db", isolation_level = None) + self.conn = sqlite3.connect(utils.sqlite_base, isolation_level = None) self.c = self.conn.cursor() # Add the articles in the base. diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index 86ddffdc..08222a3d 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -73,12 +73,21 @@ class Root: html += """Your feeds (%s):
\n""" % len(self.articles.keys()) for rss_feed_id in self.articles.keys(): + if self.feeds[rss_feed_id][1] != "0": + # not readed articles are in bold + not_read_begin = "" + not_read_end = "" + else: + not_read_begin = "" + not_read_end = "" + html += """%s (%s / %s)
\n""" % \ - (rss_feed_id.encode('utf-8'), \ - self.feeds[rss_feed_id][3].encode('utf-8'), \ - rss_feed_id, self.feeds[rss_feed_id][1], \ - self.feeds[rss_feed_id][0]) + title="Unread article(s)">%s%s%s / %s)
\n""" % \ + (rss_feed_id.encode('utf-8'), \ + self.feeds[rss_feed_id][3].encode('utf-8'), \ + rss_feed_id, not_read_begin, \ + self.feeds[rss_feed_id][1], not_read_end, \ + self.feeds[rss_feed_id][0]) html += """\n
\n""" @@ -141,12 +150,13 @@ class Root: html += """
\n
\n""" - html += "

Delete Feeds

\n" - html += """
\n""" + if self.articles: + html += "

Delete Feeds

\n" + html += """
\n""" html += "
\n" html += """

The database contains a total of %s article(s) with @@ -194,7 +204,7 @@ class Root: html += "\n\n" html += """""" - html += "


\n" + html += "
\n" html += htmlfooter return html @@ -539,8 +549,8 @@ class Root: identifiant + "'") conn.commit() c.close() - except Exception, e: - pass + except Exception: + self.error_page("Impossible to mark this article as read (database error).") #threading.Thread(None, self.update, None, ()).start() @@ -561,6 +571,8 @@ class Root: action, feed_id = param.split(':') except: return self.error_page("Bad URL") + if feed_id not in self.feeds.keys(): + return self.error_page("This feed do not exists.") conn = sqlite3.connect(utils.sqlite_base, isolation_level = None) c = conn.cursor() if action == "start": @@ -568,13 +580,13 @@ class Root: c.execute("UPDATE feeds SET mail=1 WHERE feed_site_link='" + self.feeds[feed_id][5].encode('utf-8') + "'") except: - pass + return self.error_page("Error") else: try: c.execute("UPDATE feeds SET mail=0 WHERE feed_site_link='" + self.feeds[feed_id][5].encode('utf-8') + "'") except: - pass + return self.error_page("Error") conn.commit() c.close() return self.index() @@ -589,8 +601,8 @@ class Root: Called when an article is marked as read or when new articles are fetched. """ self.articles, self.feeds = utils.load_feed() + self.nb_articles = sum([feed[0] for feed in self.feeds.values()]) if self.articles != {}: - self.nb_articles = sum([feed[0] for feed in self.feeds.values()]) self.top_words = utils.top_words(self.articles, 10) if "pylab" not in utils.IMPORT_ERROR: utils.create_histogram(self.top_words) -- cgit