using python subprocess to execute ros commands with verbosity
The following is an example for starting a roscore, however, I haven't been able to execute them with verbosity similar to how their output is printed while executing them in terminal. Basically, the following code gets stuck at proc3.communicate() which is necessary to print the stdout.
import subprocess
proc1 = subprocess.Popen(['killall', 'roscore'])
proc2 = subprocess.Popen(['killall', 'rosmaster'])
proc3 = subprocess.Popen(['roscore'], stdout=subprocess.PIPE,
stderr=subprocess.PIPE)
lines, err = proc3.communicate()
print(lines.decode("utf-8"))
Is there a way to do this with verbosity while having the content printed like in terminal? I have also tried other solitions on internet regarding when proc.communicate() remains stuck.