python,adb,分别给多个设备安装多个apk文件,os.popen(); os.system; os.path.splitext(); a.split(' \t'); readlines(); append(); os.path.join(); time.sleep();
#encoding:utf-8
import os,time
#=======================查找手机设备序列号=============
a='adb devices'
b=os.popen(a).readlines()
#print(b)
l=[]
for sn in b:
if 'device' in sn and 'List' not in sn:
a=sn.split('\t')[0]
l.append(a)
print(l) #手机序列号列表
#==========================查找给定路径下,.apk文件========
def filep(fp):
apkl=[]
namel=os.listdir(fp)
for i in namel:
if os.path.splitext(i)[1]=='.apk':
apkl.append(i)
return apkl
#print(filep("E:\study\\apk"))
path="E:\study\\apk"
print(filep(path)) #.apk列表
#====================单个手机,循环安装apk==========
for onesn in l:
for apk in filep(path):
onepath=os.path.join(path,apk)
print(onepath)
a='adb -s {} install -r {}'.format(onesn,onepath)
print(a)
bb=os.popen(a).readlines()
time.sleep(3)
#print(bb)
if 'Success\n' in bb:
print('{} 手机的的{}已经安装完毕'.format(onesn,apk))
else:
print('==========={}手机的{}安装失败=========='.format(onesn,apk))
# time.sleep(2)
# os.system('adb shell input keyevent 4') #返回键
print('{}手机的所有apk已尝试安装'.format(onesn))
python,adb,分别给多个设备安装多个apk文件,os.popen(); os.system; os.path.splitext(); a.split(' \t'); readlines(); append(); os.path.join(); time.sleep();的更多相关文章
- 【转】adb uninstall卸载apk文件说明
昨天在使用adb卸载程序,结果死活卸载不了.我输入的命令和系统提示如下: [plain] view plaincopy arthur@arthur-laptop:~$ adb uninstall ...
- Python第十一天 异常处理 glob模块和shlex模块 打开外部程序和subprocess模块 subprocess类 Pipe管道 operator模块 sorted函数 os模块 hashlib模块 platform模块 csv模块
Python第十一天 异常处理 glob模块和shlex模块 打开外部程序和subprocess模块 subprocess类 Pipe管道 operator模块 sorted函 ...
- python+adb实现自动化获取手机信息
首先我们先看一下使用adb查看Android手机信息的指令 #获取手机名称NAME = 'adb shell getprop ro.product.model'#获取手机版本VERSION = 'ad ...
- python笔记16-执行cmd指令(os.system和os.popen)
os.system 1.如果想在cmd执行python脚本,可以直接用如下指令 python [xx.py绝对路径] 比如我写了个hello.py的脚本,在脚本里面写入内容:print("h ...
- Python执行系统命令的方法 os.system(),os.popen(),commands
os.popen():用python执行shell的命令,并且返回了结果,括号中是写shell命令 Python执行系统命令的方法: https://my.oschina.net/renwofei42 ...
- python调用系统命令popen、system
python调用Shell脚本,有两种方法:os.system(cmd)或os.popen(cmd),前者返回值是脚本的退出状态码,后者的返回值是脚本执行过程中的输出内容.所以说一般我们认为popen ...
- Python os.system 和 os.popen的区别
(1) os.system # 仅仅在一个子终端运行系统命令,而不能获取命令执行后的返回信息 system(command) -> exit_statusExecute the command ...
- APK文件安装模拟器和ADB命令的使用
1.安装APK文件到模拟器 Android手机使用的执行文件为APK格式,类似于Windows平台的exe文件.在Android模拟器中安装APK文件有多种方法,如果你是开发人员,可以通过Eclips ...
- Python自动化运维之4、格式化输出、文件对象
Python格式化输出: Python的字符串格式化有两种方式: 百分号方式.format方式 百分号的方式相对来说比较老,而format方式则是比较先进的方式,企图替换古老的方式,目前两者并存.[P ...
随机推荐
- 读书笔记_python网络编程3(6)
6.TLS/SSL 6.0. 传输层安全协议(TLS, Transport Layer Security)是如今web上应用最广泛的加密方法了,1999年成为互联网标准.前身是安全套接层(SSL, S ...
- 微信小程序API交互反馈,wx.showToast显示消息提示框
导读:wx.showToast(OBJECT) 显示消息提示框. OBJECT参数说明: 参数 类型 必填 说明 最低版本 title String 是 提示的内容 icon String 否 图标, ...
- nginx配合gotty的websocket连接配置
由于gotty我作了url加密, 所以url在nginx里的前缀要能替换才行. 配置关键就在于有没有/ #user nobody; worker_processes 1; #error_log log ...
- CF1244C The Football Season
题目链接 problem 给定\(n,p,w,d\),求解任意一对\((x,y)\)满足\[xw+yd=p\\ x + y \le n\] \(1\le n\le 10^{12},0\le p\le ...
- Codeforces Round #603 (Div. 2) F. Economic Difficulties dp
F. Economic Difficulties An electrical grid in Berland palaces consists of 2 grids: main and reserve ...
- golang--redis基本介绍
redis(remote-dictionary-system)即远程字典服务器,是NoSQL数据库: 适合做缓存以及持久化: 免费开源,高性能的分布式内存数据库: redis的安装和使用: 下载Red ...
- html公用头部和尾部
这个方式比较简单,样式和js也有效果,还有object和iframe方式 效果图,可以看出公共的样式对于引入的文件也有效果,在加载完文件后js也是有效果的 index.html header.html ...
- What is Java virtual machine?
Java Virtual Machine (JVM) is a specification that provides runtime environment in which java bytec ...
- 解决:perl: warning: Please check that your locale settings
问题: perl: warning: Setting locale failed. perl: warning: Please check that your locale settings: LAN ...
- Django之Django快速体验
Django快速体验 前语: 这一节内容是直接快速上手,后面的内容是对内容进行按步解释,如果不想看解析的,可以直接只看这一节的内容. 1.新建项目应用新建项目test1新建应用booktest 2.注 ...