Esempio n. 1
0
    def handle(self, **kwargs):
        """Update the items for each channel."""
        utils.set_short_socket_timeout()
        now = datetime.now()

        def callback(channel):
            if channel.state == Channel.SUSPENDED and now.weekday() != 6:
                # only check suspended feeds on Sunday
                return
            if not channel.is_approved() and \
                    channel.state != Channel.SUSPENDED:
                # only check approved/suspended feeds
                return
            if channel.id % 24 != now.hour:
                # check channels throughout the day, some each hour
                return
            try:
                start = time.time()
                channel.update_items()
                length = time.time() - start
                if length > 6:
                    logging.warn("Update too slow for %s: %f" %
                                 (channel.url, length))
            except:
                logging.warn("\nError updating items for %s\n\n%s\n" %
                             (channel, traceback.format_exc()))

        utils.spawn_threads_for_channels('updating items', callback, 4)
Esempio n. 2
0
 def handle(self, **kwargs):
     """Update the items for each channel."""
     utils.set_short_socket_timeout()
     now = datetime.now()
     def callback(channel):
         if channel.state == Channel.SUSPENDED and now.weekday() != 6:
             # only check suspended feeds on Sunday
             return
         if not channel.is_approved() and \
                 channel.state != Channel.SUSPENDED:
             # only check approved/suspended feeds
             return
         if channel.id % 24 != now.hour:
             # check channels throughout the day, some each hour
             return
         try:
             start = time.time()
             channel.update_items()
             length = time.time() - start
             if length > 6:
                 logging.warn("Update too slow for %s: %f" % (channel.url,
                                                              length))
         except:
             logging.warn("\nError updating items for %s\n\n%s\n" %
                     (channel, traceback.format_exc()))
     utils.spawn_threads_for_channels('updating items', callback, 4)
Esempio n. 3
0
 def handle(self, redownload=False, **kwargs):
     """
     update channel thumbnails.
     """
     utils.set_short_socket_timeout()
     def callback(channel):
         try:
             channel.download_item_thumbnails(redownload)
         except:
             logging.warn("\nerror updating thumbnails for %s\n\n%s\n" %
                          (unicode(channel).encode('utf8'),
                           traceback.format_exc()))
     utils.spawn_threads_for_channels('updating thumbnails', callback, 1)
Esempio n. 4
0
    def handle(self, redownload=False, **kwargs):
        """
        update channel thumbnails.
        """
        utils.set_short_socket_timeout()

        def callback(channel):
            try:
                channel.download_item_thumbnails(redownload)
            except:
                logging.warn(
                    "\nerror updating thumbnails for %s\n\n%s\n" %
                    (unicode(channel).encode('utf8'), traceback.format_exc()))

        utils.spawn_threads_for_channels('updating thumbnails', callback, 1)