AO2XP/install_update.py

31 lines
974 B
Python
Raw Normal View History

2021-06-21 22:57:55 -04:00
import zipfile, tarfile, platform, os, time, shutil
ext = {
"Windows": "zip",
"Darwin": "zip",
"Linux": "gz"
}
def extractzip(): # Mac
archive = zipfile.ZipFile("update.zip")
if platform.system() == "Darwin": shutil.rmtree("AO2XP.app", ignore_errors=True) # delete the old app package.
archive.extractall() # extract the new version
def extractgz(): # Linux
archive = tarfile.open("update.tar.gz")
archive.extractall()
if os.path.exists("update." + ext[platform.system()]):
print "Waiting 3 seconds for AO2XP to close..."
time.sleep(3)
print "Extracting update." + ext[platform.system()] + "..."
globals()["extract" + ext[platform.system()]]() # call the extract function according to OS
print "Done!"
os.remove("update." + ext[platform.system()])
else:
print "This program will be automatically run by AO2XP to apply updates.\nYou do not need to run this yourself."
raw_input("Press enter to exit.\n")