app.py 文件源码

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

项目:aniping 作者: kuruoujou 项目源码 文件源码
def scan_scrapers():
    """On demand scrapper scanning handler.

    For some reason the scheduler doesn't always work, this endpoint allows for
    instant scanning, assuming it's not already occurring. The function is aborted
    with a ``404`` message to hide the page if the user is not authenticated.

    Scanning can take a long time - 20 to 30 minutes - so it's recommended this
    endpoint be called asynchronously.

    Returns:
       JSON formatted output to identify that scanning has completed or is already
       ongoing.
    """
    log.debug("Entering scan_scrapers.")
    if fe.check_login_id(escape(session['logged_in'])):
        log.debug("User is logged in, attempting to begin scan.")
        if not fe.scrape_shows():
            log.debug("scrape_shows returned false, either the lockfile exists incorrectly or scraping is ongoing.")
            return jsonify({"scan":"failure", "reason":"A scan is ongoing"})
        log.debug("scrape_shows just returned. Returning success.")
        return jsonify({"scan":"success"})
    log.debug("User cannot be authenticated, send 404 to hide page.")
    abort(404)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号