Skip to content

Commit

Permalink
Auto update (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
gi-b716 committed Nov 14, 2024
1 parent 4dbbfea commit eaa3cc8
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions _update.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import requests
import zipfile
import sys
import os

mirror = "https://autoHack.netlify.app/"

lasted = requests.get("{0}/LASTED".format(mirror))

if os.path.exists("dataGenerator.py"):
import dataGenerator
metaObject = dataGenerator.Meta()
if lasted == metaObject._version:
print("autoHack is up to date.")
sys.exit(0)
if metaObject._version == "":
print("Disabled update.")
sys.exit(0)

res = input("Check new version: {0}\nUpdate? (y/[n]): ".format(lasted))
if res != 'y':
sys.exit(0)

path = os.path.dirname(os.path.abspath(__file__))
files = os.listdir(".")

for file in files:
os.remove(file)

lstFile = requests.get("{0}/meta/{1}.zip".format(mirror,lasted))
with open("{0}.zip".format(lasted), "w") as zf:
zf.write(str(lstFile.content))

with zipfile.ZipFile("{0}.zip".format(lasted), "r") as z:
z.extractall("{0}\\".format(path))

os.remove("{0}.zip".format(lasted))

if os.path.exists(".\\requirements"):
os.chdir("requirements")
os.system("pip install -r requirements.txt")
os.chdir("..")
os.removedirs("requirements")

0 comments on commit eaa3cc8

Please sign in to comment.