From 2d2e0eb0f3408dcc0efa7a70431dbf210d2dcd94 Mon Sep 17 00:00:00 2001 From: Ovidiu Mircescu Date: Tue, 24 Jul 2018 14:01:26 +0200 Subject: [PATCH] Python3 porting for Examples. --- Examples/calcium1/components.py | 86 +++++++++++++++---------------- Examples/calcium2/components.py | 86 +++++++++++++++---------------- Examples/cppgui1/components.py | 4 +- Examples/cppgui1/cppcomposGUI.cxx | 8 ++- Examples/exec.sh | 3 +- Examples/pygui1/components.py | 2 +- Examples/pyth1/components.py | 4 +- Examples/pyth2/components.py | 4 +- Examples/types1/components.py | 6 +-- 9 files changed, 101 insertions(+), 102 deletions(-) diff --git a/Examples/calcium1/components.py b/Examples/calcium1/components.py index 3f81f37..995e506 100644 --- a/Examples/calcium1/components.py +++ b/Examples/calcium1/components.py @@ -243,8 +243,8 @@ defs=""" body=""" #b1 info,name= calcium.cp_cd(component) -print "name=",name -print "info=",info +print ("name=",name) +print ("info=",info) dep=calcium.CP_ITERATION @@ -253,7 +253,7 @@ val=numpy.zeros(10,'d') 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) @@ -264,124 +264,124 @@ val=calcium.stringArray(3,8) 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) @@ -389,7 +389,7 @@ 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")], diff --git a/Examples/calcium2/components.py b/Examples/calcium2/components.py index c6fd48b..30537ed 100644 --- a/Examples/calcium2/components.py +++ b/Examples/calcium2/components.py @@ -242,8 +242,8 @@ defs=""" 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 @@ -251,7 +251,7 @@ val=numpy.zeros(10,'d') 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) @@ -262,124 +262,124 @@ val=calcium.stringArray(3,8) 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) @@ -387,7 +387,7 @@ 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")], diff --git a/Examples/cppgui1/components.py b/Examples/cppgui1/components.py index 3300bac..39c98c5 100644 --- a/Examples/cppgui1/components.py +++ b/Examples/cppgui1/components.py @@ -41,12 +41,12 @@ public: 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;}; diff --git a/Examples/cppgui1/cppcomposGUI.cxx b/Examples/cppgui1/cppcomposGUI.cxx index e7dec69..47d5ce6 100644 --- a/Examples/cppgui1/cppcomposGUI.cxx +++ b/Examples/cppgui1/cppcomposGUI.cxx @@ -24,6 +24,7 @@ #include #include #include +#include #include #include CORBA_CLIENT_HEADER(cppcompos) @@ -100,10 +101,7 @@ bool cppcomposGUI::activateModule( SUIT_Study* theStudy ) 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()) @@ -117,7 +115,7 @@ bool cppcomposGUI::activateModule( SUIT_Study* theStudy ) aStudyBuilder->DefineComponentInstance(aFather, engine); } CORBA::Boolean valid; - engine->DumpPython(aDSStudy,1,0,valid); + engine->DumpPython(1,0,valid); return bOk; } diff --git a/Examples/exec.sh b/Examples/exec.sh index d035773..d82cb1b 100755 --- a/Examples/exec.sh +++ b/Examples/exec.sh @@ -4,10 +4,11 @@ com=$* # Modify to your SALOME installation -export SALOME_DIR=/local00/home/I35256/salome/install/V7_main_git +export SALOME_DIR=/home/I35256/salome/C9 source $SALOME_DIR/salome_prerequisites.sh source $SALOME_DIR/salome_modules.sh +source $SALOME_DIR/modules/build/YACS_master/.yamm/env_build.sh echo execution: $com $com diff --git a/Examples/pygui1/components.py b/Examples/pygui1/components.py index 45dada3..6b13e7a 100644 --- a/Examples/pygui1/components.py +++ b/Examples/pygui1/components.py @@ -48,7 +48,7 @@ class A(SALOME_DriverPy.SALOME_DriverPy_i): 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: diff --git a/Examples/pyth1/components.py b/Examples/pyth1/components.py index 4e95ae7..ea2b40c 100644 --- a/Examples/pyth1/components.py +++ b/Examples/pyth1/components.py @@ -35,11 +35,11 @@ body=""" 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 diff --git a/Examples/pyth2/components.py b/Examples/pyth2/components.py index 0a2ecbb..3f695e0 100644 --- a/Examples/pyth2/components.py +++ b/Examples/pyth2/components.py @@ -32,11 +32,11 @@ body=""" 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) diff --git a/Examples/types1/components.py b/Examples/types1/components.py index d8484d3..6b2a807 100644 --- a/Examples/types1/components.py +++ b/Examples/types1/components.py @@ -149,7 +149,7 @@ c1=CPPComponent("compo1",services=[ 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] @@ -159,11 +159,11 @@ ad3=[[[[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() """ -- 2.39.2