remove unneeded clash params

This commit is contained in:
spla 2022-03-21 19:24:10 +01:00
pare 5ba03a1c86
commit 4d2da23196

Veure arxiu

@ -9,6 +9,7 @@ from mastodon import Mastodon
import psycopg2
import matplotlib.pyplot as plt
import ray
import pdb
ray.init(num_cpus = 32) # Specify this system CPUs.
@ -16,25 +17,17 @@ class Server:
name = 'Server'
def __init_(self, server, software, users, alive, api, soft_version, now):
def __init_(self, server=None):
self.server = server
self.software = software
self.users = users
self.alive = alive
self.api = api
self.version = self.soft_version
self.now = now
@ray.remote
def get_alive_servers(server):
def get_alive_servers(self):
users = 0
downs = 0
fediverse_db, fediverse_db_user = db_config()
try:
conn = None
@ -43,7 +36,7 @@ class Server:
cur = conn.cursor()
cur.execute("select alive, software, users_api, version, first_checked_at, downs from fediverse where server=(%s)", (server,))
cur.execute("select alive, software, users_api, version, first_checked_at, downs from fediverse where server=(%s)", (self,))
row = cur.fetchone()
@ -74,7 +67,7 @@ class Server:
user_agent = {'User-agent': "fediverse's servers stats (fediverse@mastodont.cat)"}
data = requests.get('https://' + server + api, headers = user_agent, timeout=3)
data = requests.get('https://' + self + api, headers = user_agent, timeout=3)
try:
@ -127,62 +120,62 @@ class Server:
if soft_version != "" and soft_version is not None:
print(f'\n** Server {server} ({software} {soft_version}) is alive! **')
print(f'\n** Server {self} ({software} {soft_version}) is alive! **')
else:
print(f'\n** Server {server} ({software}) is alive! **')
print(f'\n** Server {self} ({software}) is alive! **')
write_alive_server(server, software, soft_version, alive, api, users, downs, first_checked_at)
write_alive_server(self, software, soft_version, alive, api, users, downs, first_checked_at)
except urllib3.exceptions.ProtocolError as protoerr:
print_dead(server)
print_dead(self)
pass
except requests.exceptions.ChunkedEncodingError as chunkerr:
print_dead(server)
print_dead(self)
pass
except KeyError as e:
print_dead(server)
print_dead(self)
pass
except ValueError as verr:
print_dead(server)
print_dead(self)
pass
except requests.exceptions.SSLError as errssl:
print_dead(server)
print_dead(self)
pass
except requests.exceptions.HTTPError as errh:
print_dead(server)
print_dead(self)
pass
except requests.exceptions.ConnectionError as errc:
print_dead(server)
print_dead(self)
pass
except requests.exceptions.Timeout as errt:
print_dead(server)
print_dead(self)
pass
except requests.exceptions.RequestException as err:
print_dead(server)
print_dead(self)
pass
except socket.gaierror as gai_error:
print_dead(server)
print_dead(self)
pass
if not alive:
@ -195,9 +188,9 @@ class Server:
downs = 1
write_not_alive_server(server, software, soft_version, alive, api, users, downs, first_checked_at)
write_not_alive_server(self, software, soft_version, alive, api, users, downs, first_checked_at)
return (server, software, soft_version, alive, api, users, downs, first_checked_at)
return (self, software, soft_version, alive, api, users, downs, first_checked_at)
def write_alive_server(server, software, soft_version, alive, api, users, downs, first_checked_at):
@ -504,6 +497,8 @@ if __name__ == '__main__':
if sys.argv[1] == '--multi':
fediverse_db, fediverse_db_user = db_config()
start = datetime.now()
program = 'fediverse'
@ -512,12 +507,10 @@ if __name__ == '__main__':
save_time(program, start, finish)
now = datetime.now()
now = start
mastodon, mastodon_hostname = mastodon()
fediverse_db, fediverse_db_user = db_config()
total_servers = 0
total_users = 0