added activity check

This commit is contained in:
Samuel Walker 2024-06-19 21:36:55 -06:00
parent ae392a7f64
commit f818ae6c4a

19
Main.py
View File

@ -7,6 +7,7 @@ import io
import json
import tempfile
import subprocess
import time
def main():
instance_name = "Familycraft Season 7"
@ -23,17 +24,27 @@ def main():
versions = json.load(bio)
bio.close()
version = "0.0.0"
if os.path.exists(prism_instance_path+"/"+instance_name+"/version.txt"):
with open(prism_instance_path+"/"+instance_name+"/version.txt", 'r') as fp:
version = fp.readline()
if os.path.exists(prism_instance_path+"/"+instance_name+"/.minecraft/version.txt"):
with open(prism_instance_path+"/"+instance_name+"/.minecraft/version.txt", 'r') as fp:
version = fp.readline().rstrip()
if version != versions[len(versions)-1]["Version"]:
#version = versions[len(versions)-1]["Version"]
# Update Modpack
print(version)
print(versions[len(versions)-1]["Version"])
with tempfile.TemporaryDirectory() as temp_dir:
modpack = open(os.path.join(temp_dir, instance_name+".mrpack"), 'wb')
ftp.retrbinary("RETR "+versions[len(versions)-1]["File"], modpack.write)
modpack.close()
subprocess.run([prism_command, '-I', modpack.name])
p = subprocess.Popen([prism_command, '-I', modpack.name])
while True:
time.sleep(5)
if os.path.exists(prism_instance_path+"/"+instance_name+"/.minecraft/version.txt"):
with open(prism_instance_path+"/"+instance_name+"/.minecraft/version.txt", 'r') as fp:
version = fp.readline().rstrip()
if version == versions[len(versions)-1]["Version"]:
break;
#with open(prism_instance_path+"/"+instance_name+"/version.txt", 'w') as fp:
# fp.seek(0)
# fp.truncate()