While developing python wrapper library for Android Debug Bridge (ADB), I'm using subprocess to execute adb commands in shell. Here is the simplified example:
import subprocess
...
def exec_adb_command(adb_command):
return = subprocess.call(adb_command)
If command executed propery exec_adb_command returns 0 which is OK.
But some adb commands return not only "0" or "1" but also generate some output which I want to catch also. adb devices for example:
D:\git\adb-lib\test>adb devices
List of devices attached
07eeb4bb device
I've already tried subprocess.check_output() for that purpose, and it does return output but not the return code ("0" or "1").
Ideally I would want to get a tuple where t[0] is return code and t[1] is actual output.
Am I missing something in subprocess module which already allows to get such kind of results?
Thanks!