Ashok Kumar
Ashok Kumar

Reputation: 43

Save result of command "adb devices" in a variable

I am working on Automation part.I am running adb command via os.system("adb devices") in python.

I want to save output of command "adb devices" in variable because I want to compare device id which ever I am getting from adb devices and fastboot devices.

Upvotes: 0

Views: 1960

Answers (2)

Diego Torres Milano
Diego Torres Milano

Reputation: 69328

You can also use AdbClient from AndroidViewClient/culebra

#! /usr/bin/env python
# -*- coding: utf-8 -*-

from com.dtmilano.android.adb.adbclient import AdbClient

for device in AdbClient().getDevices():
    print device

to list all devices and its properties, like serialno.

Upvotes: 2

Waman
Waman

Reputation: 1179

process = subprocess.Popen(cmd, shell=True,stdout=subprocess.PIPE)
for line in iter(process.stdout.readline, ''):
    print line

Compare line with your value

Upvotes: 0

Related Questions