Ejemplo n.º 1
0
def get_local_tweets(source, limit):
    try:
        with open(source.file, "r") as fh:
            input_lines = fh.readlines()
    except (FileNotFoundError, PermissionError) as e:
        logger.debug(e)
        return []
    local_tweets = parse_string(input_lines, source)
    return sorted(local_tweets, reverse=True)[:limit]
Ejemplo n.º 2
0
def retrieve_file(source, limit):
    try:
        response = yield from aiohttp.get(source.url)
        content = yield from response.text()
    except Exception as e:
        logger.debug(e)
        return []
    if response.status == 200:
        tweets = parse_string(content.splitlines(), source)
        return sorted(tweets, reverse=True)[:limit]
    else:
        return []
Ejemplo n.º 3
0
def retrieve_file(source, limit):
    try:
        response = yield from aiohttp.get(source.url)
        content = yield from response.text()
    except Exception as e:
        logger.debug(e)
        return []
    if response.status == 200:
        tweets = parse_string(content.splitlines(), source, limit)
        return tweets
    else:
        return []
Ejemplo n.º 4
0
Archivo: http.py Proyecto: tedder/twtxt
def retrieve_file(source, limit, timeout):
    try:
        with aiohttp.Timeout(timeout):
            response = yield from aiohttp.get(source.url)
        content = yield from response.text()
    except Exception as e:
        logger.debug(e)
        return []
    if response.status == 200:
        tweets = parse_string(content.splitlines(), source)
        return sorted(tweets, reverse=True)[:limit]
    else:
        return []