import tkinter as tk import paramiko as pm import json def on_btn_list(): hostname = ent_server_hostname.get() user = ent_user.get() password = ent_password.get() ssh_list_addons(hostname, user, password) def ssh_list_addons(hn, user, pw): ssh = pm.SSHClient() ssh.set_missing_host_key_policy(pm.AutoAddPolicy()) ssh.connect(hostname=hn, username=user, password=pw) get_installed_addons(ssh) #get_addon_json_data(ssh, "behavior_pack", "Bedrock-Bridge") ssh.close() def get_installed_addons(ssh): stdin, stdout, stderr = ssh.exec_command("docker exec -t minecraft ls -1 /data/behavior_packs/") txt_box.delete(1.0, tk.END) txt_box.insert(tk.END, "Installed behavior packs:\n") output = stdout.readlines() for item in output: line = str(item).replace("\n", "") #print(line) if(line.find("vanilla") == -1 and line.find("experimental") == -1 and line.find("chemistry") == -1): #print("LINE = " + line) uuid, version = get_addon_json_data(ssh, "behavior_pack", line) #uuid = "abc" #version = "123" #txt_box.insert(tk.END, '> ' + line + "(UUID: " + uuid + "; Version: " + version + ")\n") txt_box.insert(tk.END, f"> {line}\n (UUID = {str(uuid)}; Version = {str(version)})\n\n") txt_box.insert(tk.END, "\nInstalled resource packs:\n") stdin, stdout, stderr = ssh.exec_command("docker exec -t minecraft ls -1 /data/resource_packs/") output = stdout.readlines() for item in output: line = str(item).replace("\n", "") #print(line) if(line.find("vanilla") == -1 and line.find("experimental") == -1 and line.find("chemistry") == -1): uuid, version = get_addon_json_data(ssh, "resource_pack", line) #txt_box.insert(tk.END, '> ' + line) txt_box.insert(tk.END, f"> {line}\n (UUID = {str(uuid)}; Version = {str(version)})\n\n") def get_addon_json_data(ssh, pack_type:str, addon:str): print("\n" + pack_type + "\n") print("\n" + addon + "\n") command = f"docker exec -t minecraft cat /data/{pack_type}s/{addon.strip()}/manifest.json" stdin, stdout, stderr = ssh.exec_command(command) output = stdout.readlines() string = "" for item in output: line = str(item) string = string + line manifest = json.loads(string) uuid = manifest.get('header', {}).get('uuid', 'No UUID found') version_list = manifest.get('header', {}).get('version', []) version = '.'.join(map(str, version_list)) if version_list else 'No version found' print(f"UUID = {uuid} VERSION = {version} VERSION_LIST = {version_list}") #return uuid, version return uuid, version_list window = tk.Tk() frm_a = tk.Frame(master=window) frm_b = tk.Frame(master=window, bg="green") lbl_server_hostname = tk.Label(master=frm_a, text="Server Hostname").pack(side="top") ent_server_hostname = tk.Entry(master=frm_a) ent_server_hostname.pack() lbl_user = tk.Label(master=frm_a, text="user").pack() ent_user = tk.Entry(master=frm_a) ent_user.pack() lbl_password = tk.Label(master=frm_a, text="password").pack() ent_password = tk.Entry(master=frm_a,show='*') ent_password.pack() txt_box = tk.Text(master=frm_b, bg='black', fg='green') txt_box.pack(expand=True, fill="both") btn_login = tk.Button(master=frm_a,text="list installed addons", command=on_btn_list).pack() frm_a.pack(side="left", padx=20, pady=20) frm_b.pack(expand=True, fill="both", padx=20, pady=20) window.mainloop()