Personal tools
You are here: Home Forum How to use Salome? Running a python script in batch mode with my own module

Running a python script in batch mode with my own module

Up to How to use Salome?

Running a python script in batch mode with my own module

Posted by Robin Tomcin at June 30. 2010

Hi!

I have to extend the functionality of the GEOM module and created an own module, based on the HELLO example module. Then I want to use this module (called it "GEOMHELPER") in my python scripts, running Salome in batch mode (without GUI).

With some effort, i finally managed to get it compiled and working with the "makeBanner" example method. Importing is done in the following way in my python script
"batch.py":

loadgeomhelperscript = os.getenv("GEOMHELPER_ROOT_DIR") + "/bin/salome/myrunSalome.py"
execfile(loadgeomhelperscript)
gh=test(clt)     # !!!!!
print gh.makeBanner("WOHOO!")

(just writing "import GEOMHELPER_ORB" doesn't produce errors, but "GEOMHELPER_ORB.makeBanner(...)" doesn't work somehow)

By executing the following command, Salome is started and automatically executes my python script:

runSalome --modules=GEOM,SMESH,GEOMHELPER -u "batch.py"

But like that the Salome GUI is still there. To completely get rid of the Salome GUI i just execute it with the parameter -t:

runSalome --modules=GEOM,SMESH,GEOMHELPER -t -u "batch.py"

This usually works with all modules and everything is just in my csh console, but not when I import my GEOMHELPER module in the above described way. This error appears in my csh console:

executing batch.py
Traceback (most recent call last):
  File "/scr/ceplx101/scr1/tomcin/Salome/KERNEL_5.1.3/bin/salome/runSalome.py", line 862, in ?
    clt,args = main()
  File "/scr/ceplx101/scr1/tomcin/Salome/KERNEL_5.1.3/bin/salome/runSalome.py", line 855, in main
    clt = useSalome(args, modules_list, modules_root_dir)
  File "/scr/ceplx101/scr1/tomcin/Salome/KERNEL_5.1.3/bin/salome/runSalome.py", line 693, in useSalome
    execfile(scrname,globals())
  File "batch.py", line 8, in ?
    execfile(loadgeomhelperscript)
  File "/scr/ceplx101/scr1/tomcin/Salome/GEOMHELPER_5.1.3/bin/salome/myrunSalome.py", line 41, in ?
    clt,args = main()
  File "/scr/ceplx101/scr1/tomcin/Salome/KERNEL_5.1.3/bin/salome/runSalome.py", line 855, in main
    clt = useSalome(args, modules_list, modules_root_dir)
  File "/scr/ceplx101/scr1/tomcin/Salome/KERNEL_5.1.3/bin/salome/runSalome.py", line 693, in useSalome
    execfile(scrname,globals())
  File "batch.py", line 9, in ?
    gh=test(clt)
NameError: name 'clt' is not defined

So the problem only occurs with the batch parameter "-t" AND the GEOMHELPER module. Otherwise it works fine.
I know this is kind of "deep" inside the complex Salome module system, but I hope someone has suggestions, probably another way to import my module? I have tried to compare GEOMHELPER to GEOM to find out why it works with GEOM and not with my module, but this is really hard! I am quite desperate...

Thanks in advance,
     Robin

Powered by Ploneboard
Document Actions