Merge pull request #262 from DidierRLopes/fix-twitter-api-key-wrong

Twitter commands sentiment/infer to fail smoothly when wrong API Key
This commit is contained in:
jmaslek
2021-03-22 16:44:50 -04:00
committed by GitHub

View File

@@ -128,6 +128,10 @@ def inference(l_args, s_ticker):
row = get_data(tweet)
df_tweets = df_tweets.append(row, ignore_index=True)
elif response.status_code == 401:
print("Twitter API Key provided is incorrect\n")
return
# Load sentiment model
sentiment_model = flair.models.TextClassifier.load("en-sentiment")
print("")
@@ -287,6 +291,10 @@ def sentiment(l_args, s_ticker):
row = get_data(tweet)
df_tweets = df_tweets.append(row, ignore_index=True)
elif response.status_code == 401:
print("Twitter API Key provided is incorrect\n")
return
# Load sentiment model
print("")
sentiment_model = flair.models.TextClassifier.load("en-sentiment")