currentTime = 0
- have_woodchuck = mainthread.execute (wc().available)
-
def wc_success():
try:
wc().stream_register (self.key, "", 6 * 60 * 60)
# this first.
if http_status == 304:
logger.debug("%s: No changes to feed." % (self.key,))
- mainthread.execute (wc_success, async=True)
+ mainthread.execute(wc_success, async=True)
success = True
elif len(tmp["entries"])==0 and not tmp.version:
# An error occured fetching or parsing the feed. (Version
% (url, str (tmp.version),
str (tmp.get ('bozo_exception', 'Unknown error'))))
logger.debug(tmp)
- if have_woodchuck:
- def e():
+ def register_stream_update_failed(http_status):
+ def doit():
logger.debug("%s: stream update failed!" % self.key)
try:
if 500 <= http_status and http_status < 600:
ec = woodchuck.TransferStatus.TransientNetwork
wc()[self.key].update_failed(ec)
- mainthread.execute (e, async=True)
+ return doit
+ if wc().available:
+ mainthread.execute(
+ register_stream_update_failed(
+ http_status=http_status),
+ async=True)
else:
currentTime = time.time()
# The etag and modified value should only be updated if the content was not null
# Register the object with Woodchuck and mark it as
# downloaded.
- if have_woodchuck:
- def e():
+ def register_object_transferred(
+ id, title, publication_time,
+ sent, received, object_size):
+ def doit():
+ logger.debug("Registering transfer of object %s"
+ % title)
try:
obj = wc()[self.key].object_register(
object_identifier=id,
- human_readable_name=tmpEntry["title"])
+ human_readable_name=title)
except woodchuck.ObjectExistsError:
obj = wc()[self.key][id]
else:
- # If the entry does not contain a publication
- # time, the attribute won't exist.
- pubtime = entry.get ('date_parsed', None)
- if pubtime:
- obj.publication_time = time.mktime (pubtime)
-
- received = (progress_handler.stats['received']
- - received_base)
- sent = progress_handler.stats['sent'] - sent_base
- obj.transferred (
- indicator=(woodchuck.Indicator.ApplicationVisual
- |woodchuck.Indicator.StreamWide),
+ obj.publication_time = publication_time
+ obj.transferred(
+ indicator=(
+ woodchuck.Indicator.ApplicationVisual
+ |woodchuck.Indicator.StreamWide),
transferred_down=received,
transferred_up=sent,
object_size=object_size)
- mainthread.execute(e, async=True)
+ return doit
+ if wc().available:
+ # If the entry does not contain a publication
+ # time, the attribute won't exist.
+ pubtime = entry.get('date_parsed', None)
+ if pubtime:
+ publication_time = time.mktime (pubtime)
+ else:
+ publication_time = None
+
+ sent = progress_handler.stats['sent'] - sent_base
+ received = (progress_handler.stats['received']
+ - received_base)
+
+ mainthread.execute(
+ register_object_transferred(
+ id=id,
+ title=tmpEntry["title"],
+ publication_time=publication_time,
+ sent=sent, received=received,
+ object_size=object_size),
+ async=True)
self.db.commit()
logger.debug (
self.db.execute("UPDATE feed SET read=1 WHERE id=?;", (id,) )
self.db.commit()
- def e():
- if wc().available():
- try:
- wc()[self.key][id].used()
- except KeyError:
- pass
+ def doit():
+ try:
+ wc()[self.key][id].used()
+ except KeyError:
+ pass
+ if wc().available():
+ mainthread.execute(doit, async=True)
def setEntryUnread(self, id):
self.db.execute("UPDATE feed SET read=0 WHERE id=?;", (id,) )
self.db.execute("DELETE FROM images WHERE id=?;", (id,) )
self.db.commit()
- def e():
- if wc().available():
- try:
- wc()[self.key][id].files_deleted (
- woodchuck.DeletionResponse.Deleted)
- del wc()[self.key][id]
- except KeyError:
- pass
- mainthread.execute (e, async=True)
+ def doit():
+ try:
+ wc()[self.key][id].files_deleted (
+ woodchuck.DeletionResponse.Deleted)
+ del wc()[self.key][id]
+ except KeyError:
+ pass
+ if wc().available():
+ mainthread.execute (doit, async=True)
class ArchivedArticles(Feed):
def addArchivedArticle(self, title, link, date, configdir):