from os.path import isfile, isdir, exists
from os import mkdir, remove, stat, environ
+import logging
+logger = logging.getLogger(__name__)
+
+import debugging
+debugging.init(dot_directory=".feedingit", program_name="feedingit-web")
+
CONFIGDIR = environ.get("HOME", "/home/user") + "/.feedingit"
#CONFIGDIR = "/home/user/.feedingit/"
def start_server():
global listing
- listing = Listing(CONFIGDIR)
+ listing = Listing(config, CONFIGDIR)
httpd = BaseHTTPServer.HTTPServer(("127.0.0.1", PORT), Handler)
httpd.serve_forever()
# download = Download(listing, feeds)
# download.start()
-class Download(Thread):
- def __init__(self, listing, keys):
- Thread.__init__(self)
- self.listing = listing
- self.keys = keys
-
- def run (self):
- updateDbusHandler.UpdateStarted()
- for key in self.keys:
- print "Start update: %s" % key
- updatingFeeds.append(key)
- (use_proxy, proxy) = config.getProxy()
- try:
- if use_proxy:
- self.listing.updateFeed(key, proxy=proxy, imageCache=config.getImageCache() )
- else:
- self.listing.updateFeed(key, imageCache=config.getImageCache() )
- except:
- print "Error updating feed: %s" %key
- updatingFeeds.remove(key)
- print "End update: %s" % key
- updateDbusHandler.UpdateFinished()
-
class Handler(BaseHTTPServer.BaseHTTPRequestHandler):
def updateAll(self):
- feeds = []
for cat in listing.getListOfCategories():
for feed in listing.getSortedListOfKeys("Manual", category=cat):
- feeds.append(feed)
- download = Download(listing, feeds)
- download.start()
+ listing.updateFeed(feed)
def openTaskSwitch(self):
import subprocess
if markAllAsRead=="True":
feed.markAllAsRead()
listing.updateUnread(key)
- updateDbusHandler.ArticleCountUpdated()
xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?><xml>"
if onlyUnread == "False":
onlyUnread = False
feed = listing.getFeed(key)
feed.setEntryRead(article)
listing.updateUnread(key)
- updateDbusHandler.ArticleCountUpdated()
self.send_response(200)
self.send_header("Content-type", "text/html")
self.end_headers()
xml = "<xml>OK</xml>"
elif request[1] == "updateFeed":
key = request[2]
- download = Download(listing, [key,])
- download.start()
+ listing.updateFeed(key)
xml = "<xml>OK</xml>"
elif request[1]=="updateAll":
#app.automaticUpdate()
self.updateAll()
- updateDbusHandler.ArticleCountUpdated()
xml = "<xml>OK</xml>"
elif request[1] == "addCat":
catName = request[2]
try:
mkdir(CONFIGDIR)
except:
- print "Error: Can't create configuration directory"
+ logger.error("Error: Can't create configuration directory")
from sys import exit
exit(1)
-# Start the HTTP server in a new thread
-thread.start_new_thread(start_server, ())
-
# Initialize the glib mainloop, for dbus purposes
from feedingitdbus import ServerObject
-from updatedbus import UpdateServerObject, get_lock
+from updatedbus import UpdateServerObject
import gobject
gobject.threads_init()
import dbus.mainloop.glib
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
+import mainthread
+mainthread.init()
+from jobmanager import JobManager
+JobManager(True)
-global updateDbusHandler, dbusHandler
app = App()
dbusHandler = ServerObject(app)
-updateDbusHandler = UpdateServerObject(app)
+
+# Start the HTTP server in a new thread
+thread.start_new_thread(start_server, ())
mainloop = gobject.MainLoop()
mainloop.run()