0

I'm working on a python script that does a adb pull command from the device. If I pull large .apk files, is there a way to find out how long it takes to complete the pull?

A sample pull:

      ./adb pull /data/app/com.rovio.angrybirdsstarwars.ads.iap-1.apk

This took sometime to finish before which my next command started even after a sleep(4)

4

1 回答 1

2

打电话怎么样

file_name = "/data/app/com.rovio.angrybirdsstarwars.ads.iap-1.apk"
cmd = "adb shell ls -l %s"%file_name #stat doesnt work i dont think
file_size = subprocess.Popen(cmd,stdout=subprocess.PIPE).communicate()[0].split()[3]
usb2_xfer = 4603904.0 #4496 KB/s  (http://forum.xda-developers.com/showthread.php?t=882608)
print "EST TIME:%0.2f secs"%(file_size/usb2_xfer)

您可能需要调整 usb2_xfer ...还要确保您的设备在 USB 2.0 而不是 1.1 中运行(否则它会慢得多...请参阅我从中获得下载速度的链接)

这假设您通过 USB 连接到设备...如果您通过网络连接,则可以下载一个小 txt 文件以获取下载速度...。

如果您使用 os.system 调用该命令,它应该阻塞直到命令完成

print "Start Command!"
os.system("adb pull ...")
print "Command Finished!!"

如果你用 Popen 打电话

print "start command"
p = subprocess.Popen("adb pull ...",stdout = subprocess.PIPE,stderr=subprocess.PIPE)
stdout,stderr = p.communicate() # you could do p.wait() if you dont care about output
print "Command Finished!"
print stdout
print stderr
于 2013-09-17T23:50:31.327 回答