android - Python can not capture full adb logs -
what want achieve - running adb log (logs running), doing activity on android, stop/end log capture (ctrl+c), post processing of logs.
only issue face - can not capture full logcat log in file
import sys import subprocess import time import ctypes # start print "test start" time.sleep(5) # log capturing start, log not stop keep on running proc = subprocess.popen("adb logcat -v time",stdout=subprocess.pipe ) time.sleep(3) # runs while print "calc start" time.sleep(5) #start test************************************ code testing #ctrl c************************************************* try: ctypes.windll.kernel32.generateconsolectrlevent(0, 0) proc.wait() except keyboardinterrupt: print "ignoring ctrlc" print "still running" #********************adb log saving****************** text = proc.stdout.read() f = open('c:\python27\out_logs_dd\log.txt', 'w') f.write(text) open('c:\python27\out_logs_dd\log.txt', 'w') f: f.write(text) f.close()
when run code, running log size small. searched , came know "proc.communicate()"
might solution. tried 'communicate'
not solve issue. pointer pls.
replacing proc.stdout.read()
proc.stdout.readline()
solved me. stdout.read() reads until eof - slowing down speed drastically. similar question: communicate subprocess without waiting subprocess terminate on windows
Comments
Post a Comment