1 # Copyright (C) 2009-2014 EDF R&D
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
17 # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 from string import Template
23 from compat import Template,set
26 import sys,traceback,os
27 sys.path=sys.path+[${python_path}]
28 import ${module}_ORB__POA
48 class ${component}(${module}_ORB__POA.${component}, ${inheritedclass} dsccalcium.PyDSCComponent):
50 To be identified as a SALOME component this Python class
51 must have the same name as the component, inherit omniorb
52 class ${module}_ORB__POA.${component} and DSC class dsccalcium.PyDSCComponent
53 that implements DSC API.
55 def __init__ ( self, orb, poa, contID, containerName, instanceName, interfaceName ):
56 dsccalcium.PyDSCComponent.__init__(self, orb, poa,contID,containerName,instanceName,interfaceName)
59 def init_service(self,service):
66 pyCompoEXE="""#!/usr/bin/env python
71 if __name__ == '__main__':
72 from omniORB import CORBA
74 orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
75 poa = orb.resolve_initial_references("RootPOA")
76 print "ORB and POA initialized",orb,poa
80 container=orb.string_to_object(sys.argv[1])
81 containerName=sys.argv[2]
82 instanceName=sys.argv[3]
84 compo=${component}(orb,poa,container,containerName, instanceName, "${component}")
85 comp_o = compo._this()
86 comp_iors = orb.object_to_string(comp_o)
87 print "ior ${component}",comp_iors
93 poaManager = poa._get_the_POAManager()
97 print "fin du composant ${component} standalone"
101 pyCompo=Template(pyCompo)
102 pyCompoEXE=Template(pyCompoEXE)
105 def ${service}(self,${inparams}):
106 self.beginService("${component}.${service}")
115 self.endService("${component}.${service}")
120 exc_typ,exc_val,exc_fr=sys.exc_info()
121 l=traceback.format_exception(exc_typ,exc_val,exc_fr)
122 raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"${component}.py",0)) """
123 pyService=Template(pyService)
125 pyinitService=""" if service == "${service}":
126 #initialization CALCIUM ports IN
128 #initialization CALCIUM ports OUT
131 pyinitService=Template(pyinitService)
132 pyinitCEXEService=pyinitService
133 pyinitEXEService=pyinitService
135 # CMakeLists.txt in src/<component> for a python component
136 # template parameters:
137 # sources: source files, separated by spaces
138 cmake_src_compo_py="""
145 SALOME_INSTALL_SCRIPTS("$${_bin_SCRIPTS}" $${SALOME_INSTALL_SCRIPT_PYTHON})
147 cmake_src_compo_py=Template(cmake_src_compo_py)