Esempio n. 1
0
def fetch_asyncio(user_id, feed_id):
    "Crawl the feeds with asyncio."
    import asyncio

    with application.app_context():
        populate_g()
        from flask import g
        from web.models import User
        from crawler import classic_crawler
        users = []
        try:
            users = User.query.filter(User.id == int(user_id)).all()
        except:
            users = User.query.all()
        finally:
            if users == []:
                users = User.query.all()

        try:
            feed_id = int(feed_id)
        except:
            feed_id = None

        loop = asyncio.get_event_loop()
        for user in users:
            if user.activation_key == "":
                print("Fetching articles for " + user.nickname)
                g.user = user
                classic_crawler.retrieve_feed(loop, g.user, feed_id)
        loop.close()
Esempio n. 2
0
def fetch_asyncio(user_id, feed_id):
    "Crawl the feeds with asyncio."
    import asyncio

    with application.app_context():
        from flask.ext.login import current_user
        from crawler import classic_crawler
        ucontr = UserController()
        users = []
        try:
            users = [ucontr.get(user_id)]
        except:
            users = ucontr.read()
        finally:
            if users == []:
                users = ucontr.read()

        try:
            feed_id = int(feed_id)
        except:
            feed_id = None

        loop = asyncio.get_event_loop()
        for user in users:
            if user.is_active:
                logger.warn("Fetching articles for " + user.login)
                classic_crawler.retrieve_feed(loop, current_user, feed_id)
        loop.close()
Esempio n. 3
0
def fetch_asyncio(user_id, feed_id):
    "Crawl the feeds with asyncio."
    import asyncio

    with application.app_context():
        from flask.ext.login import current_user
        from crawler import classic_crawler
        ucontr = UserController()
        users = []
        try:
            users = [ucontr.get(user_id)]
        except:
            users = ucontr.read()
        finally:
            if users == []:
                users = ucontr.read()

        try:
            feed_id = int(feed_id)
        except:
            feed_id = None

        loop = asyncio.get_event_loop()
        for user in users:
            if user.is_active:
                logger.warn("Fetching articles for " + user.login)
                classic_crawler.retrieve_feed(loop, current_user, feed_id)
        loop.close()
Esempio n. 4
0
def fetch_asyncio(user_id, feed_id):
    "Crawl the feeds with asyncio."
    import asyncio

    with application.app_context():
        populate_g()
        from flask import g
        from web.models import User
        from crawler import classic_crawler
        users = []
        try:
            users = User.query.filter(User.id == int(user_id)).all()
        except:
            users = User.query.all()
        finally:
            if users == []:
                users = User.query.all()

        try:
            feed_id = int(feed_id)
        except:
            feed_id = None

        loop = asyncio.get_event_loop()
        for user in users:
            if user.activation_key == "":
                print("Fetching articles for " + user.nickname)
                g.user = user
                classic_crawler.retrieve_feed(loop, g.user, feed_id)
        loop.close()