diff --git a/Scripts/check_servers.py b/Scripts/check_servers.py deleted file mode 100644 --- a/Scripts/check_servers.py +++ /dev/null @@ -1,54 +0,0 @@ - -import os -import os.path -import json - -from datetime import datetime - -DATE_FORMAT = '%d-%m-%Y %H:%M:%S' - -DATADIR = './data' - - -def get_json_files(): - - for root, _, files in os.walk(DATADIR): - for f in files: - if f.endswith('.json'): - yield os.path.join(root, f) - - -def check_all_servers(): - - for f in get_json_files(): - try: - with open(f, encoding='utf-8') as file_object: - data = json.load(file_object) - - with open(f, mode='w', encoding='utf-8') as file_object: - - date = datetime.strptime(data['last_updated'], - DATE_FORMAT) - now = datetime.utcnow() - - delta = now - date - - if delta.seconds >= 3600: - status = 'Offline' - elif delta.seconds >= 1200: - status = 'Unkown' - else: - status = None - - if status: - for key in ('server_status', 'tor_status'): - data[key] = status - - json.dump(data, file_object) - except Exception as e: - print(e) - continue - - -if __name__ == '__main__': - check_all_servers()