python-操作adb多线程批量安装,卸载app

  • 多线程
import threading
import  time
class base_thread(threading.Thread):
    def __init__(self, func):
        threading.Thread.__init__(self)
        self.func = func
        #print(type(self.func))
    def run(self):
        self.func
  • 操作adb
# -*- coding: utf-8 -*-

import os
import time
import sys
import glob
from Base.Threads import base_thread

#单文件安装
def install(filename):
    print(filename)
    os.popen("adb install %s" % filename)

#批量安装app,多线程安装
def bact_install(dir):
    if os.path.isdir(dir):
        starttime = time.time()
        filelist= glob.glob(dir + "*.apk")
        threads = []
        for i in range(0, len(filelist)):
            threads.append(base_thread(install(filelist[i])))
        for j in range(0, len(filelist)):
            threads[j].start()
        for k in range(0, len(filelist)):
            threads[k].join()
        print("总运行时间"+str(time.time() - starttime))
    else:
        print("目录不存在")
        sys.exit(0)

#卸载app
def uninstall(packageName):
    os.popen("adb wait-for-device")
    print("start uninstall...")
    os.popen("adb uninstall %s" % packageName)



最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容