Compare commits
No commits in common. "786143081bf83ccbc9a822615d227e0687d5cb80" and "460e99dcd46c6a262ccde5900d9785351393f33d" have entirely different histories.
786143081b
...
460e99dcd4
75
Backend.py
75
Backend.py
@ -1,75 +0,0 @@
|
|||||||
from ftplib import FTP_TLS as FTP
|
|
||||||
import io
|
|
||||||
import json
|
|
||||||
import tempfile
|
|
||||||
import subprocess
|
|
||||||
import time
|
|
||||||
import os
|
|
||||||
import datetime
|
|
||||||
|
|
||||||
|
|
||||||
def perform_installation(instance_name, prism_command, prism_instance_path):
|
|
||||||
ftp = FTP("gitea.piwalker.net")
|
|
||||||
ftp.login()
|
|
||||||
ftp.prot_p()
|
|
||||||
|
|
||||||
# Fetching versions.json from FTP
|
|
||||||
bio = io.BytesIO()
|
|
||||||
ftp.retrbinary("RETR versions.json", bio.write)
|
|
||||||
bio.seek(0)
|
|
||||||
versions = json.load(bio)
|
|
||||||
bio.close()
|
|
||||||
|
|
||||||
# Checking current version
|
|
||||||
version = "0.0.0"
|
|
||||||
version_file_path = os.path.join(prism_instance_path, instance_name, ".minecraft", "version.txt")
|
|
||||||
if os.path.exists(version_file_path):
|
|
||||||
with open(version_file_path, 'r') as fp:
|
|
||||||
version = fp.readline().rstrip()
|
|
||||||
|
|
||||||
# Checking if update is needed
|
|
||||||
if version != versions[-1]["Version"]:
|
|
||||||
print(f"Current version: {version}")
|
|
||||||
print(f"Latest version: {versions[-1]['Version']}")
|
|
||||||
|
|
||||||
# Downloading modpack
|
|
||||||
with tempfile.TemporaryDirectory() as temp_dir:
|
|
||||||
modpack_file_path = os.path.join(temp_dir, instance_name + ".mrpack")
|
|
||||||
with open(modpack_file_path, 'wb') as modpack:
|
|
||||||
ftp.retrbinary("RETR " + versions[-1]["File"], modpack.write)
|
|
||||||
|
|
||||||
# Running PrismLauncher with modpack
|
|
||||||
subprocess.Popen([prism_command, '-I', modpack_file_path])
|
|
||||||
|
|
||||||
# Waiting for installation to complete
|
|
||||||
while True:
|
|
||||||
time.sleep(5)
|
|
||||||
if os.path.exists(version_file_path):
|
|
||||||
with open(version_file_path, 'r') as fp:
|
|
||||||
version = fp.readline().rstrip()
|
|
||||||
if version == versions[-1]["Version"]:
|
|
||||||
break
|
|
||||||
|
|
||||||
# Launching PrismLauncher with the instance
|
|
||||||
subprocess.run([prism_command, '-l', instance_name])
|
|
||||||
|
|
||||||
|
|
||||||
def upload_pack(username, password, version_tag, fileName):
|
|
||||||
ftp = FTP("gitea.piwalker.net", username, password)
|
|
||||||
ftp.prot_p()
|
|
||||||
bio = io.BytesIO()
|
|
||||||
ftp.retrbinary("RETR versions.json", bio.write)
|
|
||||||
bio.seek(0)
|
|
||||||
versions = json.load(bio)
|
|
||||||
bio.close()
|
|
||||||
time = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
|
|
||||||
versions.append({"Version":version_tag, "Date":time, "File":"Versions/fcs7-"+time+".mrpack"})
|
|
||||||
with open(fileName, 'rb') as fp:
|
|
||||||
ftp.storbinary("STOR "+versions[len(versions)-1]["File"], fp)
|
|
||||||
bio = io.BytesIO()
|
|
||||||
bio.write(json.dumps(versions).encode())
|
|
||||||
bio.seek(0)
|
|
||||||
ftp.storbinary("STOR versions.json", bio)
|
|
||||||
bio.close()
|
|
||||||
ftp.close()
|
|
||||||
|
|
53
Main.py
53
Main.py
@ -1,8 +1,13 @@
|
|||||||
|
from ftplib import FTP
|
||||||
import os
|
import os
|
||||||
|
import io
|
||||||
|
import json
|
||||||
|
import tempfile
|
||||||
|
import subprocess
|
||||||
|
import time
|
||||||
import tkinter as tk
|
import tkinter as tk
|
||||||
from tkinter import filedialog
|
from tkinter import filedialog
|
||||||
import configparser
|
import configparser
|
||||||
import Backend
|
|
||||||
import customtkinter
|
import customtkinter
|
||||||
from customtkinter import *
|
from customtkinter import *
|
||||||
|
|
||||||
@ -73,7 +78,7 @@ def main():
|
|||||||
def start_installation():
|
def start_installation():
|
||||||
prism_instance_path = prism_instance_path_entry.get()
|
prism_instance_path = prism_instance_path_entry.get()
|
||||||
app.destroy() # Close the GUI window
|
app.destroy() # Close the GUI window
|
||||||
Backend.perform_installation(instance_name, prism_command, prism_instance_path)
|
perform_installation(instance_name, prism_command, prism_instance_path)
|
||||||
|
|
||||||
# Button to start installation
|
# Button to start installation
|
||||||
install_button = CTkButton(master=app, text="Launch Minecraft", command=start_installation)
|
install_button = CTkButton(master=app, text="Launch Minecraft", command=start_installation)
|
||||||
@ -81,6 +86,50 @@ def main():
|
|||||||
|
|
||||||
app.mainloop()
|
app.mainloop()
|
||||||
|
|
||||||
|
def perform_installation(instance_name, prism_command, prism_instance_path):
|
||||||
|
ftp = FTP("gitea.piwalker.net")
|
||||||
|
ftp.login()
|
||||||
|
|
||||||
|
# Fetching versions.json from FTP
|
||||||
|
bio = io.BytesIO()
|
||||||
|
ftp.retrbinary("RETR versions.json", bio.write)
|
||||||
|
bio.seek(0)
|
||||||
|
versions = json.load(bio)
|
||||||
|
bio.close()
|
||||||
|
|
||||||
|
# Checking current version
|
||||||
|
version = "0.0.0"
|
||||||
|
version_file_path = os.path.join(prism_instance_path, instance_name, ".minecraft", "version.txt")
|
||||||
|
if os.path.exists(version_file_path):
|
||||||
|
with open(version_file_path, 'r') as fp:
|
||||||
|
version = fp.readline().rstrip()
|
||||||
|
|
||||||
|
# Checking if update is needed
|
||||||
|
if version != versions[-1]["Version"]:
|
||||||
|
print(f"Current version: {version}")
|
||||||
|
print(f"Latest version: {versions[-1]['Version']}")
|
||||||
|
|
||||||
|
# Downloading modpack
|
||||||
|
with tempfile.TemporaryDirectory() as temp_dir:
|
||||||
|
modpack_file_path = os.path.join(temp_dir, instance_name + ".mrpack")
|
||||||
|
with open(modpack_file_path, 'wb') as modpack:
|
||||||
|
ftp.retrbinary("RETR " + versions[-1]["File"], modpack.write)
|
||||||
|
|
||||||
|
# Running PrismLauncher with modpack
|
||||||
|
p = subprocess.Popen([prism_command, '-I', modpack_file_path])
|
||||||
|
|
||||||
|
# Waiting for installation to complete
|
||||||
|
while True:
|
||||||
|
time.sleep(5)
|
||||||
|
if os.path.exists(version_file_path):
|
||||||
|
with open(version_file_path, 'r') as fp:
|
||||||
|
version = fp.readline().rstrip()
|
||||||
|
if version == versions[-1]["Version"]:
|
||||||
|
break
|
||||||
|
|
||||||
|
# Launching PrismLauncher with the instance
|
||||||
|
subprocess.run([prism_command, '-l', instance_name])
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
||||||
|
36
Upload.py
36
Upload.py
@ -1,12 +1,28 @@
|
|||||||
import Backend
|
from ftplib import FTP_TLS as FTP
|
||||||
|
from getpass import getpass
|
||||||
|
import json
|
||||||
|
import io
|
||||||
|
import datetime
|
||||||
|
|
||||||
def main():
|
fileName = "modpack.mrpack"
|
||||||
fileName = "modpack.mrpack"
|
username = input("Username: ")
|
||||||
username = input("Username: ")
|
password = getpass()
|
||||||
password = getpass()
|
version_tag = input("Version Number: ")
|
||||||
version_tag = input("Version Number: ")
|
ftp = FTP("gitea.piwalker.net", username, password)
|
||||||
Backend.upload_pack(username, password, version_tag, fileName)
|
ftp.prot_p()
|
||||||
|
bio = io.BytesIO()
|
||||||
|
ftp.retrbinary("RETR versions.json", bio.write)
|
||||||
|
bio.seek(0)
|
||||||
|
versions = json.load(bio)
|
||||||
|
bio.close()
|
||||||
|
time = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
|
||||||
|
versions.append({"Version":version_tag, "Date":time, "File":"Versions/fcs7-"+time+".mrpack"})
|
||||||
|
with open(fileName, 'rb') as fp:
|
||||||
|
ftp.storbinary("STOR "+versions[len(versions)-1]["File"], fp)
|
||||||
|
bio = io.BytesIO()
|
||||||
|
bio.write(json.dumps(versions).encode())
|
||||||
|
bio.seek(0)
|
||||||
|
ftp.storbinary("STOR versions.json", bio)
|
||||||
|
bio.close()
|
||||||
|
|
||||||
|
ftp.close()
|
||||||
if __name__=="__main__":
|
|
||||||
main()
|
|
||||||
|
Loading…
Reference in New Issue
Block a user