Beispiel #1
0
    def invoke(self, feedid, lastmod):
        feedid = int(feedid)
        lastmod = lastmod.replace('%', ' ')
        if lastmod == "None":
            lastmod = None

        feed = dbimpl.feeddb.get_feed_by_id(feedid)
        if not feed: # might have been gc-ed in the meantime
            return

        items = {} # url -> item (so we can check for new ones)
        for item in feed.get_items():
            items[item.get_link()] = item

        # read xml
        try:
            file = os.path.join(FEED_CACHE, "feed-%s.rss" % feedid)
            site = rsslib.read_feed(file, rsslib.DefaultFactory(),
                                    rsslib.urllib_loader)
            feed.set_error(None)
            os.unlink(file)
        except Exception, e:
            # we failed, so record the failure and move on
            #traceback.print_exc()
            feed.set_error(str(e))
            feed.save()
            os.unlink(file)
            return
Beispiel #2
0
 def invoke(self, feedid, lastmod):
     feedid = int(feedid)
     lastmod = lastmod.replace('%', ' ')
     if lastmod == "None":
         lastmod = None
     
     feed = dbimpl.feeddb.get_feed_by_id(feedid)
     if not feed: # might have been gc-ed in the meantime
         return
     
     items = {} # url -> item (so we can check for new ones)
     for item in feed.get_items():
         items[item.get_link()] = item
         
     # read xml
     try:
         file = os.path.join(FEED_CACHE, "feed-%s.rss" % feedid)
         site = rsslib.read_feed(file, rsslib.DefaultFactory(),
                                 rsslib.urllib_loader)
         feed.set_error(None)
         os.unlink(file)
     except Exception, e:
         # we failed, so record the failure and move on
         #traceback.print_exc()
         feed.set_error(str(e))
         feed.save()
         os.unlink(file)
         return
Beispiel #3
0
    def read_feed(self, url):
        oldsite = self._feedurlmap.get(url)
        if oldsite:
            oldsite.being_read()

        try:
            site = rsslib.read_feed(url, wzfactory)
        except Exception, e:
            if oldsite:
                oldsite.not_being_read()
                oldsite.set_error(traceback.format_exc())
            if not isinstance(e, IOError):
                traceback.print_exc()
            else:
                print "ERROR: ", e
            return []  # we didn't get any feed, so no point in continuing
Beispiel #4
0
 def read_feed(self, url):
     oldsite = self._feedurlmap.get(url)
     if oldsite:
         oldsite.being_read()
             
     try:
         site = rsslib.read_feed(url, wzfactory)
     except Exception, e:
         if oldsite:
             oldsite.not_being_read()
             oldsite.set_error(traceback.format_exc())
         if not isinstance(e, IOError):
             traceback.print_exc()
         else:
             print "ERROR: ", e
         return [] # we didn't get any feed, so no point in continuing
Beispiel #5
0
    def check_feed(self, key):
        feed = db.get(db.Key(key))
        if not feed:
            # this means the feed has been deleted, and so the task is no
            # longer necessary. we should just return and let the task die.
            logging.info("Tried to check non-existent feed with key " + key)
            return

        try:
            site = rsslib.read_feed(feed.xmlurl, data_loader=gae_loader)
        except Exception, e:
            # we failed, so record the failure and move on
            traceback.print_exc()
            feed.error = str(e)
            feed.lasterror = datetime.datetime.now()
            feed.put()
            return
Beispiel #6
0
 def add_feed(self, feedurl):
     feeddb.add_feed(rsslib.read_feed(feedurl, wzfactory))
Beispiel #7
0
 def add_feed(self, feedurl):
     feeddb.add_feed(rsslib.read_feed(feedurl, wzfactory))