diff --git a/unit_test.py b/unit_test.py index 7c25236..8c842c0 100644 --- a/unit_test.py +++ b/unit_test.py @@ -1,7 +1,7 @@ -import asyncio import os +import shutil +from typing import Callable, Union -import file_manager import firebase_manager @@ -13,10 +13,30 @@ def ban_user(user_id: str): print("Error banning user " + user_id, "|", str(e), type(e).__name__) +def organize_minecraft_files(file_list: list[str], target_directory: str): + os.makedirs(target_directory, exist_ok=True) + + for file_name in file_list: + if file_name.endswith('.jar'): + version = file_name.split('-')[1] + version_folder = os.path.join(target_directory, version) + + os.makedirs(version_folder, exist_ok=True) + + source_path = os.path.join(target_directory, file_name) + destination_path = os.path.join(version_folder, 'server.jar') + + shutil.move(source_path, destination_path) + + if __name__ == '__main__': #ban_user("MpkbDMOO8PQddQgB5VgBQdTMWF53") #file_manager.log_action("gqZN3eCHF3V2er3Py3rlgk8u2t83", "test", "DeleteServer") #firebase_manager.set_servers_not_running() - current_dir_content: list[str] = os.listdir(".") - parsed_extension: str = '.py' - print(file_manager.filter_directory_contents(parsed_extension, current_dir_content)) + #print(firebase_manager.get_server_field("secret :)", "AMITIE" ,"version")) + ''' + organize_minecraft_files( + listdir("/home/hapso/Desktop/Personal/servii-backend/servers/paper"), + "/home/hapso/Desktop/Personal/servii-backend/servers/paper") + ''' + pass