Personal tools
You are here: Home Forum How to use Salome? How to make a Salome script stop using TUI?

How to make a Salome script stop using TUI?

Up to How to use Salome?

How to make a Salome script stop using TUI?

Posted by Arnau Bayon at May 15. 2013

I'm running a Salome script as a subprocess of a Linux script. Is there any automatic way (not pressing "Ctrl+D") to make the Salome script stop when it's done so that the Linux script can go on? I've tried adding after the last line "exit()", "sys.exit()", "quit()", etc.) but I don't get the desired result, only a Python terminal that I have to close manually.

 

Thanks a lot!

 

Arnau.

Re: How to make a Salome script stop using TUI?

Posted by Vadim SANDLER at May 15. 2013

Hello Arnau,

You can add the following code to the end of your SALOME Python script:

import killSalome
killSalome.killAllPorts()

Regards,
Vadim.

Re: How to make a Salome script stop using TUI?

Posted by Arnau Bayon at May 16. 2013

Thank you for you quick reply, Vadim. Unfortunately, I had already tried that and it didn't work, I don't know why. Please find attached the script that is causing the problem. Any hint about it is welcome. Thanks a lot again!

Regards,

 

Arnau.

Attachments

Re: How to make a Salome script stop using TUI?

Posted by Vadim SANDLER at May 16. 2013

Hello Arnau,

Unfortunately, I cannot fix your script as it uses missing variables.py module.

However, I checked with arbitrary SALOME script with mentioend two lines added to the end of script. This well works if SALOME is launched in batch mode (with -t option):

runSalome -t <script>

Unfortunately, this does not work if SALOME is launched in GUI mode:

runSalome <script>

  or

runSalome -g <script>

This is because in latter case Python script is executed in the GUI process,and killSalome script in first turn shutdowns Session Server (GUI) that kills the script execution and prevents other SALOME processes to shutdown.

Regards,
Vadim.

Re: How to make a Salome script stop using TUI?

Posted by Arnau Bayon at May 16. 2013

Hello Vadim,

 

I'm sorry, I forgot to attach "variables.py" and the pointcloud source file to my post. This new version of my script has the variables definition implemented (although you will have to adapt the original file routes to your own case).

 

As regards the Salome launching mode that you mentioned, I have always done it in TUI mode, that is in the Salome installation directory:

 

./runSalome -t createmesh.py

 

 

And also:

 

./runSalome -t -u createmesh.py

 

 

But I get the same result in both cases: a Python console after the script is (correctly) executed by Salome. It occurs to me that maybe all this has to do with the Salome version I am using (Salome 6.3.0 in SalomeMeca version preinstalled in CAELinux 2011). Any idea?

 

Once again, thanks a lot for your help!

 

Regards,

 

Arnau.

Attachments

Re: How to make a Salome script stop using TUI?

Posted by Vadim SANDLER at May 16. 2013

Hello Arnau,

Well, I have checked your script with "pure" SALOME v6.3.1 and v6.6.0 (no SalomeMeca) - in both cases all works OK and finishes execution killing all SALOME processes.

So, I guess that it might be a problem with some environment variable that results in such behavior, but I'm not sure.

Regards,
Vadim.

Re: How to make a Salome script stop using TUI?

Posted by Arnau Bayon at June 19. 2013

Hello Vadim,

I have not had the time to try it, but I have been suggested to use this solution to my problem. I post it just in case other users had experienced the same problem (I would really appreciate that they reported their results if they tried this solution).

Kind regards,

 

Arnau.

 

Re: How to make a Salome script stop using TUI?

Posted by Fynn at March 14. 2017

Hi,

I was wondering if it is now possible to kill Salome through a script which is launched in GUI mode.

Since this post is nearly 4 years old, I have hope this feature was added to Salome.

cheers,

Fynn

 

Previously Vadim SANDLER wrote:

Hello Arnau,

Unfortunately, I cannot fix your script as it uses missing variables.py module.

However, I checked with arbitrary SALOME script with mentioend two lines added to the end of script. This well works if SALOME is launched in batch mode (with -t option):

runSalome -t <script>

Unfortunately, this does not work if SALOME is launched in GUI mode:

runSalome <script>

  or

runSalome -g <script>

This is because in latter case Python script is executed in the GUI process,and killSalome script in first turn shutdowns Session Server (GUI) that kills the script execution and prevents other SALOME processes to shutdown.

Regards,
Vadim.

 

Powered by Ploneboard
Document Actions