python 控制adb

xiaoxiao2021-02-28  84

import os os.system(“adb -s ‘192.168.0.113’ shell ps | grep org.yeshen.test | awk ‘{print$2}’ | wc -l”)

检查在线的设备

adb devices import subprocess # 检查在线的设备 online = set() cmd = "adb devices | grep '\tdevice' | cut -d ':' -f1" pipe = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) while True: out = pipe.stdout.readline() if not out and pipe.returncode is not None: break online.add(out.strip()) pipe.poll() pipe.stdout.close() print online

python控制 adb 管道

import subprocess ip=192.168.0.110 package="org.yeshen.test" cmd = "adb -s %s:5555 shell ps | grep %s | wc -l" % (ip, package) pipe = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE) app_count = pipe.stdout.readline().strip() pipe.stdout.close() print "%s >count> %s" % (package,app_count)
转载请注明原文地址: https://www.6miu.com/read-51190.html

最新回复(0)