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]
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 []
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 []
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 []