From fbdf6e78583dcf62f0cb8a6196bbe061526dbde7 Mon Sep 17 00:00:00 2001 From: James Simmons <53658028+simmonsj330@users.noreply.github.com> Date: Thu, 15 Sep 2022 07:04:53 -0500 Subject: [PATCH] adding warning to news (#2545) Co-authored-by: Colin Delahunty <72827203+colin99d@users.noreply.github.com> --- openbb_terminal/common/feedparser_model.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/openbb_terminal/common/feedparser_model.py b/openbb_terminal/common/feedparser_model.py index afee68d5ec7..9ec240e07d2 100644 --- a/openbb_terminal/common/feedparser_model.py +++ b/openbb_terminal/common/feedparser_model.py @@ -49,17 +49,21 @@ def get_news( "https://news.google.com/rss/search?q=when:24h&hl=en-US&gl=US&ceid=US:en" ) - if data.status == 200: # Checking if data request succeeded + if ( + hasattr(data, "status") and data.status == 200 + ): # Checking if data has status attribute and if data request succeeded if data.entries: have_data = True - elif limit == 60: # Breaking if 60 successful requests return no data console.print("[red]Timeout occurred. Please try again\n[/red") break limit = limit + 1 - elif data.status != 200: # If data request failed + elif hasattr(data, "status") and data.status != 200: # If data request failed console.print("[red]Status code not 200. Unable to retrieve data\n[/red]") break + else: + console.print("[red]Could not retrieve data\n[/red]") + break return pd.DataFrame(data.entries, columns=["title", "link", "published"])