1 #!/usr/bin/env python2.5
4 # Copyright (c) 2007-2008 INdT.
5 # Copyright (c) 2011 Neal H. Walfield
6 # This program is free software: you can redistribute it and/or modify
7 # it under the terms of the GNU Lesser General Public License as published by
8 # the Free Software Foundation, either version 3 of the License, or
9 # (at your option) any later version.
11 # This program is distributed in the hope that it will be useful,
12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 # GNU Lesser General Public License for more details.
16 # You should have received a copy of the GNU Lesser General Public License
17 # along with this program. If not, see <http://www.gnu.org/licenses/>.
20 # ============================================================================
21 # Name : update_feeds.py
22 # Author : Yves Marcoz
24 # Description : Simple RSS Reader
25 # ============================================================================
27 from rss_sqlite import Listing
28 from config import Config
29 from updatedbus import get_lock, UpdateServerObject
35 from jobmanager import JobManager
38 CONFIGDIR="/home/user/.feedingit/"
39 #DESKTOP_FILE = "/usr/share/applications/hildon-status-menu/feedingit_status.desktop"
42 from socket import setdefaulttimeout
44 setdefaulttimeout(timeout)
47 from updatedbus import UpdateServerObject
53 debug_file = open("/home/user/.feedingit/feedingit_update.log", "a")
55 debug_file.write (*args)
59 self.config = Config(self, CONFIGDIR+"config.ini")
60 self.dbusHandler = UpdateServerObject(self)
61 self.listing = Listing(self.config, CONFIGDIR)
65 jm.stats_hook_register (self.job_manager_update,
66 run_in_main_thread=True)
68 self.dbusHandler.UpdateStarted()
69 for k in self.listing.getListOfFeeds():
70 self.listing.updateFeed (k)
72 def job_manager_update(self, jm, old_stats, new_stats, updated_feed):
73 if not new_stats['jobs-queued'] and not new_stats['jobs-in-progress']:
74 self.dbusHandler.UpdateFinished()
75 self.dbusHandler.ArticleCountUpdated()
80 print "Stop update called."
83 import dbus.mainloop.glib
84 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
86 gobject.threads_init()
88 mainloop = gobject.MainLoop()
90 app_lock = get_lock("app_lock")
97 except KeyboardInterrupt:
98 print "Interrupted. Quitting."
102 debug("Update in progress")