3 from string import Template
5 from compat import Template,set
7 astercompoMakefile="""include $$(top_srcdir)/adm_local/make_common_starter.am
8 salomepython_PYTHON = ${component}.py
11 astercompoMakefile=Template(astercompoMakefile)
12 astercexeMakefile=astercompoMakefile
14 asterexeMakefile="""include $$(top_srcdir)/adm_local/make_common_starter.am
15 salomepython_PYTHON = ${component}_module.py
16 # These files are executable scripts
17 dist_salomescript_SCRIPTS= ${component}.exe
19 asterexeMakefile=Template(asterexeMakefile)
22 import sys,traceback,os
30 sys.path=sys.path+[${python_path}]
34 from Execution.E_SUPERV import SUPERV
36 aster_dir="${aster_dir}"
47 class ${component}(${module}__POA.${component},dsccalcium.PyDSCComponent,SUPERV):
49 To be identified as a SALOME component this Python class
50 must have the same name as the component, inherit omniorb
51 class ${module}__POA.${component} and DSC class dsccalcium.PyDSCComponent
52 that implements DSC API.
54 def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ):
55 print "${component}.__init__: ", containerName, ';', instanceName,interfaceName
56 dsccalcium.PyDSCComponent.__init__(self, orb, poa,contID,containerName,instanceName,interfaceName)
59 if hasattr(self,"init_timer"):
61 #fin modif pour aster 9.0
62 if os.path.exists(os.path.join(aster_dir,"elements")):
63 shutil.copyfile(os.path.join(aster_dir,"elements"),"elem.1")
65 shutil.copyfile(os.path.join(aster_dir,"catobj","elements"),"elem.1")
67 def init_service(self,service):
73 asterCompo=Template(asterCompo)
76 import sys,traceback,os
83 from E_SUPERV import SUPERV
94 class ${component}(${module}__POA.${component},dsccalcium.PyDSCComponent,SUPERV):
96 To be identified as a SALOME component this Python class
97 must have the same name as the component, inherit omniorb
98 class ${module}__POA.${component} and DSC class dsccalcium.PyDSCComponent
99 that implements DSC API.
101 def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ):
102 print "${component}.__init__: ", containerName, ';', instanceName,interfaceName
104 dsccalcium.PyDSCComponent.__init__(self, orb, poa,contID,containerName,instanceName,interfaceName)
106 def init_service(self,service):
113 asterEXECompo=asterCEXECompo+"""
115 dsccalcium.PyDSCComponent.destroy(self)
116 self._orb.shutdown(0)
119 asterCEXECompo=Template(asterCEXECompo)
120 asterEXECompo=Template(asterEXECompo)
123 def ${service}(self,${inparams}):
124 print "${component}.${service}"
125 self.beginService("${component}.${service}")
126 self.jdc=Cata.cata.JdC(procedure=jdc,cata=Cata.cata,nom="Salome",context_ini=${dvars})
128 #modif pour aster 9.0
129 if hasattr(self,"init_timer"):
131 #fin modif pour aster 9.0
133 # On compile le texte Python
136 #modif pour aster 9.0
137 # On initialise les tops de mesure globale de temps d'execution du jdc
138 if hasattr(self,"init_timer"):
139 j.cpu_user=os.times()[0]
140 j.cpu_syst=os.times()[1]
141 #fin modif pour aster 9.0
143 if not j.cr.estvide():
144 msg="ERREUR DE COMPILATION DANS ACCAS - INTERRUPTION"
146 print ">> JDC.py : DEBUT RAPPORT"
148 print ">> JDC.py : FIN RAPPORT"
151 raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,msg+'\\n'+str(j.cr),"${component}.py",0))
153 #surcharge des arguments de la ligne de commande (defaut stocke dans le composant) par un eventuel port de nom argv
155 self.argv=self.argv+argv.split()
159 #initialisation des arguments de la ligne de commande (remplace la methode initexec de B_JDC.py)
160 aster.argv(self.argv)
161 aster.init(CONTEXT.debug)
169 exc_typ,exc_val,exc_fr=sys.exc_info()
170 l=traceback.format_exception(exc_typ,exc_val,exc_fr)
171 raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"${component}.py",0))
174 if not j.cr.estvide():
175 msg="ERREUR A L'INTERPRETATION DANS ACCAS - INTERRUPTION"
178 print ">> JDC.py : DEBUT RAPPORT"
180 print ">> JDC.py : FIN RAPPORT"
182 raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,msg+'\\n'+str(j.cr), "${component}.py",0))
184 if j.par_lot == 'NON':
185 print "FIN EXECUTION"
186 err=calcium.cp_fin(self.proxy,calcium.CP_ARRET)
187 #retour sans erreur (il faut pousser les variables de sortie)
188 print "End of ${component}.${service}"
190 self.endService("${component}.${service}")
193 # Verification de la validite du jeu de commande
196 msg="ERREUR A LA VERIFICATION SYNTAXIQUE - INTERRUPTION"
198 print ">> JDC.py : DEBUT RAPPORT"
200 print ">> JDC.py : FIN RAPPORT"
202 raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,msg+'\\n'+str(cr),"${component}.py",0))
208 if not j.cr.estvide():
209 msg="ERREUR A L'EXECUTION - INTERRUPTION"
212 print ">> JDC.py : DEBUT RAPPORT"
214 print ">> JDC.py : FIN RAPPORT"
216 raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,msg+'\\n'+str(j.cr),"${component}.py",0))
218 #retour sans erreur (il faut pousser les variables de sortie)
219 err=calcium.cp_fin(self.proxy,calcium.CP_ARRET)
220 print "End of ${component}.${service}"
222 self.endService("${component}.${service}")
225 self.MESSAGE("ERREUR INOPINEE - INTERRUPTION")
227 exc_typ,exc_val,exc_fr=sys.exc_info()
228 l=traceback.format_exception(exc_typ,exc_val,exc_fr)
229 raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"${component}.py",0))
231 asterService=Template(asterService)
234 def ${service}(self,${inparams}):
235 print "${component}.${service}"
236 self.beginService("${component}.${service}")
241 self.jdc.g_context.update(${dvars})
243 CONTEXT.set_current_step(self.jdc)
244 linecache.cache['<string>']=0,0,string.split(jdc,'\\n'),'<string>'
245 exec jdc in self.jdc.g_context
246 CONTEXT.unset_current_step()
247 self.endService("${component}.${service}")
249 self.endService("${component}.${service}")
252 exc_typ,exc_val,exc_fr=sys.exc_info()
253 l=traceback.format_exception(exc_typ,exc_val,exc_fr)
254 self.endService("${component}.${service}")
255 CONTEXT.unset_current_step()
256 raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"${component}.py",0))
259 asterCEXEService=Template(asterCEXEService)
260 asterEXEService=asterCEXEService
265 # Check availability of Aster binary distribution
268 AC_DEFUN([AC_CHECK_ASTER],[
270 AC_CHECKING(for Aster)
275 [AC_HELP_STRING([--with-aster=DIR],[root directory path of Aster installation])],
276 [ASTER_DIR="$withval"],[ASTER_DIR=""])
278 if test -f ${ASTER_DIR}/asteru ; then
280 AC_MSG_RESULT(Using Aster distribution in ${ASTER_DIR})
282 ASTER_INCLUDES=-I$ASTER_DIR/bibc/include
285 AC_SUBST(ASTER_INCLUDES)
288 AC_MSG_WARN("Cannot find Aster distribution")
291 AC_MSG_RESULT(for Aster: $Aster_ok)
300 make_etude="""P actions make_etude
318 make_etude=Template(make_etude)
320 make_etude_exe="""P actions make_etude
336 make_etude_exe=Template(make_etude_exe)
340 export SALOME_CONTAINERNAME=$$1
342 cp ${export} temp.export
343 cat >> temp.export << END
344 F mess $$PWD/messages R 6
345 F resu $$PWD/resu R 8
346 F erre $$PWD/erre R 9
353 exeaster="""#!/bin/sh
355 export SALOME_CONTAINER=$$1
356 export SALOME_CONTAINERNAME=$$2
357 export SALOME_INSTANCE=$$3
359 cp ${export} temp.export
360 cat >> temp.export << END
361 F mess $$PWD/messages R 6
362 F resu $$PWD/resu R 8
363 F erre $$PWD/erre R 9
368 exeaster=Template(exeaster)
370 container="""import sys,os
371 from omniORB import CORBA
372 from SALOME_ContainerPy import SALOME_ContainerPy_i
374 if __name__ == '__main__':
377 orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
378 poa = orb.resolve_initial_references("RootPOA")
379 print "ORB and POA initialized"
380 containerName=os.getenv("SALOME_CONTAINERNAME")
381 cpy_i = SALOME_ContainerPy_i(orb, poa, containerName)
382 print "SALOME_ContainerPy_i instance created ",cpy_i
383 cpy_o = cpy_i._this()
384 print "SALOME_ContainerPy_i instance activated ",cpy_o
389 poaManager = poa._get_the_POAManager()
390 poaManager.activate()
394 print "fin container aster"
399 component="""import sys,os
400 from omniORB import CORBA
401 from ${component}_module import ${component}
403 if __name__ == '__main__':
406 orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
407 poa = orb.resolve_initial_references("RootPOA")
408 print "ORB and POA initialized",orb,poa
412 container=orb.string_to_object(os.getenv("SALOME_CONTAINER"))
413 containerName=os.getenv("SALOME_CONTAINERNAME")
414 instanceName=os.getenv("SALOME_INSTANCE")
416 compo=${component}(orb,poa,container,containerName, instanceName, "${component}")
417 comp_o = compo._this()
418 comp_iors = orb.object_to_string(comp_o)
419 print "ior aster",comp_iors
425 poaManager = poa._get_the_POAManager()
426 poaManager.activate()
429 print "fin du composant aster standalone"
432 component=Template(component)