本文介绍了当我设置ADB_TRACE = adb时,如何获取cmd中的信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试获取将文件推送到设备时的进度。
当我在cmd中设置ADB_TRACE = adb时可用(在)



然后我想在python 2.7中使用它。

  cmd =adb push file / mnt / sdcard / file
os.putenv('ADB_TRACE','adb')
os.popen(cmd)
.read()


如何获取这些详细信息?



操作系统:win7

解决方案>

已弃用:

使用代替:

  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()

如果mysp.returncode!= 0:
print stderr
else:
print stdout


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 /mnt/sdcard/file"
os.putenv('ADB_TRACE', 'adb')
os.popen(cmd)
print cmd.read()

It shows nothing.How can I get these details?

OS:win7

解决方案

os.popen is deprecated:

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:
    print stderr
else:
    print stdout

这篇关于当我设置ADB_TRACE = adb时,如何获取cmd中的信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 09:56