首页 > 数据库技术 > 详细

PYTHON 得到ADB的输出结果

时间:2020-12-04 08:58:34      阅读:101      评论:0      收藏:0      [点我收藏+]
import subprocess

ADB_PATH="adb"

def adbdevices(adbpath=ADB_PATH):
    return set([device.split(\t)[0] for device in subprocess.check_output([adbpath, devices]).splitlines() if str(device).endswith(\tdevice)])


def adbdevicesa(adbpath=ADB_PATH):
    for device in subprocess.check_output([adbpath, devices]).splitlines():
        #print(device)
        #print(type(device))
        #print(device.decode(‘utf-8‘))
        if "device" in device.decode(utf-8) and "List" not in device.decode(utf-8) :
            print(device.decode(utf-8))
    
    #if str(device).endswith(‘\tdevice‘)])


def adbshell(command, serial=None, adbpath=ADB_PATH):
    args = [adbpath]
    if serial is not None:
        args.extend([-s, serial])
    args.extend([shell, command])
    return subprocess.check_output(args)

def pmpath(pname, serial=None, adbpath=ADB_PATH):
    return adbshell(pm path {}.format(pname), serial=serial, adbpath=adbpath)
adbdevicesa()

 

PYTHON 得到ADB的输出结果

原文:https://www.cnblogs.com/xkdn/p/14083842.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!