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
39 debugging.init(dot_directory=".feedingit", program_name="update_feeds")
41 CONFIGDIR="/home/user/.feedingit/"
42 #DESKTOP_FILE = "/usr/share/applications/hildon-status-menu/feedingit_status.desktop"
45 from socket import setdefaulttimeout
47 setdefaulttimeout(timeout)
50 from updatedbus import UpdateServerObject
54 self.config = Config(self, CONFIGDIR+"config.ini")
55 self.dbusHandler = UpdateServerObject(self)
56 self.listing = Listing(self.config, CONFIGDIR)
60 jm.stats_hook_register (self.job_manager_update,
61 run_in_main_thread=True)
63 self.dbusHandler.UpdateStarted()
64 for k in self.listing.getListOfFeeds():
65 self.listing.updateFeed (k)
67 def job_manager_update(self, jm, old_stats, new_stats, updated_feed):
68 if not new_stats['jobs-queued'] and not new_stats['jobs-in-progress']:
69 self.dbusHandler.UpdateFinished()
70 self.dbusHandler.ArticleCountUpdated()
75 print "Stop update called."
78 import dbus.mainloop.glib
79 dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
81 gobject.threads_init()
83 mainloop = gobject.MainLoop()
85 app_lock = get_lock("app_lock")
92 except KeyboardInterrupt:
93 print "Interrupted. Quitting."
97 logger.error("Update in progress")