forked from gb112211/AndroidTestScripts
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbatch_install.py
More file actions
56 lines (45 loc) · 1.2 KB
/
batch_install.py
File metadata and controls
56 lines (45 loc) · 1.2 KB
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
# -*- coding: utf-8 -*-
'''
Created on 2015年1月26日
@author: xuxu
'''
import os
import time
import sys
#需要在脚本所在目录AndroidAdb目录下有个AndroidAdb.exe程序,该adb可以支持安装以中文命名的apk
#需要将apk文件放在脚本所在目录下的Apps目录下
#检查AndroidAdb.exe
def check_adb():
if os.path.isfile("%s\\AndroidAdb\\AndroidAdb.exe" %os.getcwd()):
return True
else:
return False
#检查Apps目录
def check_dir():
if os.path.isdir("%s\\Apps" %os.getcwd()):
return True
else:
return False
#安装应用
def install():
count = 0
apps_dir = "%s\\Apps" %os.getcwd()
for path, subdir, files in os.walk(apps_dir):
for apk in files:
os.popen("%s\\AndroidAdb\\AndroidAdb.exe install %s" %(os.getcwd(), os.path.join(path, apk)))
count += 1
print "\n%s apps install complete." %str(count)
if __name__ == "__main__":
if check_adb():
pass
else:
print "AndroidAdb.exe not exist."
time.sleep(3)
sys.exit(0)
if check_dir():
pass
else:
print "Apps Directory not exist"
time.sleep(3)
sys.exit(0)
install()