本文整理汇总了Python中models.Entry.update_for_feed方法的典型用法代码示例。如果您正苦于以下问题:Python Entry.update_for_feed方法的具体用法?Python Entry.update_for_feed怎么用?Python Entry.update_for_feed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Entry
的用法示例。
在下文中一共展示了Entry.update_for_feed方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: feed_push_update
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import update_for_feed [as 别名]
def feed_push_update(feed_key):
feed = ndb.Key(urlsafe=feed_key).get()
if not feed:
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)
return ''
logger.info('Got PuSH body: %s', data)
logger.info('Got PuSH headers: %s', request.headers)
Entry.update_for_feed(feed, publish=True, skip_queue=True)
return ''
示例2: update_all_feeds
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import update_for_feed [as 别名]
def update_all_feeds(interval_id):
"""Update all feeds for a specific interval"""
if request.headers.get('X-Appengine-Cron') != 'true':
return jsonify_error(message='Not a cron call')
feeds = Feed.for_interval(interval_id)
for feed in feeds:
feed.prepare_request()
errors = 0
success = 0
for feed in feeds:
try:
Entry.update_for_feed(feed, publish=True)
success += 1
except FetchException, e:
errors += 1
pass
except Exception, e:
errors += 1
logger.exception('Failed to update feed:%s' % (feed.feed_url, ))
示例3: tq_feed_poll
# 需要导入模块: from models import Entry [as 别名]
# 或者: from models.Entry import update_for_feed [as 别名]
def tq_feed_poll():
"""Poll some feeds feed"""
if not request.headers.get('X-AppEngine-QueueName'):
raise ndb.Return(jsonify_error(message='Not a Task call'))
keys = request.form.get('keys')
if not keys:
logger.info('Task Queue poll no keys')
raise ndb.Return(jsonify_error(code=500))
success = 0
errors = 0
entries_created = 0
logger.info('Getting feeds')
ndb_keys = [ndb.Key(urlsafe=key) for key in keys.split(',')]
feeds = yield ndb.get_multi_async(ndb_keys)
logger.info('Got %d feed(s)', len(feeds))
futures = []
for i, feed in enumerate(feeds):
if not feed:
errors += 1
logger.info("Couldn't find feed for key: %s", ndb_keys[i])
continue
futures.append((i, Entry.update_for_feed(feed)))
for i, future in futures:
try:
parsed_feed, num_new_entries = yield future
entries_created += num_new_entries
success += 1
except:
errors += 1
feed = feeds[i]
logger.exception('Failed to update feed:%s, i=%s' % (feed.feed_url, i))
logger.info('Polled feeds entries_created: %s success: %s errors: %s', entries_created, success, errors)
raise ndb.Return(jsonify(status='ok'))