import os
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
from module_generator import Generator,Module,ASTERComponent,Service,F77Component
aster_root=os.path.join(aster_home,aster_version)
import os
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
from module_generator import Generator,Module,ASTERComponent,Service,F77Component
aster_root=os.path.join(aster_home,aster_version)
import os
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
from module_generator import Generator,Module,Service,PYComponent,CPPComponent,F77Component
from module_generator import Library
body="""
#b1
info,name= calcium.cp_cd(component)
-print "name=",name
-print "info=",info
+print ("name=",name)
+print ("info=",info)
dep=calcium.CP_ITERATION
val[0]=7.7
val[5]=a*b
nval=10
-print "--------> Appel calcium.cp_edb",val
+print ("--------> Appel calcium.cp_edb",val)
info=calcium.cp_edb(component, dep, 0., 1, "ba", nval,val)
info=calcium.cp_edb(component, dep, 0., 2, "ba", nval,val)
info=calcium.cp_edb(component, dep, 0., 3, "ba", nval,val)
val[0]="coucouc"
val[1]="bonjour"
val[2]="salut"
-print "--------> Appel calcium.cp_ech",val
+print ("--------> Appel calcium.cp_ech",val)
info=calcium.cp_ech(component, dep, 0., 1, "bb", 3,val)
#int
val=numpy.zeros(10,'i')
val[0]=1
val[1]=3
-print "--------> Appel calcium.cp_een",val
+print ("--------> Appel calcium.cp_een",val)
info=calcium.cp_een(component, dep, 0., 1, "bc", 3,val)
val=numpy.zeros(10,'F')
val[0]=1+2j
val[1]=3+2j
-print "--------> Appel calcium.cp_ecp",val
+print ("--------> Appel calcium.cp_ecp",val)
info=calcium.cp_ecp(component, dep, 0., 1, "bd", 3,val)
val=numpy.zeros(10,'f')
val[0]=1.3
val[1]=3.2
-print "--------> Appel calcium.cp_ere",val
+print ("--------> Appel calcium.cp_ere",val)
info=calcium.cp_ere(component, dep, 0., 1, "be", 3,val)
val=numpy.zeros(10,'i')
val[0]=True
val[1]=False
val[2]=False
-print "--------> Appel calcium.cp_elo",val
+print ("--------> Appel calcium.cp_elo",val)
info=calcium.cp_elo(component, dep, 0., 1, "bf", 3,val)
val=numpy.zeros(10,'l')
val[0]=1
val[1]=3
val[2]=333
-print "--------> Appel calcium.cp_eln",val
+print ("--------> Appel calcium.cp_eln",val)
info=calcium.cp_eln(component, dep, 0., 1, "bg", 3,val)
val=numpy.zeros(10,'i')
val[0]=1
val[1]=3
val[2]=4
-print "--------> Appel calcium.cp_een",val
+print ("--------> Appel calcium.cp_een",val)
info=calcium.cp_een(component, dep, 0., 1, "bh", 3,val)
val=numpy.zeros(10,'l')
val[0]=1
val[1]=3
val[2]=333
-print "--------> Appel calcium.cp_elg",val
+print ("--------> Appel calcium.cp_elg",val)
info=calcium.cp_elg(component, dep, 0., 1, "bi", 3,val)
-print "info=",info
+print ("info=",info)
#read
val=numpy.zeros(10,'d')
-print "--------> Appel calcium.cp_ldb"
+print ("--------> Appel calcium.cp_ldb")
info,tt,ii,mval=calcium.cp_ldb(component, dep, 0.,1., 1, "aa", 3,val)
-print mval,val
+print (mval,val)
val=numpy.array(["","","",], dtype='S13')
-print "--------> Appel calcium.cp_lch"
+print ("--------> Appel calcium.cp_lch")
info,tt,ii,mval=calcium.cp_lch(component, dep, 0.,1., 1, "ab", 3,val)
-print mval,val
-print val.dtype
+print (mval,val)
+print (val.dtype)
val=numpy.array([" "," "," ",], dtype='S13')
-print "--------> Appel calcium.cp_lch"
+print ("--------> Appel calcium.cp_lch")
info,tt,ii,mval=calcium.cp_lch(component, dep, 0.,1., 1, "ab", 3,val)
-print mval,val
-print val.dtype
+print (mval,val)
+print (val.dtype)
val=calcium.stringArray(3,8)
-print "--------> Appel calcium.cp_lch"
+print ("--------> Appel calcium.cp_lch")
info,tt,ii,mval=calcium.cp_lch(component, dep, 0.,1., 1, "ab", 3,val)
-print mval,val
-print val[0]
-print val[1]
-print val[2]
+print (mval,val)
+print (val[0])
+print (val[1])
+print (val[2])
val=numpy.zeros(10,'i')
-print "--------> Appel calcium.cp_len"
+print ("--------> Appel calcium.cp_len")
info,tt,ii,mval=calcium.cp_len(component, dep, 0.,1., 1, "ac", 3,val)
-print mval,val
+print (mval,val)
val=numpy.zeros(10,'F')
-print "--------> Appel calcium.cp_lcp"
+print ("--------> Appel calcium.cp_lcp")
info,tt,ii,mval=calcium.cp_lcp(component, dep, 0.,1., 1, "ad", 3,val)
-print mval,val
+print (mval,val)
val=numpy.zeros(10,'f')
-print "--------> Appel calcium.cp_lre"
+print ("--------> Appel calcium.cp_lre")
info,tt,ii,mval=calcium.cp_lre(component, dep, 0.,1., 1, "ae", 3,val)
-print mval,val
+print (mval,val)
val=numpy.zeros(10,'i')
-print "--------> Appel calcium.cp_llo"
+print ("--------> Appel calcium.cp_llo")
info,tt,ii,mval=calcium.cp_llo(component, dep, 0.,1., 1, "af", 3,val)
-print mval,val
+print (mval,val)
val=numpy.zeros(10,'l')
-print "--------> Appel calcium.cp_lln"
+print ("--------> Appel calcium.cp_lln")
info,tt,ii,mval=calcium.cp_lln(component, dep, 0.,1., 1, "ag", 3,val)
-print mval,val
+print (mval,val)
val=numpy.zeros(10,'i')
-print "--------> Appel calcium.cp_len"
+print ("--------> Appel calcium.cp_len")
info,tt,ii,mval=calcium.cp_len(component, dep, 0.,1., 1, "ah", 3,val)
-print mval,val
+print (mval,val)
val=numpy.zeros(10,'l')
-print "--------> Appel calcium.cp_llg"
+print ("--------> Appel calcium.cp_llg")
info,tt,ii,mval=calcium.cp_llg(component, dep, 0.,1., 1, "ai", 3,val)
-print "info=",info
-print mval,val
+print ("info=",info)
+print (mval,val)
info=calcium.cp_fini(component,"aa",1)
-print "info=",info
+print ("info=",info)
info=calcium.cp_effi(component,"aa",3)
-print "info=",info
+print ("info=",info)
import time
time.sleep(15)
c=a+b
d=a-b
err=calcium.cp_fin(component,calcium.CP_ARRET)
-print "err=",err
+print ("err=",err)
"""
c2=PYComponent("compo2",services=[
Service("s1",inport=[("a","double"),("b","double")],
import os
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
from module_generator import Generator,Module,Service,PYComponent,CPPComponent,F77Component
from module_generator import Library
body="""
#b1
info,name= calcium.cp_cd(component)
-print "name=",name
-print "info=",info
+print ("name=",name)
+print ("info=",info)
dep=calcium.CP_TEMPS
#double
val[0]=7.7
val[5]=a*b
nval=10
-print "--------> Appel calcium.cp_edb",val
+print ("--------> Appel calcium.cp_edb",val)
info=calcium.cp_edb(component, dep, 0., 1, "ba", nval,val)
info=calcium.cp_edb(component, dep, 1., 2, "ba", nval,val)
info=calcium.cp_edb(component, dep, 2., 3, "ba", nval,val)
val[0]="coucouc"
val[1]="bonjour"
val[2]="salut"
-print "--------> Appel calcium.cp_ech",val
+print ("--------> Appel calcium.cp_ech",val)
info=calcium.cp_ech(component, dep, 0., 1, "bb", 3,val)
#int
val=numpy.zeros(10,'i')
val[0]=1
val[1]=3
-print "--------> Appel calcium.cp_een",val
+print ("--------> Appel calcium.cp_een",val)
info=calcium.cp_een(component, dep, 0., 1, "bc", 3,val)
val=numpy.zeros(10,'F')
val[0]=1+2j
val[1]=3+2j
-print "--------> Appel calcium.cp_ecp",val
+print ("--------> Appel calcium.cp_ecp",val)
info=calcium.cp_ecp(component, dep, 0., 1, "bd", 3,val)
val=numpy.zeros(10,'f')
val[0]=1.3
val[1]=3.2
-print "--------> Appel calcium.cp_ere",val
+print ("--------> Appel calcium.cp_ere",val)
info=calcium.cp_ere(component, dep, 0., 1, "be", 3,val)
val=numpy.zeros(10,'i')
val[0]=True
val[1]=False
val[2]=False
-print "--------> Appel calcium.cp_elo",val
+print ("--------> Appel calcium.cp_elo",val)
info=calcium.cp_elo(component, dep, 0., 1, "bf", 3,val)
val=numpy.zeros(10,'l')
val[0]=1
val[1]=3
val[2]=333
-print "--------> Appel calcium.cp_eln",val
+print ("--------> Appel calcium.cp_eln",val)
info=calcium.cp_eln(component, dep, 0., 1, "bg", 3,val)
val=numpy.zeros(10,'i')
val[0]=1
val[1]=3
val[2]=4
-print "--------> Appel calcium.cp_een",val
+print ("--------> Appel calcium.cp_een",val)
info=calcium.cp_een(component, dep, 0., 1, "bh", 3,val)
val=numpy.zeros(10,'l')
val[0]=1
val[1]=3
val[2]=333
-print "--------> Appel calcium.cp_elg",val
+print ("--------> Appel calcium.cp_elg",val)
info=calcium.cp_elg(component, dep, 0., 1, "bi", 3,val)
-print "info=",info
+print ("info=",info)
#read
val=numpy.zeros(10,'d')
-print "--------> Appel calcium.cp_ldb"
+print ("--------> Appel calcium.cp_ldb")
info,tt,ii,mval=calcium.cp_ldb(component, dep, 0.,1., 1, "aa", 3,val)
-print mval,val
+print (mval,val)
val=numpy.array(["","","",], dtype='S13')
-print "--------> Appel calcium.cp_lch"
+print ("--------> Appel calcium.cp_lch")
info,tt,ii,mval=calcium.cp_lch(component, dep, 0.,1., 1, "ab", 3,val)
-print mval,val
-print val.dtype
+print (mval,val)
+print (val.dtype)
val=numpy.array([" "," "," ",], dtype='S13')
-print "--------> Appel calcium.cp_lch"
+print ("--------> Appel calcium.cp_lch")
info,tt,ii,mval=calcium.cp_lch(component, dep, 0.,1., 1, "ab", 3,val)
-print mval,val
-print val.dtype
+print (mval,val)
+print (val.dtype)
val=calcium.stringArray(3,8)
-print "--------> Appel calcium.cp_lch"
+print ("--------> Appel calcium.cp_lch")
info,tt,ii,mval=calcium.cp_lch(component, dep, 0.,1., 1, "ab", 3,val)
-print mval,val
-print val[0]
-print val[1]
-print val[2]
+print (mval,val)
+print (val[0])
+print (val[1])
+print (val[2])
val=numpy.zeros(10,'i')
-print "--------> Appel calcium.cp_len"
+print ("--------> Appel calcium.cp_len")
info,tt,ii,mval=calcium.cp_len(component, dep, 0.,1., 1, "ac", 3,val)
-print mval,val
+print (mval,val)
val=numpy.zeros(10,'F')
-print "--------> Appel calcium.cp_lcp"
+print ("--------> Appel calcium.cp_lcp")
info,tt,ii,mval=calcium.cp_lcp(component, dep, 0.,1., 1, "ad", 3,val)
-print mval,val
+print (mval,val)
val=numpy.zeros(10,'f')
-print "--------> Appel calcium.cp_lre"
+print ("--------> Appel calcium.cp_lre")
info,tt,ii,mval=calcium.cp_lre(component, dep, 0.,1., 1, "ae", 3,val)
-print mval,val
+print (mval,val)
val=numpy.zeros(10,'i')
-print "--------> Appel calcium.cp_llo"
+print ("--------> Appel calcium.cp_llo")
info,tt,ii,mval=calcium.cp_llo(component, dep, 0.,1., 1, "af", 3,val)
-print mval,val
+print (mval,val)
val=numpy.zeros(10,'l')
-print "--------> Appel calcium.cp_lln"
+print ("--------> Appel calcium.cp_lln")
info,tt,ii,mval=calcium.cp_lln(component, dep, 0.,1., 1, "ag", 3,val)
-print mval,val
+print (mval,val)
val=numpy.zeros(10,'i')
-print "--------> Appel calcium.cp_len"
+print ("--------> Appel calcium.cp_len")
info,tt,ii,mval=calcium.cp_len(component, dep, 0.,1., 1, "ah", 3,val)
-print mval,val
+print (mval,val)
val=numpy.zeros(10,'l')
-print "--------> Appel calcium.cp_llg"
+print ("--------> Appel calcium.cp_llg")
info,tt,ii,mval=calcium.cp_llg(component, dep, 0.,1., 1, "ai", 3,val)
-print "info=",info
-print mval,val
+print ("info=",info)
+print (mval,val)
info=calcium.cp_fint(component,"aa",0.5)
-print "info=",info
+print ("info=",info)
info=calcium.cp_efft(component,"aa",1.5)
-print "info=",info
+print ("info=",info)
import time
time.sleep(15)
c=a+b
d=a-b
err=calcium.cp_fin(component,calcium.CP_ARRET)
-print "err=",err
+print ("err=",err)
"""
c2=PYComponent("compo2",services=[
Service("s1",inport=[("a","double"),("b","double")],
import os
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
from module_generator import Generator,Module,Service,CPPComponent
cwd=os.getcwd()
import os
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
from module_generator import Generator,Module,Service,CPPComponent
cwd=os.getcwd()
#
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
import os
from module_generator import *
virtual bool Load(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, const char* theURL, bool isMultiFile){return 0;};
virtual bool LoadASCII(SALOMEDS::SComponent_ptr theComponent, const SALOMEDS::TMPFile& theStream, const char* theURL, bool isMultiFile){return 0;};
virtual void Close(SALOMEDS::SComponent_ptr IORSComponent){};
- virtual char* ComponentDataType(){return "cppcompos";};
+ virtual char* ComponentDataType(){return (char*)"cppcompos";};
virtual char* IORToLocalPersistentID(SALOMEDS::SObject_ptr theSObject, const char* IORString, CORBA::Boolean isMultiFile, CORBA::Boolean isASCII){return 0;};
virtual char* LocalPersistentIDToIOR(SALOMEDS::SObject_ptr theSObject, const char* aLocalPersistentID, CORBA::Boolean isMultiFile,
CORBA::Boolean isASCII){return 0;};
virtual bool CanPublishInStudy(CORBA::Object_ptr theIOR){return 0;};
- virtual SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::Study_ptr theStudy,SALOMEDS::SObject_ptr theSObject,CORBA::Object_ptr theObject,
+ virtual SALOMEDS::SObject_ptr PublishInStudy(SALOMEDS::SObject_ptr theSObject,CORBA::Object_ptr theObject,
const char* theName){return 0;};
virtual CORBA::Boolean CanCopy(SALOMEDS::SObject_ptr theObject){return 0;};
virtual SALOMEDS::TMPFile* CopyFrom(SALOMEDS::SObject_ptr theObject, CORBA::Long& theObjectID){return 0;};
#include <SUIT_Study.h>
#include <SalomeApp_Application.h>
#include <SALOME_LifeCycleCORBA.hxx>
+#include <SALOME_KernelServices.hxx>
#include <SALOMEconfig.h>
#include CORBA_CLIENT_HEADER(cppcompos)
setMenuShown( true );
setToolShown( true );
- SALOME_NamingService *aNamingService = SalomeApp_Application::namingService();
- CORBA::Object_var aSMObject = aNamingService->Resolve("/myStudyManager");
- SALOMEDS::StudyManager_var aStudyManager = SALOMEDS::StudyManager::_narrow(aSMObject);
- SALOMEDS::Study_var aDSStudy = aStudyManager->GetStudyByID(theStudy->id());
+ SALOMEDS::Study_var aDSStudy = KERNEL::getStudyServant();
SALOMEDS::SComponent_var aFather = aDSStudy->FindComponent("cppcompos");
if (aFather->_is_nil())
aStudyBuilder->DefineComponentInstance(aFather, engine);
}
CORBA::Boolean valid;
- engine->DumpPython(aDSStudy,1,0,valid);
+ engine->DumpPython(1,0,valid);
return bOk;
}
import os
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
from module_generator import Generator,Module,Service,F77Component
from module_generator import Library
import os
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
from module_generator import Generator,Module,Service,F77Component
cwd=os.getcwd()
import SALOME
import salome
salome.salome_init()
-print "Test du composant CALCUL genere par hxx2salome"
+print("Test du composant CALCUL genere par hxx2salome")
import hxxcompos_ORB
myCalc = salome.lcc.FindOrLoadComponent("FactoryServer", "CALCUL")
-print "10+15 = ",myCalc.add(10,15)
-print "10x15 = ",myCalc.mul(10,15)
+print("10+15 = ",myCalc.add(10,15))
+print("10x15 = ",myCalc.mul(10,15))
#print "6! = ",myCalc.fact(6)
res1,res2 = myCalc.sqr2(12.0)
-print "12*12 = ",res1," ",res2
+print("12*12 = ",res1," ",res2)
j=1
i1,i2,i3 = myCalc.return_3_int(j)
assert (i1 == j+1),'Erreur dans la fonction return_3_int'
assert (i2 == j+2),'Erreur dans la fonction return_3_int'
assert (i3 == j+3),'Erreur dans la fonction return_3_int'
-print 'return_3_int : ',j,' ',i1,' ',i2,' ',i3
-print "True && True = ",myCalc.And(True,True)
-print "True && False = ",myCalc.And(True,False)
-print "True || False = ",myCalc.Or(True,False)
+print('return_3_int : ',j,' ',i1,' ',i2,' ',i3)
+print("True && True = ",myCalc.And(True,True))
+print("True && False = ",myCalc.And(True,False))
+print("True || False = ",myCalc.Or(True,False))
from math import fabs
assert (fabs(res1-144.0)<1.0e-6 ), 'Erreur dans la fonction myCalc.sqr2 : 12*12 = '+str(res1)
assert ( myCalc.And(True,True)==True ) , 'Erreur dans la fonction And(True,True)'
assert ( myCalc.And(True,False)==False ) , 'Erreur dans la fonction And(True,False)'
assert ( myCalc.Or(True,False)==True ) , 'Erreur dans la fonction Or(True,False)'
-print "Fin test hxx2salome/001/A1"
+print("Fin test hxx2salome/001/A1")
#
myCoco = salome.lcc.FindOrLoadComponent("FactoryServerI", "ICOCO")
#
liste_champs = myCoco.getInputFieldsNames()
nb_champs=len(liste_champs)
-print "Nombre de champs = ",nb_champs
+print("Nombre de champs = ",nb_champs)
assert nb_champs == 2 , 'erreur dans le nombre de champs, different de 2!'
#
-print "Champ 1 (SourceField) : ",liste_champs[0]
-print "Champ 2 (TargetField) : ",liste_champs[1]
+print("Champ 1 (SourceField) : ",liste_champs[0])
+print("Champ 2 (TargetField) : ",liste_champs[1])
assert liste_champs[0] == "SourceField", 'erreur dans le nom du champ 1'
assert liste_champs[1] == "TargetField", 'erreur dans le nom du champ 2'
#
-print "Fin test hxx2salome/ICOCO/A1"
+print("Fin test hxx2salome/ICOCO/A1")
myCoco1 = salome.lcc.FindOrLoadComponent("FactoryServerI1", "ICOCO")
myCoco2 = salome.lcc.FindOrLoadComponent("FactoryServerI2", "ICOCO")
#
f=myCoco1.getOutputField("SourceField")
myCoco2.printField(f)
#
-print "##################################"
-print "Fin test hxx2salome/ICOCO/A2"
+print("##################################")
+print("Fin test hxx2salome/ICOCO/A2")
import os
#import context from ..
-execfile("../pacocontext.py")
+exec(compile(open("../pacocontext.py").read(), "../pacocontext.py", 'exec'))
from module_generator import Generator,Module,Service,PACOComponent
cwd=os.getcwd()
import os
#import context from ..
-execfile("../pacocontext.py")
+exec(compile(open("../pacocontext.py").read(), "../pacocontext.py", 'exec'))
from module_generator import Generator,Module,Service,PACOComponent
cwd=os.getcwd()
import os
#import context from ..
-execfile("../pacocontext.py")
+exec(compile(open("../pacocontext.py").read(), "../pacocontext.py", 'exec'))
from module_generator import Generator,Module,Service,PACOComponent
cwd=os.getcwd()
import os
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
from module_generator import *
import os
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
from module_generator import *
def createObject( self, study, name ):
"Create object. "
try:
- print study,name
+ print (study,name)
builder = study.NewBuilder()
father = study.FindComponent( "pycompos" )
if father is None:
name = "%s_%d" % ( default_name, __objectid__ )
if not name: return
getEngine().createObject( _getStudy(), name )
- print getEngine().s1(4,5)
- print getEngine().ComponentDataType()
+ print(getEngine().s1(4,5))
+ print(getEngine().ComponentDataType())
sg.updateObjBrowser( True )
class DemoImpl(QtWidgets.QDialog):
# called when GUI action is activated
# action ID is passed as parameter
def OnGUIEvent( commandID ):
- print "pycompos.OnGUIEvent(): command = %d" % commandID
+ print("pycompos.OnGUIEvent(): command = %d" % commandID)
if commandID==941:
widget=QMainWindow(sgPyQt.getDesktop())
web = QWebView(widget)
#
def f():
- print "coucou"
+ print("coucou")
import os
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
from module_generator import Generator,Module,Service,PYComponent
cwd=os.getcwd()
val=numpy.zeros(10,'d')
val[5]=a*b
nval=10
- print "--------> Appel calcium.cp_edb"
+ print ("--------> Appel calcium.cp_edb")
info=calcium.cp_edb(component, dep, 0., 1, "ba", nval,val)
val=numpy.zeros(10,'d')
info,tt,ii,mval=calcium.cp_ldb(component, dep, 0.,1., 1, "aa", nval,val)
- print mval,val
+ print (mval,val)
bidul.f()
c=a+b
d=a-b
import os
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
from module_generator import Generator,Module,Service,PYComponent
cwd=os.getcwd()
val=numpy.zeros(10,'d')
val[5]=a*b
nval=10
- print "--------> Appel calcium.cp_edb"
+ print ("--------> Appel calcium.cp_edb")
info=calcium.cp_edb(component, dep, 0., 1, "ba", nval,val)
val=numpy.zeros(10,'d')
info,tt,ii,mval=calcium.cp_ldb(component, dep, 0.,1., 1, "aa", nval,val)
- print mval,val
+ print (mval,val)
c=a+b
d=a-b
err=calcium.cp_fin(component,calcium.CP_ARRET)
#start salome and connect to it
try:
salome_module.main(["start", "-t"])
- except SystemExit, e:
+ except SystemExit as e:
pass
import runSession
runSession.configureSession()
xmlLoader = loader.YACSLoader()
try:
p = xmlLoader.load("coupling.xml")
- except IOError,ex:
+ except IOError as ex:
self.fail("IO exception:" + ex);
self.assertTrue(p.isValid())
e = pilot.ExecutorSwig()
def tearDown(self):
try:
salome_module.main(["killall"])
- except SystemExit, e:
+ except SystemExit as e:
pass
if __name__ == '__main__':
import os
#import context from ..
-execfile("../context.py")
+exec(compile(open("../context.py").read(), "../context.py", 'exec'))
from module_generator import Generator,Module,Service,CPPComponent,PYComponent,add_type,add_module
pydefs="""import SALOME_TYPES"""
pybody="""
-print a,b,c,d,d2,d3,e,f,g
+print (a,b,c,d,d2,d3,e,f,g)
aa=SALOME_TYPES.Parameter(name="a",value="45.")
ab=[]
ac=[1,2,3]
ae=["aaa","bbb"]
af=SALOME_TYPES.ParametricInput(inputVarList=ae,outputVarList=ae, inputValues=[[[[1,2,3]]]],specificParameters=[])
ag=SALOME_TYPES.ParametricOutput(outputValues=[[[[1,2,3]]]], specificOutputInfos=[], returnCode=1, errorMessage="error")
-print aa,ab,ac,ad,ad2,ad3,ae,af,ag
+print (aa,ab,ac,ad,ad2,ad3,ae,af,ag)
"""
s2pybody="""
-print "service s2 python component"
+print ("service s2 python component")
aa=a
a.Register()
"""
<outport name="o8" type="SALOME_TYPES/ParametricOutput"/>
</inline>
<inline name="PyScript0005">
- <script><code><![CDATA[print i1
-print i2
-print i3
-print i4
-print i8
-print i9
-print i5
-print i6
-print i7
+ <script><code><![CDATA[print(i1)
+print(i2)
+print(i3)
+print(i4)
+print(i8)
+print(i9)
+print(i5)
+print(i6)
+print(i7)
]]></code></script>
<inport name="i1" type="SALOME_TYPES/Parameter"/>
<inport name="i2" type="SALOME_TYPES/ParameterList"/>
<inport name="i7" type="SALOME_TYPES/ParametricOutput"/>
</inline>
<inline name="PyScript006">
- <script><code><![CDATA[print i1
-print i2
-print i3
-print i4
-print i8
-print i9
-print i5
-print i6
-print i7
+ <script><code><![CDATA[print(i1)
+print(i2)
+print(i3)
+print(i4)
+print(i8)
+print(i9)
+print(i5)
+print(i6)
+print(i7)
]]></code></script>
<inport name="i1" type="SALOME_TYPES/Parameter"/>
<inport name="i2" type="SALOME_TYPES/ParameterList"/>
generates a SALOME source module, its installation and a SALOME application including this module and
other preexisting SALOME modules like GEOM, SMESH or others.
"""
-from gener import Module, Service, Generator
-from fcompo import F77Component
-from cppcompo import CPPComponent
-from pacocompo import PACOComponent
-from pycompo import PYComponent
-from astcompo import ASTERComponent
-from hxxcompo import HXX2SALOMEComponent
-from hxxparacompo import HXX2SALOMEParaComponent
-from yacstypes import add_type
-from salomemodules import add_module
-from gener import Library
-from mpicompo import MPIComponent
+from module_generator.gener import Module, Service, Generator
+from module_generator.fcompo import F77Component
+from module_generator.cppcompo import CPPComponent
+from module_generator.pacocompo import PACOComponent
+from module_generator.pycompo import PYComponent
+from module_generator.astcompo import ASTERComponent
+from module_generator.hxxcompo import HXX2SALOMEComponent
+from module_generator.hxxparacompo import HXX2SALOMEParaComponent
+from module_generator.yacstypes import add_type
+from module_generator.salomemodules import add_module
+from module_generator.gener import Library
+from module_generator.mpicompo import MPIComponent
"""
import re, os, sys
-from gener import Component, Invalid, makedirs
+from module_generator.gener import Component, Invalid, makedirs
-from pyth_tmpl import pyinitEXEService, pyinitCEXEService, pyinitService
-import aster_tmpl
-from aster_tmpl import asterCEXEService, asterEXEService
-from aster_tmpl import asterService, asterEXECompo, asterCEXECompo, asterCompo
-from aster_tmpl import comm, make_etude, cexe, exeaster
-from aster_tmpl import container, component
-from aster_tmpl import cmake_src_compo_aster, cmake_src_compo_aster_lib
+from module_generator.pyth_tmpl import pyinitEXEService, pyinitCEXEService, pyinitService
+from module_generator import aster_tmpl
+from module_generator.aster_tmpl import asterCEXEService, asterEXEService
+from module_generator.aster_tmpl import asterService, asterEXECompo, asterCEXECompo, asterCompo
+from module_generator.aster_tmpl import comm, make_etude, cexe, exeaster
+from module_generator.aster_tmpl import container, component
+from module_generator.aster_tmpl import cmake_src_compo_aster, cmake_src_compo_aster_lib
class ASTERComponent(Component):
"""
if typ=="file":continue #files are not passed through service interface
params.append(name)
if typ == "pyobj":
- datas.append('"%s":cPickle.loads(%s)' % (name, name))
+ datas.append('"%s":pickle.loads(%s)' % (name, name))
else:
datas.append('"%s":%s' % (name, name))
#ajout de l'adresse du composant
if typ=="file":continue #files are not passed through service interface
params.append(name)
if typ == "pyobj":
- datas.append('cPickle.dumps(j.g_context["%s"],-1)'%name)
+ datas.append('pickle.dumps(j.g_context["%s"],-1)'%name)
else:
datas.append('j.g_context["%s"]'%name)
outparams = ",".join(params)
if typ=="file":continue #files are not passed through service interface
params.append(name)
if typ == "pyobj":
- datas.append('"%s":cPickle.loads(%s)' % (name, name))
+ datas.append('"%s":pickle.loads(%s)' % (name, name))
else:
datas.append('"%s":%s' % (name, name))
#ajout de l'adresse du composant
for name, typ in serv.outport:
params.append(name)
if typ == "pyobj":
- datas.append('cPickle.dumps(j.g_context["%s"],-1)'%name)
+ datas.append('pickle.dumps(j.g_context["%s"],-1)'%name)
else:
datas.append('j.g_context["%s"]'%name)
outparams = ",".join(params)
if typ=="file":continue #files are not passed through service interface
params.append(name)
if typ == "pyobj":
- datas.append('"%s":cPickle.loads(%s)' % (name, name))
+ datas.append('"%s":pickle.loads(%s)' % (name, name))
else:
datas.append('"%s":%s' % (name, name))
#ajout de l'adresse du composant
for name, typ in serv.outport:
params.append(name)
if typ == "pyobj":
- datas.append('cPickle.dumps(j.g_context["%s"],-1)'%name)
+ datas.append('pickle.dumps(j.g_context["%s"],-1)'%name)
else:
datas.append('j.g_context["%s"]'%name)
outparams = ",".join(params)
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
asterCompo="""
import sys,traceback,os
if not j.cr.estvide():
msg="ERREUR DE COMPILATION DANS ACCAS - INTERRUPTION"
self.MESSAGE(msg)
- print ">> JDC.py : DEBUT RAPPORT"
- print j.cr
- print ">> JDC.py : FIN RAPPORT"
+ print (">> JDC.py : DEBUT RAPPORT")
+ print (j.cr)
+ print (">> JDC.py : FIN RAPPORT")
j.supprime()
sys.stdout.flush()
raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,msg+'\\n'+str(j.cr),"${component}.py",0))
msg="ERREUR A L'INTERPRETATION DANS ACCAS - INTERRUPTION"
self.MESSAGE(msg)
ier=1
- print ">> JDC.py : DEBUT RAPPORT"
- print j.cr
- print ">> JDC.py : FIN RAPPORT"
+ print (">> JDC.py : DEBUT RAPPORT")
+ print (j.cr)
+ print (">> JDC.py : FIN RAPPORT")
sys.stdout.flush()
raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,msg+'\\n'+str(j.cr), "${component}.py",0))
if j.par_lot == 'NON':
- print "FIN EXECUTION"
+ print ("FIN EXECUTION")
#err=calcium.cp_fin(self.proxy,calcium.CP_ARRET)
#retour sans erreur (il faut pousser les variables de sortie)
sys.stdout.flush()
if not cr.estvide():
msg="ERREUR A LA VERIFICATION SYNTAXIQUE - INTERRUPTION"
self.MESSAGE(msg)
- print ">> JDC.py : DEBUT RAPPORT"
- print cr
- print ">> JDC.py : FIN RAPPORT"
+ print( ">> JDC.py : DEBUT RAPPORT")
+ print( cr)
+ print( ">> JDC.py : FIN RAPPORT")
sys.stdout.flush()
raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,msg+'\\n'+str(cr),"${component}.py",0))
msg="ERREUR A L'EXECUTION - INTERRUPTION"
self.MESSAGE(msg)
ier=1
- print ">> JDC.py : DEBUT RAPPORT"
- print j.cr
- print ">> JDC.py : FIN RAPPORT"
+ print( ">> JDC.py : DEBUT RAPPORT")
+ print( j.cr)
+ print( ">> JDC.py : FIN RAPPORT")
sys.stdout.flush()
raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,msg+'\\n'+str(j.cr),"${component}.py",0))
else:
if __name__ == '__main__':
- print sys.argv
+ print( sys.argv)
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
poa = orb.resolve_initial_references("RootPOA")
- print "ORB and POA initialized"
+ print( "ORB and POA initialized")
containerName=os.getenv("SALOME_CONTAINERNAME")
cpy_i = SALOME_ContainerPy_i(orb, poa, containerName)
- print "SALOME_ContainerPy_i instance created ",cpy_i
+ print( "SALOME_ContainerPy_i instance created ",cpy_i)
cpy_o = cpy_i._this()
- print "SALOME_ContainerPy_i instance activated ",cpy_o
+ print( "SALOME_ContainerPy_i instance activated ",cpy_o)
sys.stdout.flush()
sys.stderr.flush()
#Block for ever
orb.run()
- print "fin container aster"
+ print( "fin container aster")
sys.stdout.flush()
sys.stderr.flush()
"""
if __name__ == '__main__':
- print sys.argv
+ print( sys.argv)
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
poa = orb.resolve_initial_references("RootPOA")
- print "ORB and POA initialized",orb,poa
+ print( "ORB and POA initialized",orb,poa)
sys.stdout.flush()
sys.stderr.flush()
compo=${component}(orb,poa,container,containerName, instanceName, "${component}")
comp_o = compo._this()
comp_iors = orb.object_to_string(comp_o)
- print "ior aster",comp_iors
+ print( "ior aster",comp_iors)
sys.stdout.flush()
sys.stderr.flush()
poaManager.activate()
orb.run()
- print "fin du composant aster standalone"
+ print( "fin du composant aster standalone")
"""
component=Template(component)
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
# CORBA idl
d = {}
for v in iterable :
k = key(v)
- if not d.has_key(k) :
+ if k not in d :
d[k] = []
d[k].append(v)
- keys = d.keys()
+ keys = list(d.keys())
keys.sort(cmp)
i = []
for k in keys :
cls.pattern = re.compile(pattern, re.IGNORECASE | re.VERBOSE)
-class Template:
+class Template(metaclass=_TemplateMetaclass):
"""A string class for supporting $-substitutions."""
- __metaclass__ = _TemplateMetaclass
delimiter = '$'
idpattern = r'[_a-z][_a-z0-9]*'
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
cxxCompo="""
#include "${component}.hxx"
"""
import os
-from gener import Component, Invalid
-from cpp_tmpl import initService, cxxService, hxxCompo, cxxCompo
-from cpp_tmpl import exeCPP, cmake_src_compo_cpp
-from yacstypes import corba_rtn_type
+from module_generator.gener import Component, Invalid
+from module_generator.cpp_tmpl import initService, cxxService, hxxCompo, cxxCompo
+from module_generator.cpp_tmpl import exeCPP, cmake_src_compo_cpp
+from module_generator.yacstypes import corba_rtn_type
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
class CPPComponent(Component):
"""
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
# CMakeLists.txt in doc directory
# template parameters:
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-from gener import Component
-from cppcompo import CPPComponent
+from module_generator.gener import Component
+from module_generator.cppcompo import CPPComponent
import platform
archi = platform.architecture()[0]
try:
from string import Template
except:
- from compat import Template, set
+ from module_generator.compat import Template, set
class Invalid(Exception):
pass
debug=0
-from mod_tmpl import *
-from cata_tmpl import catalog, interface, idl
-from cata_tmpl import xml, xml_interface, xml_service
-from cata_tmpl import idlMakefilePaCO_BUILT_SOURCES, idlMakefilePaCO_nodist_salomeinclude_HEADERS
-from cata_tmpl import idlMakefilePACO_salomepython_DATA, idlMakefilePACO_salomeidl_DATA
-from cata_tmpl import idlMakefilePACO_INCLUDES
-from cata_tmpl import cataOutStream, cataInStream, cataOutparam, cataInparam
-from cata_tmpl import cataOutParallelStream, cataInParallelStream
-from cata_tmpl import cataService, cataCompo
+from module_generator.mod_tmpl import *
+from module_generator.cata_tmpl import catalog, interface, idl
+from module_generator.cata_tmpl import xml, xml_interface, xml_service
+from module_generator.cata_tmpl import idlMakefilePaCO_BUILT_SOURCES, idlMakefilePaCO_nodist_salomeinclude_HEADERS
+from module_generator.cata_tmpl import idlMakefilePACO_salomepython_DATA, idlMakefilePACO_salomeidl_DATA
+from module_generator.cata_tmpl import idlMakefilePACO_INCLUDES
+from module_generator.cata_tmpl import cataOutStream, cataInStream, cataOutparam, cataInparam
+from module_generator.cata_tmpl import cataOutParallelStream, cataInParallelStream
+from module_generator.cata_tmpl import cataService, cataCompo
#from aster_tmpl import check_aster
-from salomemodules import salome_modules
-from yacstypes import corbaTypes, corbaOutTypes, moduleTypes, idlTypes, corba_in_type, corba_out_type
-from yacstypes import ValidTypes, PyValidTypes, calciumTypes, DatastreamParallelTypes
-from yacstypes import ValidImpl, ValidImplTypes, ValidStreamTypes, ValidParallelStreamTypes, ValidDependencies
-from gui_tmpl import cmake_py_gui, pysalomeapp, cmake_cpp_gui, cppsalomeapp
-from doc_tmpl import docmakefile, docconf, docsalomeapp
-import yacsgen_version
+from module_generator.salomemodules import salome_modules
+from module_generator.yacstypes import corbaTypes, corbaOutTypes, moduleTypes, idlTypes, corba_in_type, corba_out_type
+from module_generator.yacstypes import ValidTypes, PyValidTypes, calciumTypes, DatastreamParallelTypes
+from module_generator.yacstypes import ValidImpl, ValidImplTypes, ValidStreamTypes, ValidParallelStreamTypes, ValidDependencies
+from module_generator.gui_tmpl import cmake_py_gui, pysalomeapp, cmake_cpp_gui, cppsalomeapp
+from module_generator.doc_tmpl import docmakefile, docconf, docsalomeapp
+from module_generator import yacsgen_version
def makedirs(namedir):
"""Create a new directory named namedir. If a directory already exists copy it to namedir.bak"""
self.gui = gui
try:
self.validate()
- except Invalid,e:
+ except Invalid as e:
if debug:
traceback.print_exc()
- print "Error in module %s: %s" % (name,e)
+ print("Error in module %s: %s" % (name,e))
raise SystemExit
def validate(self):
cmake_vars = cmake_vars + salome_modules[mod]["linklibs"]
else:
default_lib = var_template.substitute(name=mod)
- print "Unknown libraries for module " + mod
- print "Using default library name " + default_lib
+ print("Unknown libraries for module " + mod)
+ print("Using default library name " + default_lib)
cmake_vars = cmake_vars + default_lib + "\n "
return cmake_text, cmake_vars
"""
def get_dependent_modules(mod,modules):
modules.add(mod)
- if salome_modules[mod].has_key("depends"):
+ if "depends" in salome_modules[mod]:
for m in salome_modules[mod]["depends"]:
if m not in modules:
get_dependent_modules(m,modules)
>>> s1 = module_generator.Service('myservice', inport=[("a","double"),],
instream=[("aa","CALCIUM_double","I")],
- body="print a")
+ body="print( a)")
"""
srcs[compo.name] = fdict
cmakecontent = ""
- components_string = "".join(map(lambda x: x.name+" ", module.components))
+ components_string = "".join([x.name+" " for x in module.components])
if self.module.gui:
GUIname=module.name+"GUI"
cmake_gui="OFF"
prefix = os.path.abspath(self.module.prefix)
- component_libs = "".join(map(lambda x: x.libraryName()+" ",
- module.components))
+ component_libs = "".join([x.libraryName()+" " for x in module.components])
add_modules = ""
for x in self.used_modules:
cmake_text = cmake_find_module.substitute(module=x)
# other_sks=other_sks+os.path.splitext(os.path.basename(fidl))[0]+"SK.cc "
include_template=Template("$${${module}_ROOT_DIR}/idl/salome")
- opt_inc="".join(map(lambda x:include_template.substitute(module=x)+"\n ",
- self.used_modules))
+ opt_inc="".join([include_template.substitute(module=x)+"\n " for x in self.used_modules])
link_template=Template("$${${module}_SalomeIDL${module}}")
- opt_link="".join(map(lambda x:link_template.substitute(module=x)+"\n ",
- self.used_modules))
+ opt_link="".join([link_template.substitute(module=x)+"\n " for x in self.used_modules])
idlfiles={"CMakeLists.txt":cmake_idl.substitute(module=module.name,
extra_idl=other_idls,
elif src[-3:]==".ui":
ui_files=ui_files+os.path.basename(src)+"\n "
elif src[-3:]==".ts":
- ts_files=ts_files+os.path.basename(src)+"\n "
+ ts_files = ts_files + os.path.basename(src) + "\n "
else:
other=other+os.path.basename(src)+"\n "
- compo_dirs = "".join(map(lambda x:
- "${PROJECT_SOURCE_DIR}/src/"+x.name+"\n ",
- self.module.components))
+ compo_dirs = "".join(["${PROJECT_SOURCE_DIR}/src/"+x.name+"\n " for x in self.module.components])
compo_dirs = compo_dirs + "${PROJECT_BINARY_DIR}/src/" + self.module.name + "GUI\n"
- component_libs = "".join(map(lambda x:
- x.libraryName()+" ", self.module.components))
+ component_libs = "".join([x.libraryName()+" " for x in self.module.components])
makefile=cmake_cpp_gui.substitute(module=self.module.name,
include_dirs=compo_dirs,
libs=component_libs,
def makeMakefile(self,makefileItems):
makefile=""
- if makefileItems.has_key("header"):
+ if "header" in makefileItems:
makefile=makefile + makefileItems["header"]+'\n'
- if makefileItems.has_key("lib_LTLIBRARIES"):
+ if "lib_LTLIBRARIES" in makefileItems:
makefile=makefile+"lib_LTLIBRARIES= "+" ".join(makefileItems["lib_LTLIBRARIES"])+'\n'
- if makefileItems.has_key("salomepython_PYTHON"):
+ if "salomepython_PYTHON" in makefileItems:
makefile=makefile+"salomepython_PYTHON= "+" ".join(makefileItems["salomepython_PYTHON"])+'\n'
- if makefileItems.has_key("dist_salomescript_SCRIPTS"):
+ if "dist_salomescript_SCRIPTS" in makefileItems:
makefile=makefile+"dist_salomescript_SCRIPTS= "+" ".join(makefileItems["dist_salomescript_SCRIPTS"])+'\n'
- if makefileItems.has_key("salomeres_DATA"):
+ if "salomeres_DATA" in makefileItems:
makefile=makefile+"salomeres_DATA= "+" ".join(makefileItems["salomeres_DATA"])+'\n'
- if makefileItems.has_key("salomeinclude_HEADERS"):
+ if "salomeinclude_HEADERS" in makefileItems:
makefile=makefile+"salomeinclude_HEADERS= "+" ".join(makefileItems["salomeinclude_HEADERS"])+'\n'
- if makefileItems.has_key("body"):
+ if "body" in makefileItems:
makefile=makefile+makefileItems["body"]+'\n'
return makefile
# For PaCO++
def makexml(self):
- from pacocompo import PACOComponent
+ from .pacocompo import PACOComponent
interfaces = []
for compo in self.module.components:
if isinstance(compo, PACOComponent):
dic key = file name to create
dic value = file content or dictionary defining the content of a sub directory
"""
- for name, content in dic.items():
+ for name, content in list(dic.items()):
filename = os.path.join(basedir, name)
- if isinstance(content, basestring):
- if isinstance(content, unicode):
- # encodage to utf-8 if unicode string
- content=content.encode('utf8')
- fil = open(filename, 'w')
- fil.write(content)
- fil.close()
+ if isinstance(content, str):
+ # encodage to utf-8 if unicode string / on python3 str are unicode
+ with open(filename, 'w') as fil:
+ fil.write(content)
else:
if not os.path.exists(filename):
os.makedirs(filename)
modules = []
if restrict:
for mod in restrict:
- if modules_dict.has_key(mod):
+ if mod in modules_dict:
modules.append(modules_dict[mod])
else:
- modules = modules_dict.values()
+ modules = list(modules_dict.values())
#add the alternate modules if given
if altmodules:
- for module, path in altmodules.items():
+ for module, path in list(altmodules.items()):
modules.append(' <module name="%s" path="%s"/>' % (module, path))
#add the generated module
host = socket.gethostname().split('.')[0]
fil.write(command % host)
fil.close()
-
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
# SalomeApp.xml file for a python gui.
# template parameters:
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
cxxCompo="""
// this cxx file was generated by yacsgen
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
cxxCompo="""
// this cxx file was generated by yacsgen
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
hxxgui_cxx="""
#include "${component_name}GUI.h"
debug=1
import os
-import string
import fnmatch
from tempfile import mkstemp
-from gener import Component, Invalid
-from hxx_tmpl import cxxService, hxxCompo, cxxCompo, cmake_src_compo_hxx
+from module_generator.gener import Component, Invalid
+from module_generator.hxx_tmpl import cxxService, hxxCompo, cxxCompo, cmake_src_compo_hxx
from module_generator import Service
-from yacstypes import corba_rtn_type,moduleTypes
-from hxx_awk import parse01,parse1,parse2,parse3
-from hxx_awk import cpp2idl_mapping
+from module_generator.yacstypes import corba_rtn_type,moduleTypes
+from module_generator.hxx_awk import parse01,parse1,parse2,parse3
+from module_generator.hxx_awk import cpp2idl_mapping
# these tables contain the part of code which depends upon c++ types
-from hxx_awk import cpp_impl_a,cpp_impl_b,cpp_impl_c
-from hxx_awk import cpp2yacs_mapping
+from module_generator.hxx_awk import cpp_impl_a,cpp_impl_b,cpp_impl_c
+from module_generator.hxx_awk import cpp2yacs_mapping
from tempfile import mkdtemp
-from hxx_tmpl_gui import hxxgui_cxx, hxxgui_h, hxxgui_icon_ts
-from hxx_tmpl_gui import hxxgui_message_en, hxxgui_message_fr
-from hxx_tmpl_gui import hxxgui_config, hxxgui_xml_fr, hxxgui_xml_en
-from gener import Library
-from gui_tmpl import cppsalomeapp
+from module_generator.hxx_tmpl_gui import hxxgui_cxx, hxxgui_h, hxxgui_icon_ts
+from module_generator.hxx_tmpl_gui import hxxgui_message_en, hxxgui_message_fr
+from module_generator.hxx_tmpl_gui import hxxgui_config, hxxgui_xml_fr, hxxgui_xml_en
+from module_generator.gener import Library
+from module_generator.gui_tmpl import cppsalomeapp
# ------------------------------------------------------------------------------
f=os.popen(cmd1)
class_name=f.readlines()[0]
name=class_name
- print "classname=",class_name
+ print("classname=",class_name)
f.close()
# create temporary awk files for the parsing
result_parsing=open("parse_type_result","r")
for line in result_parsing.readlines():
line=line[0:-1] # get rid of trailing \n
- words = string.split(line,';')
+ words = line.split(';')
if len(words) >=3 and words[0] == "Function": # detect a new service
function_name=words[2]
# - store it in service_definition[serv]["impl"]
for serv in list_of_services:
if debug:
- print "service : ",serv
- print " inports -> ",service_definition[serv]["inports"]
- print " outports -> ",service_definition[serv]["outports"]
- print " return -> ",service_definition[serv]["ret"]
+ print("service : ",serv)
+ print(" inports -> ",service_definition[serv]["inports"])
+ print(" outports -> ",service_definition[serv]["outports"])
+ print(" return -> ",service_definition[serv]["ret"])
# Part 1 : Argument pre-processing
post=""
pre=""
- if string.find(cpp_impl_a[argtype],"auto_ptr" ) != -1 :
+ if cpp_impl_a[argtype].find("auto_ptr" ) != -1 :
# for auto_ptr argument, retrieve the raw pointer behind
post=".get()"
if argtype == "const MEDMEM::MESH&" or \
# Part 3.b : In Argument Post-processing
for (argname,argtype) in service_definition[serv]["inports"]:
# not all in types require a treatment
- if cpp_impl_c.has_key(argtype):
+ if argtype in cpp_impl_c:
format=cpp_impl_c[argtype]
# id : treatment of %(module) is postponed in makecxx
s_argument_postprocessing += \
s_argument_postprocessing + \
s_rtn_processing
if debug:
- print "implementation :\n",service_definition[serv]["impl"]
+ print("implementation :\n",service_definition[serv]["impl"])
#
# Create a list of Service objects (called services),
code=service_definition[serv]["impl"]
if debug:
- print "service : ",serv
- print " inports -> ",service_definition[serv]["inports"]
- print " converted inports -> ",inports
- print " outports -> ",service_definition[serv]["outports"]
- print " converted outports -> ",outports
- print " Return -> ",service_definition[serv]["ret"]
- print " converted Return -> ",Return
+ print("service : ",serv)
+ print(" inports -> ",service_definition[serv]["inports"])
+ print(" converted inports -> ",inports)
+ print(" outports -> ",service_definition[serv]["outports"])
+ print(" converted outports -> ",outports)
+ print(" Return -> ",service_definition[serv]["ret"])
+ print(" converted Return -> ",Return)
services.append(Service(serv,
inport=inports,
defs = []
for serv in self.services:
defs.append(serv.defs)
- print "CNC bug : ",serv.body
+ print("CNC bug : ",serv.body)
service = cxxService.substitute(
component=self.name,
service=serv.name,
def getIdlInterfaces(self):
services = self.getIdlServices()
- from hxx_tmpl import interfaceidlhxx
+ from .hxx_tmpl import interfaceidlhxx
Inherited=""
if self.use_medmem==True:
Inherited="Engines::EngineComponent,SALOME::MultiCommClass,SALOME_MED::MED_Gen_Driver"
debug=1
import os
-from gener import Component, Invalid
-from hxx_para_tmpl import cxxService, hxxCompo, cxxCompo, cmake_src_compo_hxxpara
+from module_generator.gener import Component, Invalid
+from module_generator.hxx_para_tmpl import cxxService, hxxCompo, cxxCompo, cmake_src_compo_hxxpara
from module_generator import Service
-import string
from tempfile import mkstemp
-from yacstypes import corba_rtn_type,moduleTypes
-from gener import Library
+from module_generator.yacstypes import corba_rtn_type,moduleTypes
+from module_generator.gener import Library
class HXX2SALOMEParaComponent(Component):
def __init__(self, hxxfile , cpplib , cpp_path ):
self.hxxfile=hxxfile # to include it in servant implementation
# grab name of c++ component
- from hxx_awk import parse01,parse1,parse2,parse3
+ from .hxx_awk import parse01,parse1,parse2,parse3
cmd1="""awk '$1 == "class" && $0 !~ /;/ {print $2}' """ + hxxfileful[0] + """|awk -F: '{printf "%s",$1}' """
f=os.popen(cmd1)
class_name=f.readlines()[0]
name=class_name
- print "classname=",class_name
+ print("classname=",class_name)
if cpplib[:3]=="lib" and cpplib[-3:]==".so":
cpplibname=cpplib[3:-3] # get rid of lib and .so, to use within makefile.am
# ...
# The service names are stored in list_of_services
# The information relative to a service (called service_name) is stored in the dictionnary service_definition[service_name]
- from hxx_awk import cpp2idl_mapping
- from hxx_awk import cpp2yacs_mapping
+ from .hxx_awk import cpp2idl_mapping
+ from .hxx_awk import cpp2yacs_mapping
cpp2yacs_mapping["const MEDCoupling::MEDCouplingFieldDouble*"]="SALOME_MED/MPIMEDCouplingFieldDoubleCorbaInterface"
cpp2yacs_mapping["const MEDCoupling::MEDCouplingFieldDouble&"]="SALOME_MED/MPIMEDCouplingFieldDoubleCorbaInterface"
cpp2yacs_mapping["MEDCoupling::MEDCouplingFieldDouble*&"]="SALOME_MED/MPIMEDCouplingFieldDoubleCorbaInterface"
result_parsing=open("parse_type_result","r")
for line in result_parsing.readlines():
line=line[0:-1] # get rid of trailing \n
- words = string.split(line,';')
+ words = line.split(';')
if len(words) >=3 and words[0] == "Function": # detect a new service
function_name=words[2]
else:
service_definition[list_of_services[-1]]["outports"].append( (argname,typename) )
- if service_definition.has_key('getInputFieldTemplate'):
+ if 'getInputFieldTemplate' in service_definition:
del service_definition['getInputFieldTemplate']
#
# generate implementation of c++ servant
# store it in service_definition[serv]["impl"]
#
- from hxx_awk import cpp_impl_a,cpp_impl_b,cpp_impl_c # these tables contain the part of code which depends upon c++ types
+ from .hxx_awk import cpp_impl_a,cpp_impl_b,cpp_impl_c # these tables contain the part of code which depends upon c++ types
cpp_impl_b["MEDCoupling::MEDCouplingFieldDouble*"]="""\tMEDCoupling::MPIMEDCouplingFieldDoubleServant * _rtn_field_i = new MEDCoupling::MPIMEDCouplingFieldDoubleServant(_orb,_poa,this,_rtn_cpp);
\t_rtn_cpp->decrRef();
\tSALOME_MED::MPIMEDCouplingFieldDoubleCorbaInterface_ptr _rtn_ior = _rtn_field_i->_this();\n"""
cpp_impl_a["const MEDCoupling::MEDCouplingFieldDouble*"]="\tMEDCoupling::MEDCouplingFieldDouble* _%(arg)s=cppCompo_->getInputFieldTemplate();\n\t_setInputField(%(arg)s,_%(arg)s);\n\t_initializeCoupling(%(arg)s);\n"
- from yacstypes import corbaTypes,corbaOutTypes
+ from .yacstypes import corbaTypes,corbaOutTypes
format_thread_signature="void * th_%s(void * st);" # this thread declaration will be included in servant's header
format_thread_struct="typedef struct {\n int ip;\n Engines::IORTab* tior;\n%(arg_decl)s} thread_%(serv_name)s_str;" # this thread declaration will be included in servant's header
format_thread_create="""
self.thread_impl="" # the implementation of the thread functions used to invoque services on slave processors
for serv in list_of_services:
if debug:
- print "service : ",serv
- print " inports -> ",service_definition[serv]["inports"]
- print " outports -> ",service_definition[serv]["outports"]
- print " return -> ",service_definition[serv]["ret"]
+ print("service : ",serv)
+ print(" inports -> ",service_definition[serv]["inports"])
+ print(" outports -> ",service_definition[serv]["outports"])
+ print(" return -> ",service_definition[serv]["ret"])
# Part 0 : specific treatments for parallel components (call threads to forward the invocation to the service to all processes)
service_definition[serv]["thread_func_decl"]=format_thread_signature % serv
# special treatment for some arguments
post=""
pre=""
- if string.find(cpp_impl_a[argtype],"auto_ptr" ) != -1 :
+ if cpp_impl_a[argtype].find("auto_ptr" ) != -1 :
post=".get()" # for auto_ptr argument, retrieve the raw pointer behind
if argtype == "const MEDMEM::MESH&" or argtype == "const MEDMEM::SUPPORT&" :
pre="*" # we cannot create MESHClient on the stack (private constructor), so we create it on the heap and dereference it
# because we don't know here the module name
# Part 3.b : In Argument Post-processing
for (argname,argtype) in service_definition[serv]["inports"]:
- if cpp_impl_c.has_key(argtype): # not all in types require a treatment
+ if argtype in cpp_impl_c: # not all in types require a treatment
format=cpp_impl_c[argtype]
s_argument_postprocessing += format % {"arg" : argname, "module" : "%(module)s" } # id : treatment of %(module) is postponed in makecxx
service_definition[serv]["impl"] = s_thread_call + s_argument_processing + s_call_cpp_function + s_thread_join + s_argument_postprocessing + s_rtn_processing
if debug:
- print "implementation :\n",service_definition[serv]["impl"]
+ print("implementation :\n",service_definition[serv]["impl"])
#
# Create a list of Service objects (called services), and give it to Component constructor
code=service_definition[serv]["impl"]
if debug:
- print "service : ",serv
- print " inports -> ",service_definition[serv]["inports"]
- print " converted inports -> ",inports
- print " outports -> ",service_definition[serv]["outports"]
- print " converted outports -> ",outports
- print " Return -> ",service_definition[serv]["ret"]
- print " converted Return -> ",Return
+ print("service : ",serv)
+ print(" inports -> ",service_definition[serv]["inports"])
+ print(" converted inports -> ",inports)
+ print(" outports -> ",service_definition[serv]["outports"])
+ print(" converted outports -> ",outports)
+ print(" Return -> ",service_definition[serv]["ret"])
+ print(" converted Return -> ",Return)
services.append(Service(serv,
inport=inports,
thread_func_decl="\n".join(self.thread_func_decl)
thread_str_decl="\n".join(self.thread_str_decl)
if debug:
- print "thread_func_decl : "
- print thread_func_decl
- print "thread_str_decl : "
- print thread_str_decl
+ print("thread_func_decl : ")
+ print(thread_func_decl)
+ print("thread_str_decl : ")
+ print(thread_str_decl)
if self.inheritedclass:
inheritedclass= " public virtual " + self.inheritedclass + ","
def getIdlInterfaces(self):
services = self.getIdlServices()
- from hxx_tmpl import interfaceidlhxx
+ from .hxx_tmpl import interfaceidlhxx
Inherited=""
Inherited="SALOME_MED::ParaMEDMEMComponent"
return interfaceidlhxx.substitute(component=self.name,inherited=Inherited, services="\n".join(services))
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
application="""
<application>
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
# cxx file of a MPI component.
# template parameters:
"""
import os
-from gener import Component, Invalid
-from cpp_tmpl import initService, cxxService, hxxCompo, cxxCompo
-from cpp_tmpl import exeCPP, cmake_src_compo_cpp
-from yacstypes import corba_rtn_type, corba_in_type
-import mpi_tmpl
-from cppcompo import CPPComponent
+from module_generator.gener import Component, Invalid
+from module_generator.cpp_tmpl import initService, cxxService, hxxCompo, cxxCompo
+from module_generator.cpp_tmpl import exeCPP, cmake_src_compo_cpp
+from module_generator.yacstypes import corba_rtn_type, corba_in_type
+from module_generator import mpi_tmpl
+from module_generator.cppcompo import CPPComponent
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
class MPIComponent(CPPComponent):
"""
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
compoMakefile="""
include $$(top_srcdir)/adm_local/make_common_starter.am
Module that defines PACOComponent for SALOME PaCO++ components implemented in C++
"""
import os
-from gener import Component, Invalid
-from paco_tmpl import compoMakefile, hxxCompo, cxxService
-from paco_tmpl import initService, cxxCompo, paco_sources
-from paco_tmpl import cxxFactoryDummy, cxxFactoryMpi, cxx_des_parallel_stream
-from paco_tmpl import hxxparallel_instream, hxxparallel_outstream, hxxinit_ok
-from paco_tmpl import hxxparallel_instream_init, hxxparallel_outstream_init, cxxService_connect
-from paco_tmpl import cxx_cons_service, cxx_cons_parallel_outstream, cxx_cons_parallel_instream
-from cata_tmpl import parallel_interface
+from module_generator.gener import Component, Invalid
+from module_generator.paco_tmpl import compoMakefile, hxxCompo, cxxService
+from module_generator.paco_tmpl import initService, cxxCompo, paco_sources
+from module_generator.paco_tmpl import cxxFactoryDummy, cxxFactoryMpi, cxx_des_parallel_stream
+from module_generator.paco_tmpl import hxxparallel_instream, hxxparallel_outstream, hxxinit_ok
+from module_generator.paco_tmpl import hxxparallel_instream_init, hxxparallel_outstream_init, cxxService_connect
+from module_generator.paco_tmpl import cxx_cons_service, cxx_cons_parallel_outstream, cxx_cons_parallel_instream
+from module_generator.cata_tmpl import parallel_interface
class PACOComponent(Component):
Module that defines PYComponent for SALOME components implemented in Python
"""
import os
-from gener import Component, Invalid
-from pyth_tmpl import pyinitService, pyService, pyCompoEXE, pyCompo, cmake_src_compo_py
+from module_generator.gener import Component, Invalid
+from module_generator.pyth_tmpl import pyinitService, pyService, pyCompoEXE, pyCompo, cmake_src_compo_py
import textwrap
-from string import split,rstrip,join
def indent(text, prefix=' '):
"""Indent text by prepending a given prefix to each line."""
if not text: return ''
- lines = split(text, '\n')
- lines = map(lambda line, prefix=prefix: prefix + line, lines)
- if lines: lines[-1] = rstrip(lines[-1])
- return join(lines, '\n')
+ lines = text.split('\n')
+ lines = list(map(lambda line, prefix=prefix: prefix + line, lines))
+ if lines: lines[-1] = lines[-1].rstrip()
+ return '\n'.join(lines)
class PYComponent(Component):
"""
raise Invalid("Invalid kind ()%s for component %s" % (
self.kind, self.name))
- sources = pyfile + "".join(map(lambda x: "\n " + os.path.basename(x),
- self.sources))
+ sources = pyfile + "".join(["\n " + os.path.basename(x) for x in self.sources])
cmake_content = cmake_src_compo_py.substitute(sources=sources)
return {"CMakeLists.txt":cmake_content,
if typ=="file":continue #files are not passed through service interface
params.append(name)
if typ == "pyobj":
- pyparams.append(" %s=cPickle.loads(%s)" %(name, name))
+ pyparams.append(" %s=pickle.loads(%s)" %(name, name))
inparams = ",".join(params)
convertinparams = '\n'.join(pyparams)
if typ=="file":continue #files are not passed through service interface
params.append(name)
if typ == "pyobj":
- pyparams.append(" %s=cPickle.dumps(%s,-1)" %(name, name))
+ pyparams.append(" %s=pickle.dumps(%s,-1)" %(name, name))
outparams = ",".join(params)
convertoutparams = '\n'.join(pyparams)
#dedent and indent the body
if typ=="file":continue #files are not passed through service interface
params.append(name)
if typ == "pyobj":
- pyparams.append(" %s=cPickle.loads(%s)" %(name, name))
+ pyparams.append(" %s=pickle.loads(%s)" %(name, name))
inparams = ",".join(params)
convertinparams = '\n'.join(pyparams)
if typ=="file":continue #files are not passed through service interface
params.append(name)
if typ == "pyobj":
- pyparams.append(" %s=cPickle.dumps(%s,-1)" %(name, name))
+ pyparams.append(" %s=pickle.dumps(%s,-1)" %(name, name))
outparams = ",".join(params)
convertoutparams = '\n'.join(pyparams)
#dedent and indent the body
try:
from string import Template
except:
- from compat import Template,set
+ from module_generator.compat import Template,set
pyCompo="""
import sys,traceback,os
import dsccalcium
import SALOME
import Engines
-import cPickle
+import pickle
try:
import numpy
if __name__ == '__main__':
from omniORB import CORBA
- print sys.argv
+ print( sys.argv)
orb = CORBA.ORB_init(sys.argv, CORBA.ORB_ID)
poa = orb.resolve_initial_references("RootPOA")
- print "ORB and POA initialized",orb,poa
+ print( "ORB and POA initialized",orb,poa)
sys.stdout.flush()
sys.stderr.flush()
compo=${component}(orb,poa,container,containerName, instanceName, "${component}")
comp_o = compo._this()
comp_iors = orb.object_to_string(comp_o)
- print "ior ${component}",comp_iors
+ print( "ior ${component}",comp_iors)
sys.stdout.flush()
sys.stderr.flush()
poaManager.activate()
orb.run()
- print "fin du composant ${component} standalone"
+ print( "fin du composant ${component} standalone")
"""
# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-major_version=8
-minor_version=5
+major_version=9
+minor_version=1
patch_version=0
complete_version="%d.%d.%d" % (major_version, minor_version, patch_version)
else:
return corbaRtnTypes[typ]
-ValidTypes = corbaTypes.keys()
+ValidTypes = list(corbaTypes.keys())
PyValidTypes = ValidTypes+["pyobj"]
def add_type(typename, corbaType=None, corbaOutType=None, module="", idltype=None, corbaRtnType=None):
ValidImpl = ("CPP", "PY", "F77", "ASTER", "PACO")
ValidImplTypes = ("sequential", "parallel")
-ValidStreamTypes = calciumTypes.keys()
-ValidParallelStreamTypes = DatastreamParallelTypes.keys()
+ValidStreamTypes = list(calciumTypes.keys())
+ValidParallelStreamTypes = list(DatastreamParallelTypes.keys())
ValidDependencies = ("I", "T")
#Add KERNEL YACS types : YACS name, c++ corba arg in, c++ corba arg out,defining module, repr corba idl, c++ corba return
# Make sure given paths/files are valid
if not os.path.exists(cppdir):
- print "ERROR: cppdir %s does not exist. It is mandatory" % cppdir
- print usage
+ print("ERROR: cppdir %s does not exist. It is mandatory" % cppdir)
+ print(usage)
sys.exit(1)
if not os.path.exists(installpath):
- print "ERROR: installpath %s does not exist. It is mandatory" \
- % installpath
- print usage
+ print("ERROR: installpath %s does not exist. It is mandatory" \
+ % installpath)
+ print(usage)
sys.exit(1)
if options.environ_file != None:
if not os.path.exists(options.environ_file):
- print "ERROR: environ_file %s does not exist. It is mandatory" \
- % options.environ_file
- print usage
+ print("ERROR: environ_file %s does not exist. It is mandatory" \
+ % options.environ_file)
+ print(usage)
sys.exit(1)
hxx2salome(cppdir=cppdir,
try:
os.mkdir(install_root_dir)
except OSError:
- print "Warning : directory %s already exixts!" % install_root_dir
+ print("Warning : directory %s already exixts!" % install_root_dir)
# if a graphical user interface is required,
# ask HXX2SALOMEComponent to generate template files