CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ParaView (https://www.cfd-online.com/Forums/paraview/)
-   -   [General] Close Paraview after python script execution (https://www.cfd-online.com/Forums/paraview/124536-close-paraview-after-python-script-execution.html)

taalf October 7, 2013 11:51

Close Paraview after python script execution
 
Hi all,

I would like to launch Paraview from a bash command so as to execute a script and then exit automatically at the end of the script.

To launch Paraview and execute the script, I use:

Code:

paraview --script=script_name.py
But after the script execution, Paraview stays open...

Does anybody know how to make it close?

Thank you very much for help!

Best regards,

William

wyldckat October 11, 2013 18:20

Greetings William,

Why not use pvpython or pvbatch?

Beyond this, you can try the instructions given here: http://stackoverflow.com/questions/9...python-program

Best regards,
Bruno

taalf October 14, 2013 08:19

Quote:

Originally Posted by wyldckat (Post 456450)
Why not use pvpython or pvbatch?

Why not ?

Indeed, why not ! :D

Exactly what I was looking for :D

Many many many thanks :D

Best regards,

William

louisgag October 7, 2015 10:23

In case someone is reading on and, like me,

1) doesn't have the python-qt4 libraries compatible with his paraview binaries installed, and
2) obtains the desired rendering only using paraview --script and not by using pvpython or pvbatch, for some mysterious reason,

a solution may also be to execute something like this within the python script:

Code:

import subprocess
subprocess.call("kill $(ps aux|grep -e 'paraview --script=./YOUR_SCRIPT_NAME.py'|grep -v grep|awk {'print $2'})", shell=True)


singul4r1ty August 29, 2019 21:29

Sorry to respond even later but this is what came up when I was searching this and I found an even simpler way!

Just import sys and then run sys.exit(0). This closes paraview for me, and the 0 is an OK exit code.


All times are GMT -4. The time now is 08:22.