当前位置: 首页>>代码示例>>Python>>正文


Python Entry.publish_for_feed方法代码示例

本文整理汇总了Python中models.Entry.publish_for_feed方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.publish_for_feed方法的具体用法?Python Entry.publish_for_feed怎么用?Python Entry.publish_for_feed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在models.Entry的用法示例。


在下文中一共展示了Entry.publish_for_feed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post_all_feeds

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import publish_for_feed [as 别名]
def post_all_feeds():
    """Post all new items for feeds for a specific interval"""
    if request.headers.get('X-Appengine-Cron') != 'true':
        raise ndb.Return(jsonify_error(message='Not a cron call'))

    feed_classes = (Feed, InstagramFeed)
    iterators = [x.query().iter() for x in feed_classes]

    errors = 0
    success = 0
    num_posted = 0
    futures = []

    for iterator in iterators:
        while (yield iterator.has_next_async()):
            feed = iterator.next()
            futures.append((feed, Entry.publish_for_feed(feed)))

    for feed, future in futures:
        try:
            num_posts = yield future
            if num_posts is not None:
                num_posted += num_posts
            success += 1
        except:
            errors += 1
            logger.exception('Failed to Publish feed:%s' % (feed.feed_url, ))

    stat = yield write_epoch_to_stat(Stat, 'post_job')
    logger.info('Post Feeds success:%s errors: %s num_posted: %s', success, errors, num_posted)
    raise ndb.Return(jsonify(status='ok'))
开发者ID:ianmintz,项目名称:pourover,代码行数:33,代码来源:views.py

示例2: feed_push_update

# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import publish_for_feed [as 别名]
def feed_push_update(feed_key):
    feed = ndb.Key(urlsafe=feed_key).get()
    if not feed:
        raise ndb.Return(("No feed", 404))

    data = request.stream.read()

    if feed.hub_secret:
        server_signature = request.headers.get('X-Hub-Signature', None)
        signature = hmac.new(feed.hub_secret, data).hexdigest()

        if server_signature != signature:
            logger.warn('Got PuSH subscribe POST for feed key=%s w/o valid signature: sent=%s != expected=%s', feed_key,
                        server_signature, signature)

            raise ndb.Return('')

    logger.info('Got PuSH body: %s', data)
    logger.info('Got PuSH headers: %s', request.headers)

    parsed_feed = feedparser.parse(data)
    new_guids, old_guids = yield Entry.process_parsed_feed(parsed_feed, feed, overflow=False)
    yield Entry.publish_for_feed(feed, skip_queue=False)

    raise ndb.Return('')
开发者ID:ianmintz,项目名称:pourover,代码行数:27,代码来源:views.py


注:本文中的models.Entry.publish_for_feed方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。