aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xfeedgetter.py14
-rwxr-xr-xpyAggr3g470r.py12
-rwxr-xr-xutils.py19
3 files changed, 28 insertions, 17 deletions
diff --git a/feedgetter.py b/feedgetter.py
index 1ea9d9d9..7e6e4c71 100755
--- a/feedgetter.py
+++ b/feedgetter.py
@@ -37,19 +37,7 @@ class FeedGetter(object):
Initializes the base and variables.
"""
# Create the base if not exists.
- sqlite3.register_adapter(str, lambda s : s.decode('utf-8'))
- self.conn = sqlite3.connect("./var/feed.db", isolation_level = None)
- self.c = self.conn.cursor()
- self.c.execute('''create table if not exists feeds
- (feed_title text, feed_site_link text, \
- feed_link text PRIMARY KEY, feed_image_link text,
- mail text)''')
- self.c.execute('''create table if not exists articles
- (article_date text, article_title text, \
- article_link text PRIMARY KEY, article_description text, \
- article_readed text, feed_link text)''')
- self.conn.commit()
- self.c.close()
+ utils.create_base()
# mutex to protect the SQLite base
self.locker = threading.Lock()
diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py
index 442cf08f..a9ffd87a 100755
--- a/pyAggr3g470r.py
+++ b/pyAggr3g470r.py
@@ -89,7 +89,7 @@ class Root:
target="_blank"><img src="%s" width="28" height="28" /></a></h2>\n""" % \
(rss_feed_id, \
self.feeds[rss_feed_id][5].encode('utf-8'), \
- self.feeds[rss_feed_id][3].encode('utf-8'), \
+ utils.remove_html_tags(self.feeds[rss_feed_id][3].encode('utf-8')), \
self.feeds[rss_feed_id][4].encode('utf-8'), \
self.feeds[rss_feed_id][2].encode('utf-8'))
@@ -107,7 +107,8 @@ class Root:
html += article[1].encode('utf-8') + \
" - " + not_read_begin + \
"""<a href="/description/%s:%s" rel="noreferrer" target="_blank">%s</a>""" % \
- (rss_feed_id, article[0].encode('utf-8'),article[2].encode('utf-8')) + \
+ (rss_feed_id, article[0].encode('utf-8'), \
+ utils.remove_html_tags(article[2].encode('utf-8'))) + \
not_read_end + \
"<br />\n"
html += "<br />\n"
@@ -605,8 +606,8 @@ class Root:
When a change is detected, reload the base.
"""
mon = gamin.WatchMonitor()
- mon.watch_file(utils.sqlite_base, self.update)
time.sleep(10)
+ mon.watch_file(utils.sqlite_base, self.update)
ret = mon.event_pending()
try:
print "Watching %s" % utils.sqlite_base
@@ -647,7 +648,10 @@ if __name__ == '__main__':
# Point of entry in execution mode
LOCKER = threading.Lock()
root = Root()
- root.update()
+ if not os.path.isfile(utils.sqlite_base):
+ utils.create_base()
+ else:
+ root.update()
try:
import gamin
thread_watch_base = threading.Thread(None, root.watch_base, None, ())
diff --git a/utils.py b/utils.py
index ef6b3977..e0011edd 100755
--- a/utils.py
+++ b/utils.py
@@ -168,6 +168,24 @@ def compare(stringtime1, stringtime2):
return 1
return 0
+def create_base():
+ """
+ Create the base if not exists.
+ """
+ sqlite3.register_adapter(str, lambda s : s.decode('utf-8'))
+ conn = sqlite3.connect("./var/feed.db", isolation_level = None)
+ c = conn.cursor()
+ c.execute('''create table if not exists feeds
+ (feed_title text, feed_site_link text, \
+ feed_link text PRIMARY KEY, feed_image_link text,
+ mail text)''')
+ c.execute('''create table if not exists articles
+ (article_date text, article_title text, \
+ article_link text PRIMARY KEY, article_description text, \
+ article_readed text, feed_link text)''')
+ conn.commit()
+ c.close()
+
def load_feed():
"""
Load feeds and articles in a dictionary.
@@ -232,4 +250,5 @@ def load_feed():
c.close()
LOCKER.release()
return (articles, feeds)
+ LOCKER.release()
return (articles, feeds) \ No newline at end of file
bgstack15