pure-python-adb
pure-python-adb copied to clipboard
How can I get shell() output in real time?
Not sure if you need something like this still but though I would share this with ye as I was looking for quite sometime on a 'how to' and managed to get a live log from the device.
device.shell("logcat", handler=dump_logcat)
def dump_logcat(connection):
while True:
data = connection.read(1024)
if not data:
break
print(data.decode('utf-8'))
connection.close()
Not sure if you need something like this still but though I would share this with ye as I was looking for quite sometime on a 'how to' and managed to get a live log from the device.
device.shell("logcat", handler=dump_logcat) def dump_logcat(connection): while True: data = connection.read(1024) if not data: break print(data.decode('utf-8')) connection.close()
I was facing issue while using your example, it seems that dump_logcat function should be declared before using it. below program worked for me.
def dump_logcat(connection):
while True:
data = connection.read(1024)
if not data:
break
print(data.decode('utf-8'))
connection.close()
device.shell("logcat", handler=dump_logcat)