Updated mastofeeds.py
This commit is contained in:
pare
0f16738f03
commit
842b639af1
S'han modificat 1 arxius amb 32 adicions i 32 eliminacions
|
@ -70,70 +70,70 @@ for entry in newsfeeds.entries:
|
|||
|
||||
try:
|
||||
|
||||
conn = None
|
||||
conn = psycopg2.connect(database = feeds_db, user = feeds_db_user, password = "", host = "/var/run/postgresql", port = "5432")
|
||||
conn = None
|
||||
conn = psycopg2.connect(database = feeds_db, user = feeds_db_user, password = "", host = "/var/run/postgresql", port = "5432")
|
||||
|
||||
cur = conn.cursor()
|
||||
cur = conn.cursor()
|
||||
|
||||
cur.execute('select link from feeds where link=(%s)', (link,))
|
||||
cur.execute('select link from feeds where link=(%s)', (link,))
|
||||
|
||||
row = cur.fetchone()
|
||||
if row == None:
|
||||
publish = 1
|
||||
else:
|
||||
publish = 0
|
||||
row = cur.fetchone()
|
||||
if row == None:
|
||||
publish = 1
|
||||
else:
|
||||
publish = 0
|
||||
|
||||
cur.close()
|
||||
cur.close()
|
||||
|
||||
except (Exception, psycopg2.DatabaseError) as error:
|
||||
|
||||
print(error)
|
||||
print(error)
|
||||
|
||||
finally:
|
||||
|
||||
if conn is not None:
|
||||
if conn is not None:
|
||||
|
||||
conn.close()
|
||||
conn.close()
|
||||
|
||||
###########################################################
|
||||
|
||||
if publish == 1:
|
||||
|
||||
toot_text = str(title)+'\n'
|
||||
toot_text += str(link)
|
||||
toot_text = str(title)+'\n'
|
||||
toot_text += str(link)
|
||||
|
||||
print("Tooting...")
|
||||
print(toot_text)
|
||||
print("Tooting...")
|
||||
print(toot_text)
|
||||
|
||||
mastodon.status_post(toot_text, in_reply_to_id=None,)
|
||||
mastodon.status_post(toot_text, in_reply_to_id=None,)
|
||||
|
||||
#########################################################
|
||||
|
||||
insert_line = 'INSERT INTO feeds(link) VALUES (%s)'
|
||||
insert_line = 'INSERT INTO feeds(link) VALUES (%s)'
|
||||
|
||||
conn = None
|
||||
conn = None
|
||||
|
||||
try:
|
||||
try:
|
||||
|
||||
conn = psycopg2.connect(database = feeds_db, user = feeds_db_user, password = "", host = "/var/run/postgresql", port = "5432")
|
||||
conn = psycopg2.connect(database = feeds_db, user = feeds_db_user, password = "", host = "/var/run/postgresql", port = "5432")
|
||||
|
||||
cur = conn.cursor()
|
||||
cur = conn.cursor()
|
||||
|
||||
cur.execute(insert_line, (id,))
|
||||
cur.execute(insert_line, (id,))
|
||||
|
||||
conn.commit()
|
||||
conn.commit()
|
||||
|
||||
cur.close()
|
||||
cur.close()
|
||||
|
||||
except (Exception, psycopg2.DatabaseError) as error:
|
||||
except (Exception, psycopg2.DatabaseError) as error:
|
||||
|
||||
print(error)
|
||||
print(error)
|
||||
|
||||
finally:
|
||||
finally:
|
||||
|
||||
if conn is not None:
|
||||
if conn is not None:
|
||||
|
||||
conn.close()
|
||||
conn.close()
|
||||
else:
|
||||
|
||||
print("Any new feeds")
|
||||
print("Any new feeds")
|
||||
|
|
Loading…
Referencia en una nova incidència