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 psycopg2
import matplotlib.pyplot as plt import matplotlib.pyplot as plt
import ray import ray
import pdb
ray.init(num_cpus = 32) # Specify this system CPUs. ray.init(num_cpus = 32) # Specify this system CPUs.
@ -16,25 +17,17 @@ class Server:
name = 'Server' name = 'Server'
def __init_(self, server, software, users, alive, api, soft_version, now): def __init_(self, server=None):
self.server = server 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 @ray.remote
def get_alive_servers(server): def get_alive_servers(self):
users = 0 users = 0
downs = 0 downs = 0
fediverse_db, fediverse_db_user = db_config()
try: try:
conn = None conn = None
@ -43,7 +36,7 @@ class Server:
cur = conn.cursor() 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() row = cur.fetchone()
@ -74,7 +67,7 @@ class Server:
user_agent = {'User-agent': "fediverse's servers stats (fediverse@mastodont.cat)"} 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: try:
@ -127,62 +120,62 @@ class Server:
if soft_version != "" and soft_version is not None: 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: 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: except urllib3.exceptions.ProtocolError as protoerr:
print_dead(server) print_dead(self)
pass pass
except requests.exceptions.ChunkedEncodingError as chunkerr: except requests.exceptions.ChunkedEncodingError as chunkerr:
print_dead(server) print_dead(self)
pass pass
except KeyError as e: except KeyError as e:
print_dead(server) print_dead(self)
pass pass
except ValueError as verr: except ValueError as verr:
print_dead(server) print_dead(self)
pass pass
except requests.exceptions.SSLError as errssl: except requests.exceptions.SSLError as errssl:
print_dead(server) print_dead(self)
pass pass
except requests.exceptions.HTTPError as errh: except requests.exceptions.HTTPError as errh:
print_dead(server) print_dead(self)
pass pass
except requests.exceptions.ConnectionError as errc: except requests.exceptions.ConnectionError as errc:
print_dead(server) print_dead(self)
pass pass
except requests.exceptions.Timeout as errt: except requests.exceptions.Timeout as errt:
print_dead(server) print_dead(self)
pass pass
except requests.exceptions.RequestException as err: except requests.exceptions.RequestException as err:
print_dead(server) print_dead(self)
pass pass
except socket.gaierror as gai_error: except socket.gaierror as gai_error:
print_dead(server) print_dead(self)
pass pass
if not alive: if not alive:
@ -195,9 +188,9 @@ class Server:
downs = 1 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): 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': if sys.argv[1] == '--multi':
fediverse_db, fediverse_db_user = db_config()
start = datetime.now() start = datetime.now()
program = 'fediverse' program = 'fediverse'
@ -512,12 +507,10 @@ if __name__ == '__main__':
save_time(program, start, finish) save_time(program, start, finish)
now = datetime.now() now = start
mastodon, mastodon_hostname = mastodon() mastodon, mastodon_hostname = mastodon()
fediverse_db, fediverse_db_user = db_config()
total_servers = 0 total_servers = 0
total_users = 0 total_users = 0