first of all, I know there are many ways to capture the output of a shell... I have found this and works fine:
from subprocess import Popen, PIPE
with Popen(["ping", "localhost"], stdout=PIPE, bufsize=1, universal_newlines=True) as p:
for line in p.stdout:
if "bytes" in line:
print(line, end='')
But I need to get debugging info from de cmd, and this doesn't work... I am trying to get the output from geth that throws some info like:
mypc@thispc:~$ geth --light
INFO [07-02|21:56:08] Starting peer-to-peer node
INFO [07-02|21:56:08] Allocated cache and file handles
INFO [07-02|21:56:08] Initialised chain configuration
INFO [07-02|21:56:08] Disk storage enabled for ethash caches
INFO [07-02|21:56:08] Disk storage enabled for ethash DAGs
INFO [07-02|21:56:08] Added trusted CHT for mainnet
INFO [07-02|21:56:08] Loaded most recent local header
This is debugging info so, I don't know why, but i cannot capture normally to work with it. I need something like:
with Popen(["geth", "--light"], stdout=PIPE, bufsize=1, universal_newlines=True) as p:
for line in p.stdout:
if "Loaded" in line:
print("NICE!!")
Is there any way to do It?