Python Python实现批量安装android apk包

标签:
python安装apk软件包批量安装android软件adb安装软件包 |
分类: 自动化测试 |
基于Python实现批量安装android apk包
by:授客 QQ:1033553122
1.相关软件包及文件下载
2.测试环境
Win7 64位
Python 3.3.2
3.用法及代码show
用法:
把.apk包放入apk目录下,然后进入到install_apk_once_many.py所在目录,运行程序:
python install_apk_once_many.py
运行结果:
代码展示
#!/usr/bin/env python
#
-*- coding:utf-8 -*-
__author__
=
'shouke'
import
subprocess
import
os
workdir
= os.getcwd()
apk_path
= os.path.join(workdir,
'apk')
adb_apth
= os.path.join(workdir,
'adb.exe')
p
= subprocess.Popen(adb_apth +
' root',
stdout=subprocess.PIPE,
stderr=subprocess.PIPE,
shell=True,
universal_newlines=True)
try:
except
Exception
as
e:
filename_list
= os.listdir(apk_path)
fail_cnt
=
0
pass_cnt
=
0
fail_list
= []
# 存放安装失败的包文件名
for
filename
in
filename_list:
print('安装成功总数:',
pass_cnt)
print('安装失败总数:',
fail_cnt)
print
('安装失败的文件有:',
fail_list)
注:
adb root