I am writing a PyQt4 based launcher. When clicking a button in the launcher start_tool is called. this function opens an new terminal, executing anoother tool. hence two new windows are openend, the terminal and the newly started tool. I now want to pipe the output of the new terminal into a textedit of the launcher in order to track the errors WITHIN the launcher. I need to be able to operate both the launcher and the started tool at the same time.
I have tried following code, it pipes some output but then an "FATAL IO error: client killed" is thrown and the launcher is killed.
def f(self, lock, tools):
try:
lock.acquire()
ex = sub.Popen(tools, shell=True,stdout=sub.PIPE,stderr=sub.STDOUT)
p = os.getpid()
while True:
output = ex.stdout.readline().decode()
if output == '' and ex.poll() is not None:
break
if output:
self.console_launcher.insertPlainText(output)
QtGui.QApplication.processEvents()
lock.release()
except sub.CalledProcessError as e:
lock.acquire()
print(e)
lock.release()
finally:
lock.release()
def start_tool(self):
lock = mp.Lock()
tools = ['gnome-terminal --tab -- shells/program.sh']
p = mp.Process(target=self.f, args=(lock, tools))
p.start()
p.join()
I want to pipe the output of Tool B into the Gui of tool A. Both are PyQt4 based apps and need to run separetly.