jobs.py 文件源码

python
阅读 27 收藏 0 点赞 0 评论 0

项目:FRG-Crowdsourcing 作者: 97amarnathk 项目源码 文件源码
def news():
    """Get news from different ATOM RSS feeds."""
    import feedparser
    from pybossa.core import sentinel
    from pybossa.news import get_news, notify_news_admins, FEED_KEY
    try:
        import cPickle as pickle
    except ImportError:  # pragma: no cover
        import pickle
    urls = ['https://github.com/pybossa/pybossa/releases.atom',
            'http://scifabric.com/blog/all.atom.xml']
    score = 0
    notify = False
    if current_app.config.get('NEWS_URL'):
        urls += current_app.config.get('NEWS_URL')
    for url in urls:
        d = feedparser.parse(url)
        tmp = get_news(score)
        if (len(tmp) == 0) or (tmp[0]['updated'] != d.entries[0]['updated']):
            sentinel.master.zadd(FEED_KEY, float(score),
                                 pickle.dumps(d.entries[0]))
            notify = True
        score += 1
    if notify:
        notify_news_admins()
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号