aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcedricbonhomme <devnull@localhost>2012-03-04 08:37:07 +0100
committercedricbonhomme <devnull@localhost>2012-03-04 08:37:07 +0100
commit26b2f4f3ce39b94a32a60e4aa99e8b2aeb07cb20 (patch)
tree35909c8c76842e41017d643d2a93391faf2a99c8
parentNotifications page is working. Improved get_all_collections function. (diff)
downloadnewspipe-26b2f4f3ce39b94a32a60e4aa99e8b2aeb07cb20.tar.gz
newspipe-26b2f4f3ce39b94a32a60e4aa99e8b2aeb07cb20.tar.bz2
newspipe-26b2f4f3ce39b94a32a60e4aa99e8b2aeb07cb20.zip
Removed useless code concerning SQLite and the update method (inotify) on the old database.
-rwxr-xr-xfeedgetter.py24
-rwxr-xr-xpyAggr3g470r.py60
2 files changed, 5 insertions, 79 deletions
diff --git a/feedgetter.py b/feedgetter.py
index 74b7b3a0..b9d61c69 100755
--- a/feedgetter.py
+++ b/feedgetter.py
@@ -27,7 +27,6 @@ __license__ = "GPLv3"
import os.path
import traceback
-import sqlite3
import threading
import feedparser
import hashlib
@@ -52,15 +51,9 @@ class FeedGetter(object):
"""
Initializes the base and variables.
"""
- # Create the base if not exists.
- utils.create_base()
-
# MongoDB connections
self.articles = mongodb.Articles()
- # mutex to protect the SQLite base
- self.locker = threading.Lock()
-
def retrieve_feed(self):
"""
Parse the file 'feeds.lst' and launch a thread for each RSS feed.
@@ -89,25 +82,12 @@ class FeedGetter(object):
"""Request the URL
Executed in a thread.
- SQLite objects created in a thread can only be used in that same thread !
"""
- # Protect this part of code.
- self.locker.acquire()
-
- self.conn = sqlite3.connect(utils.sqlite_base, isolation_level = None)
- self.c = self.conn.cursor()
-
if utils.detect_url_errors([the_good_url]) == []:
# if ressource is available add the articles in the base.
- self.add_into_sqlite(the_good_url)
-
- self.conn.commit()
- self.c.close()
-
- # Release this part of code.
- self.locker.release()
+ self.add_into_database(the_good_url)
- def add_into_sqlite(self, feed_link):
+ def add_into_database(self, feed_link):
"""
Add the articles of the feed 'a_feed' in the SQLite base.
"""
diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py
index 72c8272e..53a283a1 100755
--- a/pyAggr3g470r.py
+++ b/pyAggr3g470r.py
@@ -41,7 +41,6 @@ __license__ = "GPLv3"
import os
import re
import time
-import sqlite3
import cherrypy
import calendar
import threading
@@ -1008,15 +1007,7 @@ class Root:
feed = self.feeds[feed_id]
except:
return self.error_page("Bad URL. This feed do not exists.")
- conn = sqlite3.connect(utils.sqlite_base, isolation_level = None)
- try:
- c = conn.cursor()
- c.execute("""UPDATE feeds SET mail=%s WHERE feed_site_link='%s'""" % (action, self.feeds[feed_id].feed_site_link))
- except:
- return self.error_page("Error")
- finally:
- conn.commit()
- c.close()
+
return self.index()
mail_notification.exposed = True
@@ -1174,9 +1165,8 @@ class Root:
the data base.
"""
if max_nb_articles < -1 or max_nb_articles == 0:
- max_nb_articles = 1
+ max_nb_articles = 1
utils.MAX_NB_ARTICLES = int(max_nb_articles)
- self.update()
return self.management()
set_max_articles.exposed = True
@@ -1191,15 +1181,7 @@ class Root:
article = self.feeds[feed_id].articles[article_id]
except:
return self.error_page("Bad URL. This article do not exists.")
- try:
- conn = sqlite3.connect(utils.sqlite_base, isolation_level = None)
- c = conn.cursor()
- c.execute("DELETE FROM articles WHERE article_link='" + article.article_link +"'")
- except Exception, e:
- return e
- finally:
- conn.commit()
- c.close()
+
return self.index()
delete_article.exposed = True
@@ -1262,23 +1244,6 @@ class Root:
epub.exposed = True
- #
- # Monitoring functions
- #
- def update(self, path=None, event = None):
- """
- Synchronizes transient objects (dictionary of feed and articles) with the database.
- Called when a changes in the database is detected.
- """
- self.feeds, \
- self.nb_articles, self.nb_unread_articles, \
- self.nb_favorites, self.nb_mail_notifications = utils.load_feed()
- if self.feeds != {}:
- print "Base (%s) loaded" % utils.sqlite_base
- else:
- print "Base (%s) empty!" % utils.sqlite_base
-
-
if __name__ == '__main__':
# Point of entry in execution mode
print "Launching pyAggr3g470r..."
@@ -1290,23 +1255,4 @@ if __name__ == '__main__':
#cherrypy.config.update({'error_page.404': error_page_404})
_cp_config = {'request.error_response': handle_error}
-
- #if not os.path.isfile(utils.sqlite_base):
- ## create the SQLite base if not exists
- #print "Creating data base..."
- #utils.create_base()
- ## load the informations from base in memory
- #print "Loading informations from data base..."
- #root.update()
- ## launch the available base monitoring method (gamin or classic)
- #try:
- #import gamin
- #thread_watch_base = threading.Thread(None, root.watch_base, None, ())
- #except:
- #print "The gamin module is not installed."
- #print "The base of feeds will be monitored with the simple method."
- #thread_watch_base = threading.Thread(None, root.watch_base_classic, None, ())
- #thread_watch_base.setDaemon(True)
- #thread_watch_base.start()
-
cherrypy.quickstart(root, "/" ,config=utils.path + "/cfg/cherrypy.cfg")
bgstack15