def update(self):
print "[*] Trying to update the client..."
try:
with open("client.zip", "rb") as f:
cli = f.read()
hsh = hashlib.md5(cli).hexdigest()
except IOError:
hsh = "INVALID"
path = Rest.get_update(hsh)
if path is not None:
shutil.rmtree('engine')
shutil.rmtree('client')
os.remove('client.py')
os.remove('requirements.txt')
f = zipfile.ZipFile(path, "r")
f.extractall('tmp')
f.close()
root = 'tmp' + os.sep + 'client' + os.sep
shutil.move(root + 'client', '.')
shutil.move(root + 'engine', '.')
shutil.move(root + 'client.py', '.')
shutil.move(root + 'requirements.txt', '.')
shutil.rmtree('tmp')
args = sys.argv[:]
print "[*] Update installed successfully, restarting...\n"
args.insert(0, sys.executable)
if sys.platform == 'win32':
args = ['"%s"' % arg for arg in args]
os.execv(sys.executable, args)
sys.exit(1)
else:
print "[!] Client is already the latest version."
评论列表
文章目录