Handle feedparser exception

This commit is contained in:
spla 2021-05-15 11:19:08 +02:00
pare 9ab7d02526
commit 975a752a10
S'han modificat 2 arxius amb 13 adicions i 6 eliminacions

Veure arxiu

@ -3,10 +3,7 @@ import feedparser
from mastodon import Mastodon from mastodon import Mastodon
import psycopg2 import psycopg2
import sys import sys
import time
###############################################################################
# INITIALISATION
###############################################################################
# Returns the parameter from the specified file # Returns the parameter from the specified file
def get_parameter( parameter, file_path ): def get_parameter( parameter, file_path ):
@ -61,7 +58,15 @@ if __name__ == '__main__':
publish = 0 publish = 0
newsfeeds = feedparser.parse(feeds_url) try:
newsfeeds = feedparser.parse(feeds_url)
print(newsfeeds.status)
except:
print(newsfeeds.status)
sys.exit(0)
for entry in newsfeeds.entries: for entry in newsfeeds.entries:
@ -111,6 +116,8 @@ if __name__ == '__main__':
mastodon.status_post(toot_text, in_reply_to_id=None,) mastodon.status_post(toot_text, in_reply_to_id=None,)
time.sleep(2)
######################################################### #########################################################
insert_line = 'INSERT INTO feeds(id, link) VALUES (%s, %s)' insert_line = 'INSERT INTO feeds(id, link) VALUES (%s, %s)'

Veure arxiu

@ -124,7 +124,7 @@ def log_in():
if os.path.exists("app_clientcred.txt"): if os.path.exists("app_clientcred.txt"):
print("Removing app_clientcred.txt temp file..") print("Removing app_clientcred.txt temp file..")
os.remove("app_clientcred.txt") os.remove("app_clientcred.txt")
if os.path.exists("app_usercred.txt"): if os.path.exists("app_usercred.txt"):
print("Removing app_usercred.txt temp file..") print("Removing app_usercred.txt temp file..")
os.remove("app_usercred.txt") os.remove("app_usercred.txt")
print("Secrets setup done!\n") print("Secrets setup done!\n")