How Can I Get The Info In Cmd When I Set Adb_trace=adb
I tried to get the progress when pushing a file to device. It works when I 'set ADB_TRACE=adb' in cmd (found in this page) Then I want to use it in python 2.7. cmd = 'adb push file
Solution 1:
os.popen
is deprecated:
Deprecated since version 2.6: This function is obsolete. Use the
subprocess
module. Check especially the Replacing Older Functions with thesubprocess
Module section.
Use subprocess
instead:
import subprocess as sp
cmd = ["adb","push","file","/mnt/sdcard/file"]
mysp = sp.popen(cmd, env={'ADB_TRACE':'adb'}, stdout=sp.PIPE, stderr=sp.PIPE)
stdout,stderr = mysp.communicate()
if mysp.returncode != 0:
printstderrelse:
printstdout
Post a Comment for "How Can I Get The Info In Cmd When I Set Adb_trace=adb"