From 900f9c20d397521c0259abf7e0fae7e80caedcec Mon Sep 17 00:00:00 2001 From: Ovidiu Mircescu Date: Fri, 27 Jul 2018 09:42:34 +0200 Subject: [PATCH] Python3 porting for calcium. --- module_generator/astcompo.py | 12 +++++----- module_generator/aster_tmpl.py | 44 +++++++++++++++++----------------- module_generator/gener.py | 2 +- module_generator/pycompo.py | 8 +++---- module_generator/pyth_tmpl.py | 10 ++++---- 5 files changed, 38 insertions(+), 38 deletions(-) diff --git a/module_generator/astcompo.py b/module_generator/astcompo.py index d6372ba..03762c9 100644 --- a/module_generator/astcompo.py +++ b/module_generator/astcompo.py @@ -220,7 +220,7 @@ from Execution.E_SUPERV import SUPERV 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 @@ -234,7 +234,7 @@ from Execution.E_SUPERV import SUPERV 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) @@ -283,7 +283,7 @@ from Execution.E_SUPERV import SUPERV 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 @@ -296,7 +296,7 @@ from Execution.E_SUPERV import SUPERV 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) @@ -354,7 +354,7 @@ from Execution.E_SUPERV import SUPERV 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 @@ -367,7 +367,7 @@ from Execution.E_SUPERV import SUPERV 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) diff --git a/module_generator/aster_tmpl.py b/module_generator/aster_tmpl.py index 91f7d71..47f77a6 100644 --- a/module_generator/aster_tmpl.py +++ b/module_generator/aster_tmpl.py @@ -191,9 +191,9 @@ asterService=""" 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)) @@ -223,14 +223,14 @@ asterService=""" 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() @@ -242,9 +242,9 @@ asterService=""" 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)) @@ -256,9 +256,9 @@ asterService=""" 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: @@ -380,15 +380,15 @@ from SALOME_ContainerPy import SALOME_ContainerPy_i 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() @@ -398,7 +398,7 @@ if __name__ == '__main__': #Block for ever orb.run() - print "fin container aster" + print( "fin container aster") sys.stdout.flush() sys.stderr.flush() """ @@ -409,10 +409,10 @@ from ${component}_module import ${component} 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() @@ -423,7 +423,7 @@ if __name__ == '__main__': 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() @@ -433,7 +433,7 @@ if __name__ == '__main__': poaManager.activate() orb.run() - print "fin du composant aster standalone" + print( "fin du composant aster standalone") """ component=Template(component) diff --git a/module_generator/gener.py b/module_generator/gener.py index e32442f..17934a1 100644 --- a/module_generator/gener.py +++ b/module_generator/gener.py @@ -294,7 +294,7 @@ class Service(object): >>> s1 = module_generator.Service('myservice', inport=[("a","double"),], instream=[("aa","CALCIUM_double","I")], - body="print a") + body="print( a)") """ diff --git a/module_generator/pycompo.py b/module_generator/pycompo.py index 74218d2..f97bf8d 100644 --- a/module_generator/pycompo.py +++ b/module_generator/pycompo.py @@ -118,7 +118,7 @@ class PYComponent(Component): 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) @@ -128,7 +128,7 @@ class PYComponent(Component): 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 @@ -182,7 +182,7 @@ class PYComponent(Component): 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) @@ -192,7 +192,7 @@ class PYComponent(Component): 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 diff --git a/module_generator/pyth_tmpl.py b/module_generator/pyth_tmpl.py index a5d86a1..bc7348b 100644 --- a/module_generator/pyth_tmpl.py +++ b/module_generator/pyth_tmpl.py @@ -30,7 +30,7 @@ import calcium import dsccalcium import SALOME import Engines -import cPickle +import pickle try: import numpy @@ -70,10 +70,10 @@ pyCompoEXE="""#!/usr/bin/env python 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() @@ -84,7 +84,7 @@ if __name__ == '__main__': 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() @@ -94,7 +94,7 @@ if __name__ == '__main__': poaManager.activate() orb.run() - print "fin du composant ${component} standalone" + print( "fin du composant ${component} standalone") """ -- 2.39.2