发布:2023/10/24 23:04:05作者:管理员 来源:本站 浏览次数:663
######################python 代码实现
#!usr/bin/python
# -*- coding:utf-8 -*-
# Author:joy
# 把指定目录的apk安装到所有连接设备中
import os
import subprocess
import threading
import re
import time
apk_path = "D:\\yjapk\\jiagu_sign.apk"
def excute(cmd):
subprocess.Popen(cmd, shell=True)
def get_conn_dev():
connectdeviceid = []
p = os.popen('adb devices')
outstr = p.read()
print(outstr)
connectdeviceid = re.findall(r'(\w+)\s+device\s', outstr)
return connectdeviceid
def main():
connectdevice = get_conn_dev()
commands = []
for device in connectdevice:
cmd = "adb -s %s install -r %s" % (device,apk_path)
commands.append(cmd)
threads = []
threads_count = len(commands)
for i in range(threads_count):
t = threading.Thread(target = excute, args = (commands[i],))
threads.append(t)
for i in range(threads_count):
time.sleep(1) # 防止adb连接出错
threads[i].start()
for i in range(threads_count):
threads[i].join()
if __name__ == '__main__':
main()
#################通过shell脚本实现
@echo off
echo --------------------------------------------------------
echo start install 安装包的绝对路径
echo ------------
adb -s 设备编号 install -r 安装包的绝对路径
echo ------------
adb -s 设备编号 install -r 安装包的绝对路径
echo --------------------------------------------------------
pause
© Copyright 2014 - 2024 柏港建站平台 ejk5.com. 渝ICP备16000791号-4