Hello,
What is a simple and reliable way to handle an error when calling and monitoring a CLI application through subprocess.Popen()?
Is this good enough?
What is a simple and reliable way to handle an error when calling and monitoring a CLI application through subprocess.Popen()?
Is this good enough?
p = subprocess.Popen("blah", text=True, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
if p.stderr:
self.statusbar.SetStatusText("Popen error.")
exit()
else
while (line := p.stdout.readline()) != "":
self.statusbar.SetStatusText(line.strip())
output = f"End of output. Return code: {p.wait()}"
self.statusbar.SetStatusText(output)Thank you.
