josegegas wrote: ↑Wed Sep 11, 2019 8:53 pm
... I mean, to take the messages MBDyn generates in the shell and show them somewhere in the FreeCAD gui. Any Idea?
With subprocess you capture the output of your command.
Code: Select all
out = subprocess.run(["ls", "-l", "/usr/share/freecad"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf8")
print(out.stdout)
It seems FEM uses
Popen().
https://github.com/berndhahnebach/FreeC ... ks.py#L105
This is the internal class, while the high level functions are
run() (for Python 3.5 and above), or the older
call(),
check_call(), and
check_output() (for Python 3.4 and below).
Code: Select all
process = subprocess.Popen(["ls", "-l", "/usr/share/freecad"], stdout=subprocess.PIPE, stderr=subprocess.PIPE, encoding="utf8")
out, err = process.communicate()
print(out)
print(err)
The standard output or standard error then can be printed in the terminal, the FreeCAD console, or used in some Qt dialogs.