Esempio n. 1
0
    def getImages(self, request, queryset, *arg1, **arg2):
        for image in queryset:
            logging.info('start to fetch images,The url is %s', image.oldurl)
            try:
                name = htmllib.sid() + '.jpg'
                result = getpage(htmllib.encoding(image.oldurl), 30)
                if result.code == 200:
                    result = self.__store_images(result.read(), name, image)
                else:
                    result = False
                if result:
                    logging.info('Success!')
                else:
                    logging.info('this one was Fail!')

            except Exception, data:
                logging.info(data)
Esempio n. 2
0
    def getImages(self, request, queryset, *arg1, **arg2):
                for image in queryset:
                        logging.info('start to fetch images,The url is %s', image.oldurl)
                        try:
                                name = htmllib.sid() + '.jpg'
                                result = getpage(htmllib.encoding(image.oldurl), 30)
                                if result.code == 200:
                                        result = self.__store_images(result.read(), name, image)
                                else:
                                        result = False
                                if result:
                                        logging.info('Success!')
                                else:
                                        logging.info('this one was Fail!')

                        except Exception, data:
                                logging.info(data)
Esempio n. 3
0
 def __store_entry(self, feed):
     try:
         entry, result = Entry.published.get_or_create(title=feed.title)
         entry.excerpt = feed.excerpt
         entry.status = 2
         entry.author_name = feed.author_name
         entry.date = feed.date
         entry.slug = htmllib.sid()
         entry.content = self.__Parse_image(feed.content)
         entry.categories.add(feed.feed.category)
         entry.save()
         feed.fetch_stat = 4
         feed.save()
     except Exception, data:
         logging.error('the db saved error is: %s', data)
         feed.fetch_stat = 3
         feed.save()
Esempio n. 4
0
 def __store_entry(self, feed):
             try:
                 entry, result = Entry.published.get_or_create(title=feed.title)
                 entry.excerpt = feed.excerpt
                 entry.status = 2
                 entry.author_name = feed.author_name
                 entry.date = feed.date
                 entry.slug = htmllib.sid() 
                 entry.content = self.__Parse_image(feed.content)
                 entry.categories.add(feed.feed.category)                   
                 entry.save()
                 feed.fetch_stat = 4
                 feed.save()
             except Exception, data:
                     logging.error('the db saved error is: %s', data)
                     feed.fetch_stat = 3
                     feed.save()