-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstallapk.py
61 lines (52 loc) · 1.24 KB
/
installapk.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
# coding:utf8
# Author:daben_chen
"""
批量安装apk
"""
import os
import shutil
import sys
import subprocess
import mobileinfo
import time
def install_apk(device):
"""
:params:adb批量安装
:return:
"""
apklist = []
apkdir = "apk"
if len(sys.argv) == 1:
for f in os.listdir(apkdir):
extname = os.path.splitext(f)[1]
if extname == ".apk" :
apklist.append(f)
for apk in apklist:
print("install "+apk+" on "+device)
res = os.system("adb -s " + device + " install -r "+ apkdir + "/" + "\"" + apk + "\"")
res = res>>8
if res != 0:
print("Failed to install " + apk +"\n")
return False
else:
print("Success to install " + apk +"\n")
elif len(sys.argv) > 1:
argvlen = len(sys.argv)
for l in range(argvlen):
if l != 0 :
apk = sys.argv[l]
print("install "+apk+" on "+device)
res = os.system("adb -s " + device + " install -r "+ apkdir + "/" + "\"" + apk + "\"")
res = res>>8
if res != 0:
print("Failed to install " + apk +"\n")
return False
else:
print("Success to install " + apk +"\n")
def main():
mounted_devices = mobileinfo.find_devices()
if mounted_devices is not None:
for device in mounted_devices:
install_apk(device)
if __name__ == '__main__':
main()