class AdbUtil:
@classmethod
def getDevicesListV2(cls):
inputCmd = "adb devices"
p = subprocess.Popen(inputCmd, shell=False, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
lists = p.stdout.readlines()
devicesList = []
for item in lists:
print(type(item))
itemStr = str(item, encoding="utf-8")
if (itemStr.strip() == ""):
continue
elif (itemStr.startswith("List of")):
continue
elif (itemStr.find("daemon") > -1):
continue
else:
infos = itemStr.split("\t")
devicesList.append({
"deviceId": infos[0],
"type": infos[1].replace('\r\n','')
})
return devicesList
@classmethod
def getDevicesList(cls):
p = os.popen('adb devices')
devicesList = p.read()
p.close()
lists = devicesList.split("\n")
devicesList = []
for item in lists:
if (item.strip() == ""):
continue
elif (item.startswith("List of")):
continue
elif (item.find("daemon") > -1):
continue
else:
infos = item.split("\t")
devicesList.append({
"deviceId": infos[0],
"type": infos[1]
})
return devicesList