Fix #4 are remove duplicated function

This commit is contained in:
spla 2022-03-24 13:36:59 +01:00
pare 4d2da23196
commit 42f0c3e58f
S'han modificat 3 arxius amb 8 adicions i 37 eliminacions

Veure arxiu

@ -216,9 +216,9 @@ def write_alive_server(server, software, soft_version, alive, api, users, downs,
cur.execute("UPDATE world SET checked='t' where server=(%s)", (server,))
conn.commit()
conn.commit()
cur.close()
cur.close()
except (Exception, psycopg2.DatabaseError) as error:
@ -248,7 +248,7 @@ def write_not_alive_server(server, software, soft_version, alive, api, users, do
cur.execute("UPDATE fediverse SET updated_at=(%s), alive=(%s), first_checked_at=(%s), downs=(%s) where server=(%s)", (now, alive, now, downs, server))
cur.execute("UPDATE world SET checked='t' where server=(%s)", (server,))
cur.execute("UPDATE world SET checked='f' where server=(%s)", (server,))
conn.commit()
@ -370,35 +370,6 @@ def set_world_servers_check_to_false():
conn.close()
def set_world_servers_check_to_false():
############################################################################
# set all world servers's checked column to False
try:
conn = None
conn = psycopg2.connect(database=fediverse_db, user=fediverse_db_user, password="", host="/var/run/postgresql", port="5432")
cur = conn.cursor()
cur.execute("UPDATE world SET checked='f'")
conn.commit()
cur.close()
except (Exception, psycopg2.DatabaseError) as error:
print(error)
finally:
if conn is not None:
conn.close()
def mastodon():
# Load secrets from secrets file
@ -515,13 +486,13 @@ if __name__ == '__main__':
total_users = 0
set_world_servers_check_to_false()
#set_world_servers_check_to_false()
alive_servers = get_last_checked_servers()
getservers = Server()
getservers.now = datetime.now()
getservers.now = now
ray_start = time.time()

Veure arxiu

@ -316,7 +316,7 @@ def get_world_servers():
# get world servers list
cur.execute("select server from world")# where checked='f'")
cur.execute("select server from world where checked='f'")
rows = cur.fetchall()

Veure arxiu

@ -12,7 +12,7 @@ ray.init(num_cpus = 32) # Specify this system CPUs.
def write_server(server, federated_with):
insert_sql = "INSERT INTO world(server, federated_with, updated_at, saved_at) VALUES(%s,%s,%s,%s) ON CONFLICT DO NOTHING"
insert_sql = "INSERT INTO world(server, federated_with, updated_at, saved_at, checked) VALUES(%s,%s,%s,%s,%s) ON CONFLICT DO NOTHING"
conn = None
@ -22,7 +22,7 @@ def write_server(server, federated_with):
cur = conn.cursor()
cur.execute(insert_sql, (server, federated_with, now, now,))
cur.execute(insert_sql, (server, federated_with, now, now, 'f'))
print(f'writing {server} to world database')