當前位置: 首頁>>代碼示例>>Python>>正文


Python models.MFeedPage類代碼示例

本文整理匯總了Python中apps.rss_feeds.models.MFeedPage的典型用法代碼示例。如果您正苦於以下問題:Python MFeedPage類的具體用法?Python MFeedPage怎麽用?Python MFeedPage使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了MFeedPage類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: bootstrap_feedpages

def bootstrap_feedpages():
    print "Mongo DB feed_pages: %s" % MFeedPage.objects().count()
    # db.feed_pages.drop()
    print "Dropped! Mongo DB feed_pages: %s" % MFeedPage.objects().count()

    print "FeedPages: %s" % FeedPage.objects.count()
    pprint(db.feed_pages.index_information())

    feeds = Feed.objects.all().order_by('-average_stories_per_month')
    feed_count = feeds.count()
    i = 0
    for feed in feeds:
        i += 1
        print "%s/%s: %s" % (i, feed_count, feed,)
        sys.stdout.flush()
        
        if not MFeedPage.objects(feed_id=feed.pk):
            feed_page = FeedPage.objects.filter(feed=feed).values()
            if feed_page:
                del feed_page[0]['id']
                feed_page[0]['feed_id'] = feed.pk
                try:
                    MFeedPage(**feed_page[0]).save()
                except:
                    print '\n\n!\n\n'
                    continue
        

    print "\nMongo DB feed_pages: %s" % MFeedPage.objects().count()
開發者ID:dkeskar,項目名稱:NewsBlur,代碼行數:29,代碼來源:bootstrap_mongo.py

示例2: fetch_image_from_page_data

 def fetch_image_from_page_data(self):
     image = None
     image_file = None
     if self.page_data:
         content = self.page_data
     elif settings.BACKED_BY_AWS.get('pages_on_s3') and self.feed.s3_page:
         key = settings.S3_PAGES_BUCKET.get_key(self.feed.s3_pages_key)
         compressed_content = key.get_contents_as_string()
         stream = StringIO(compressed_content)
         gz = gzip.GzipFile(fileobj=stream)
         try:
             content = gz.read()
         except IOError:
             content = None
     else:
         content = MFeedPage.get_data(feed_id=self.feed.pk)
     url = self._url_from_html(content)
     if not url:
         try:
             content = requests.get(self.feed.feed_link).content
             url = self._url_from_html(content)
         except (AttributeError, SocketError, requests.ConnectionError,
                 requests.models.MissingSchema, requests.sessions.InvalidSchema,
                 requests.sessions.TooManyRedirects,
                 requests.models.InvalidURL,
                 requests.models.ChunkedEncodingError,
                 requests.models.ContentDecodingError,
                 LocationParseError, OpenSSLError, PyAsn1Error), e:
             logging.debug(" ---> ~SN~FRFailed~FY to fetch ~FGfeed icon~FY: %s" % e)
開發者ID:stevenatwork,項目名稱:NewsBlur,代碼行數:29,代碼來源:icon_importer.py

示例3: fetch_image_from_page_data

 def fetch_image_from_page_data(self):
     image = None
     image_file = None
     if self.page_data:
         content = self.page_data
     # Deleted By Xinyan Lu : No S3 storage
     # elif settings.BACKED_BY_AWS.get('pages_on_s3') and self.feed.s3_page:
     #     key = settings.S3_PAGES_BUCKET.get_key(self.feed.s3_pages_key)
     #     compressed_content = key.get_contents_as_string()
     #     stream = StringIO(compressed_content)
     #     gz = gzip.GzipFile(fileobj=stream)
     #     try:
     #         content = gz.read()
     #     except IOError:
     #         content = None
     else:
         content = MFeedPage.get_data(feed_id=self.feed.pk)
     # Modified By Xinyan Lu : content may be None
     if content:
         url = self._url_from_html(content)
     else:
         url = None
     if url:
         image, image_file = self.get_image_from_url(url)
     return image, image_file, url
開發者ID:carlchen0928,項目名稱:rssEngine,代碼行數:25,代碼來源:icon_importer.py

示例4: fetch_image_from_page_data

 def fetch_image_from_page_data(self):
     image = None
     image_file = None
     content = MFeedPage.get_data(feed_id=self.feed.pk)
     url = self._url_from_html(content)
     if url:
         image, image_file = self.get_image_from_url(url)
     return image, image_file, url
開發者ID:AnushPrem,項目名稱:NewsBlur,代碼行數:8,代碼來源:icon_importer.py

示例5: load_feed_page

def load_feed_page(request, feed_id):
    if not feed_id:
        raise Http404
        
    data = MFeedPage.get_data(feed_id=feed_id)

    if not data:
        data = "Fetching feed..."
    
    return HttpResponse(data, mimetype='text/html')
開發者ID:mrcrabby,項目名稱:NewsBlur,代碼行數:10,代碼來源:views.py

示例6: load_feed_page

def load_feed_page(request):
    feed_id = int(request.GET.get('feed_id', 0))
    if feed_id == 0:
        raise Http404
        
    data = MFeedPage.get_data(feed_id=feed_id)

    if not data:
        data = "Fetching feed..."
    
    return HttpResponse(data, mimetype='text/html')
開發者ID:francois2metz,項目名稱:NewsBlur,代碼行數:11,代碼來源:views.py

示例7: load_feed_page

def load_feed_page(request):
    feed_id = None
    try:
        feed_id = int(request.REQUEST.get('feed_id', 0))
    except ValueError:
        feed_id_matches = re.search(r'(\d+)', request.REQUEST['feed_id'])
        if feed_id_matches: feed_id = int(feed_id_matches.group(1))
    if not feed_id:
        raise Http404
        
    data = MFeedPage.get_data(feed_id=feed_id)

    if not data:
        data = "Fetching feed..."
    
    return HttpResponse(data, mimetype='text/html')
開發者ID:rkabir,項目名稱:NewsBlur,代碼行數:16,代碼來源:views.py

示例8: fetch_image_from_page_data

 def fetch_image_from_page_data(self):
     image = None
     image_file = None
     if self.page_data:
         content = self.page_data
     elif settings.BACKED_BY_AWS.get('pages_on_s3') and self.feed.s3_page:
         key = settings.S3_PAGES_BUCKET.get_key(self.feed.s3_pages_key)
         compressed_content = key.get_contents_as_string()
         stream = StringIO(compressed_content)
         gz = gzip.GzipFile(fileobj=stream)
         content = gz.read()
     else:
         content = MFeedPage.get_data(feed_id=self.feed.pk)
     url = self._url_from_html(content)
     if url:
         image, image_file = self.get_image_from_url(url)
     return image, image_file, url
開發者ID:alliepape,項目名稱:NewsBlur,代碼行數:17,代碼來源:icon_importer.py


注:本文中的apps.rss_feeds.models.MFeedPage類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。