-
Notifications
You must be signed in to change notification settings - Fork 1
/
IPA Installer.py
72 lines (61 loc) · 1.9 KB
/
IPA Installer.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
# Modified from install ipa.py by @mersaor
# https://t.me/axel_burks
import os, appex, console, shutil, http.server, webbrowser, time
from os import path
from threading import Thread
port_number = 8080
plist_url = "itms-services://?action=download-manifest&url=https://gitee.com/suisr/PlistServer/raw/master/universal.plist"
save_dir = path.expanduser('~/Documents')
os.chdir(save_dir)
httpd = None
def startServer(port):
Handler = http.server.SimpleHTTPRequestHandler
global httpd
httpd = http.server.HTTPServer(("", port), Handler)
print("Start server at port", port)
httpd.serve_forever()
def start(port):
thread = Thread(target=startServer, args=[port])
thread.start()
startTime = int(time.time())
while not httpd:
if int(time.time()) > startTime + 60:
print("Time out")
break
return httpd
def stop():
if httpd:
httpd.shutdown()
def main():
if appex.is_running_extension():
get_path = appex.get_file_path()
file_name = path.basename(get_path)
file_ext = path.splitext(file_name)[-1]
if file_ext == '.ipa':
dstpath = path.join(save_dir, 'app.ipa')
try:
shutil.copy(get_path, dstpath)
except Exception as eer:
print(eer)
console.hud_alert('导入失败!','error',1)
start(port_number)
if httpd:
webbrowser.open(plist_url)
try:
finish = console.alert(file_name, '\n正在安装…请返回桌面查看进度…\n\n安装完成后请返回点击已完成','已完成', hide_cancel_button=False)
if finish == 1:
os.remove(dstpath)
stop()
print("Server stopped")
except:
print("Cancelled")
os.remove(dstpath)
stop()
appex.finish()
else:
console.hud_alert('非 ipa 文件无法导入安装', 'error', 2)
appex.finish()
else:
console.hud_alert('请在分享扩展中打开本脚本','error',2)
if __name__ == '__main__':
main()