0

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.

Ashok Kumar
  • 43
  • 1
  • 6
  • Possible duplicate of [Python: How to get stdout after running os.system?](http://stackoverflow.com/questions/18739239/python-how-to-get-stdout-after-running-os-system) – Alex P. Nov 25 '16 at 15:09

2 Answers2

2

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.

Diego Torres Milano
  • 65,697
  • 9
  • 111
  • 134
0
process = subprocess.Popen(cmd, shell=True,stdout=subprocess.PIPE)
for line in iter(process.stdout.readline, ''):
    print line

Compare line with your value

Waman
  • 1,179
  • 7
  • 16