diff options
author | cedricbonhomme <devnull@localhost> | 2010-03-24 09:29:39 +0100 |
---|---|---|
committer | cedricbonhomme <devnull@localhost> | 2010-03-24 09:29:39 +0100 |
commit | 2b54c068f99b826982e72af1c3e3d18c7a5a9a7f (patch) | |
tree | 0c4b7eb8d5891cb986707fa7720ed4581375527d | |
parent | Release 1.0. Mail notification. A lot of improvements and some bug fix. (diff) | |
download | newspipe-2b54c068f99b826982e72af1c3e3d18c7a5a9a7f.tar.gz newspipe-2b54c068f99b826982e72af1c3e3d18c7a5a9a7f.tar.bz2 newspipe-2b54c068f99b826982e72af1c3e3d18c7a5a9a7f.zip |
Mail notifications are sent through a new thread. Some improvements.
-rwxr-xr-x | feedgetter.py | 6 | ||||
-rwxr-xr-x | pyAggr3g470r.py | 12 |
2 files changed, 10 insertions, 8 deletions
diff --git a/feedgetter.py b/feedgetter.py index 5239dd2a..70883ed5 100755 --- a/feedgetter.py +++ b/feedgetter.py @@ -125,13 +125,11 @@ class FeedGetter(object): result = self.c.execute("SELECT mail from feeds WHERE feed_site_link='" + \ a_feed.feed.link.encode('utf-8') + "'").fetchall() if result[0][0] == "1": - # send the article - utils.send_mail(utils.mail_from, utils.mail_to, \ - a_feed.feed.title.encode('utf-8'), description) + # 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() except sqlite3.IntegrityError: # article already in the base pass diff --git a/pyAggr3g470r.py b/pyAggr3g470r.py index a9d6af8f..6327994e 100755 --- a/pyAggr3g470r.py +++ b/pyAggr3g470r.py @@ -120,9 +120,9 @@ class Root: >Unread article(s) (%s)</a>""" % (rss_feed_id, \ self.feeds[rss_feed_id][1]) if self.feeds[rss_feed_id][6] == "0": - html += """<br />\n<a href="/mail_notification/start:%s">Stay tuned</a>""" % (rss_feed_id,) + html += """<br />\n<a href="/mail_notification/start:%s" title="By e-mail">Stay tuned</a>""" % (rss_feed_id,) else: - html += """<br />\n<a href="/mail_notification(/stop:%s">Stop staying tuned</a>""" % (rss_feed_id,) + html += """<br />\n<a href="/mail_notification(/stop:%s" title="By e-mail">Stop staying tuned</a>""" % (rss_feed_id,) html += """<h4><a href="/#top">Top</a></h4>""" html += "<hr />\n" html += htmlfooter @@ -616,7 +616,7 @@ class Root: if ret > 0: print "The base of feeds (%s) has changed.\nReloading..." % utils.sqlite_base ret = mon.handle_one_event() - time.sleep(2) + time.sleep(1) except KeyboardInterrupt: pass print "Stop watching", sqlite_base @@ -629,11 +629,12 @@ class Root: Monitor the base of feeds if the module gamin is not installed. """ + time.sleep(10) old_size = 0 try: print "Watching %s" % utils.sqlite_base while True: - time.sleep(5) + time.sleep(2) # very simple test if os.path.getsize(utils.sqlite_base) != old_size: print "The base of feeds (%s) has changed.\nReloading..." % utils.sqlite_base @@ -649,8 +650,11 @@ if __name__ == '__main__': LOCKER = threading.Lock() root = Root() if not os.path.isfile(utils.sqlite_base): + # create the SQLite base if not exists utils.create_base() + # load the informations from base in memory root.update() + # launch the available base monitoring method (gamin or classic) try: import gamin thread_watch_base = threading.Thread(None, root.watch_base, None, ()) |