mirror of
https://github.com/hubHarmony/servii-backend.git
synced 2024-11-17 21:40:31 +00:00
[+] Useful minecraft servers organizer :)
This commit is contained in:
parent
dec704f3c5
commit
9756697420
30
unit_test.py
30
unit_test.py
@ -1,7 +1,7 @@
|
|||||||
import asyncio
|
|
||||||
import os
|
import os
|
||||||
|
import shutil
|
||||||
|
from typing import Callable, Union
|
||||||
|
|
||||||
import file_manager
|
|
||||||
import firebase_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__)
|
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__':
|
if __name__ == '__main__':
|
||||||
#ban_user("MpkbDMOO8PQddQgB5VgBQdTMWF53")
|
#ban_user("MpkbDMOO8PQddQgB5VgBQdTMWF53")
|
||||||
#file_manager.log_action("gqZN3eCHF3V2er3Py3rlgk8u2t83", "test", "DeleteServer")
|
#file_manager.log_action("gqZN3eCHF3V2er3Py3rlgk8u2t83", "test", "DeleteServer")
|
||||||
#firebase_manager.set_servers_not_running()
|
#firebase_manager.set_servers_not_running()
|
||||||
current_dir_content: list[str] = os.listdir(".")
|
#print(firebase_manager.get_server_field("secret :)", "AMITIE" ,"version"))
|
||||||
parsed_extension: str = '.py'
|
'''
|
||||||
print(file_manager.filter_directory_contents(parsed_extension, current_dir_content))
|
organize_minecraft_files(
|
||||||
|
listdir("/home/hapso/Desktop/Personal/servii-backend/servers/paper"),
|
||||||
|
"/home/hapso/Desktop/Personal/servii-backend/servers/paper")
|
||||||
|
'''
|
||||||
|
pass
|
||||||
|
Loading…
Reference in New Issue
Block a user