Some toot string formatting

This commit is contained in:
spla 2020-08-11 20:07:10 +02:00
pare 2283983227
commit 6d31149031
S'han modificat 1 arxius amb 13 adicions i 7 eliminacions

Veure arxiu

@ -317,18 +317,22 @@ async def getsoft(server):
soft = response_json['software']['name']
soft = soft.lower()
users = response_json['usage']['users']['total']
if users > 1000000:
return
alive = True
write_api(server, soft, users, alive, api)
print("Server " + server + " is alive!")
print("Server " + server + " (" + soft + ") is alive!")
return
except:
pass
if response.status == 200 and soft == '' and api == "/api/v1/instance?":
soft = 'mastodon'
users = response_json['stats']['user_count']
if users > 1000000:
return
alive = True
write_api(server, soft, users, alive, api)
print("Server " + server + " is alive!")
print("Server " + server + " (" + soft + ") is alive!")
def getserver(server, x):
@ -502,6 +506,8 @@ if __name__ == '__main__':
cur.close()
print("Remaining servers: " + str(len(world_servers)))
except (Exception, psycopg2.DatabaseError) as error:
print(error)
@ -714,11 +720,11 @@ if __name__ == '__main__':
toot_text += "\n"
toot_text += "top five (soft: users servers):" + " \n"
toot_text += "\n"
toot_text += '{:>0}: {:>5} {:>5}'.format(str(soft_total_project[0]), str(soft_total_users[0]), str(soft_total_servers[0])) + " \n"
toot_text += '{:>0}: {:>11} {:>8}'.format(str(soft_total_project[1]), str(soft_total_users[1]), str(soft_total_servers[1])) + " \n"
toot_text += '{:>0}: {:>12} {:>7}'.format(str(soft_total_project[2]), str(soft_total_users[2]), str(soft_total_servers[2])) + " \n"
toot_text += '{:>0}: {:>13} {:>7}'.format(str(soft_total_project[3]), str(soft_total_users[3]), str(soft_total_servers[3])) + " \n"
toot_text += '{:>0}: {:>14} {:>7}'.format(str(soft_total_project[4]), str(soft_total_users[4]), str(soft_total_servers[4])) + " \n"
toot_text += '{:<8}: {:>7} {:>4}'.format(str(soft_total_project[0]), str(soft_total_users[0]), str(soft_total_servers[0])) + " \n"
toot_text += '{:<8}: {:>7} {:>4}'.format(str(soft_total_project[1]), str(soft_total_users[1]), str(soft_total_servers[1])) + " \n"
toot_text += '{:<8}: {:>7} {:>4}'.format(str(soft_total_project[2]), str(soft_total_users[2]), str(soft_total_servers[2])) + " \n"
toot_text += '{:<8}: {:>7} {:>4}'.format(str(soft_total_project[3]), str(soft_total_users[3]), str(soft_total_servers[3])) + " \n"
toot_text += '{:<8}: {:>7} {:>4}'.format(str(soft_total_project[4]), str(soft_total_users[4]), str(soft_total_servers[4])) + " \n"
toot_text += "\n"
toot_text += "updated at " + str(last_update) + " \n"
print("Tooting...")