forkeado de spla/fediverse
set alive = True if API is replying
This commit is contained in:
pare
15201a9698
commit
5288dde459
S'han modificat 1 arxius amb 11 adicions i 7 eliminacions
18
fediverse.py
18
fediverse.py
|
@ -102,45 +102,47 @@ def alive_server(server, x):
|
||||||
if serv_api == '/nodeinfo/2.0?':
|
if serv_api == '/nodeinfo/2.0?':
|
||||||
try:
|
try:
|
||||||
users = data.json()['usage']['users']['total']
|
users = data.json()['usage']['users']['total']
|
||||||
|
alive = True
|
||||||
except:
|
except:
|
||||||
users = 0
|
users = 0
|
||||||
if serv_api == '/nodeinfo/2.0.json?':
|
if serv_api == '/nodeinfo/2.0.json?':
|
||||||
try:
|
try:
|
||||||
users = data.json()['usage']['users']['total']
|
users = data.json()['usage']['users']['total']
|
||||||
|
alive = True
|
||||||
except:
|
except:
|
||||||
users = 0
|
users = 0
|
||||||
elif serv_api == '/api/v1/instance?':
|
elif serv_api == '/api/v1/instance?':
|
||||||
try:
|
try:
|
||||||
users = data.json()['stats']['user_count']
|
users = data.json()['stats']['user_count']
|
||||||
|
alive = True
|
||||||
except:
|
except:
|
||||||
users = 0
|
users = 0
|
||||||
alive = True
|
|
||||||
if serv_soft == "pleroma" or serv_soft == "diaspora" or serv_soft == "peertube" or serv_soft == "pixelfed" or serv_soft == "hubzilla" or serv_soft == "writefreely" or serv_soft == "friendica":
|
if serv_soft == "pleroma" or serv_soft == "diaspora" or serv_soft == "peertube" or serv_soft == "pixelfed" or serv_soft == "hubzilla" or serv_soft == "writefreely" or serv_soft == "friendica":
|
||||||
try:
|
try:
|
||||||
users = data.json()['usage']['users']['total']
|
users = data.json()['usage']['users']['total']
|
||||||
|
alive = True
|
||||||
except:
|
except:
|
||||||
users = 0
|
users = 0
|
||||||
alive = True
|
|
||||||
if serv_soft == "gnusocialv2" or serv_soft == "gnusocial":
|
if serv_soft == "gnusocialv2" or serv_soft == "gnusocial":
|
||||||
try:
|
try:
|
||||||
users = data.json()['usage']['users']['total']
|
users = data.json()['usage']['users']['total']
|
||||||
if users == 0:
|
if users == 0:
|
||||||
users = data.json()['usage']['users']['activeHalfyear']
|
users = data.json()['usage']['users']['activeHalfyear']
|
||||||
|
alive = True
|
||||||
except:
|
except:
|
||||||
users = 0
|
users = 0
|
||||||
alive = True
|
|
||||||
if serv_soft == "plume" or serv_soft == 'red' or serv_soft == "misskey" or serv_soft == "zap" or serv_soft == "prismo" or serv_soft == "ravenvale" or serv_soft == "osada" or serv_soft == "groundpolis":
|
if serv_soft == "plume" or serv_soft == 'red' or serv_soft == "misskey" or serv_soft == "zap" or serv_soft == "prismo" or serv_soft == "ravenvale" or serv_soft == "osada" or serv_soft == "groundpolis":
|
||||||
try:
|
try:
|
||||||
users = data.json()['usage']['users']['total']
|
users = data.json()['usage']['users']['total']
|
||||||
|
alive = True
|
||||||
except:
|
except:
|
||||||
users = 0
|
users = 0
|
||||||
alive = True
|
|
||||||
if serv_soft == "ganggo" or serv_soft == "squs" or serv_soft == "dolphin":
|
if serv_soft == "ganggo" or serv_soft == "squs" or serv_soft == "dolphin":
|
||||||
try:
|
try:
|
||||||
users = data.json()['usage']['users']['total']
|
users = data.json()['usage']['users']['total']
|
||||||
|
alive = True
|
||||||
except:
|
except:
|
||||||
users = 0
|
users = 0
|
||||||
alive = True
|
|
||||||
|
|
||||||
print("Server " + str(server) + " (" + serv_soft + ") is alive!")
|
print("Server " + str(server) + " (" + serv_soft + ") is alive!")
|
||||||
|
|
||||||
|
@ -274,11 +276,13 @@ def write_api(server, software, users, alive, api):
|
||||||
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()
|
||||||
|
|
||||||
async def getsoft(server):
|
async def getsoft(server):
|
||||||
|
@ -551,8 +555,8 @@ if __name__ == '__main__':
|
||||||
###########################################################################
|
###########################################################################
|
||||||
# get current total servers and users, get users from every software
|
# get current total servers and users, get users from every software
|
||||||
|
|
||||||
gettotals_sql = "select count(server), sum(users) from fediverse"
|
gettotals_sql = "select count(server), sum(users) from fediverse where alive"
|
||||||
get_soft_totals_sql = "select software, sum(users) as users, count(server) as servers from fediverse where users != 0 group by software order by users desc"
|
get_soft_totals_sql = "select software, sum(users) as users, count(server) as servers from fediverse where users != 0 and alive group by software order by users desc"
|
||||||
soft_total_project = []
|
soft_total_project = []
|
||||||
soft_total_users = []
|
soft_total_users = []
|
||||||
soft_total_servers = []
|
soft_total_servers = []
|
||||||
|
|
Loading…
Referencia en una nova incidència