Salome HOME
updated copyright message
[samples/pycalculator.git] / src / PYCALCULATOR / PYCALCULATOR.py
old mode 100755 (executable)
new mode 100644 (file)
index 4ad9a14..3505882
@@ -1,4 +1,4 @@
-# Copyright (C) 2007-2016  CEA/DEN, EDF R&D, OPEN CASCADE
+# Copyright (C) 2007-2023  CEA/DEN, EDF R&D, OPEN CASCADE
 #
 # Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
 # CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 # This is necessary to ensure that different modules will have the same definition
 # of dynamic types and C++ RTTI will work between them
 #
-import DLFCN, sys
-sys.setdlopenflags(DLFCN.RTLD_NOW | DLFCN.RTLD_GLOBAL)
+import os, sys
+sys.setdlopenflags(os.RTLD_NOW | os.RTLD_GLOBAL)
 
 import PYCALCULATOR_ORB__POA
 import SALOME_ComponentPy
+import SALOME_Embedded_NamingService_ClientPy
 
 import SALOME_MED
 from MEDCouplingClient import *
@@ -47,7 +48,7 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA
     def __init__(self, orb, poa, contID, containerName, instanceName,
                  interfaceName):
 
-        if verbose(): print "Begin of PYCALCULATOR::__init__"
+        if verbose(): print("Begin of PYCALCULATOR::__init__")
 
         SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(
             self,
@@ -58,10 +59,15 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA
             instanceName,     # component instance name
             interfaceName,    # component interface name
             False)            # notification flag (for notification server)
+        
+        emb_ns = self._contId.get_embedded_NS_if_ssl()
+        import CORBA
+        if CORBA.is_nil(emb_ns):
+            self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i( self._orb )
+        else:
+            self._naming_service = SALOME_Embedded_NamingService_ClientPy.SALOME_Embedded_NamingService_ClientPy(emb_ns)
 
-       self._naming_service = SALOME_ComponentPy.SALOME_NamingServicePy_i(self._orb)
-
-        if verbose(): print "End of PYCALCULATOR::__init__"
+        if verbose(): print("End of PYCALCULATOR::__init__")
 
         pass
 
@@ -75,8 +81,8 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA
         self.beginService("PYCALCULATOR::Clone")
 
         if verbose(): 
-            print "Begin of PYCALCULATOR::Clone"
-            print "            field : ", field
+            print("Begin of PYCALCULATOR::Clone")
+            print("            field : ", field)
             pass
 
         frescorba = None
@@ -88,12 +94,12 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA
             # create CORBA field
             frescorba = MEDCouplingFieldDoubleServant._this(f)
             
-        except Exception, e:
-            if verbose(): print e
+        except Exception as e:
+            if verbose(): print(e)
             pass
         
         if verbose(): 
-            print "End of PYCALCULATOR::Clone"
+            print("End of PYCALCULATOR::Clone")
             pass
         
         self.endService("PYCALCULATOR::Clone")
@@ -105,9 +111,9 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA
         self.beginService("PYCALCULATOR::Add")
 
         if verbose(): 
-            print "Begin of PYCALCULATOR::Add"
-            print "            field 1 : ", field1
-            print "            field 2 : ", field2
+            print("Begin of PYCALCULATOR::Add")
+            print("            field 1 : ", field1)
+            print("            field 2 : ", field2)
             pass
 
         frescorba = None
@@ -124,12 +130,12 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA
             # create CORBA field
             frescorba = MEDCouplingFieldDoubleServant._this(fres)
             
-        except Exception, e:
-            if verbose(): print e
+        except Exception as e:
+            if verbose(): print(e)
             pass
         
         if verbose(): 
-            print "End of PYCALCULATOR::Add"
+            print("End of PYCALCULATOR::Add")
             pass
         
         self.endService("PYCALCULATOR::Add")
@@ -141,9 +147,9 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA
         self.beginService("PYCALCULATOR::Mul")
 
         if verbose(): 
-            print "Begin of PYCALCULATOR::Mul"
-            print "            field 1 : ", field1
-            print "            field 2 : ", field2
+            print("Begin of PYCALCULATOR::Mul")
+            print("            field 1 : ", field1)
+            print("            field 2 : ", field2)
             pass
 
         frescorba = None
@@ -160,12 +166,12 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA
             # create CORBA field
             frescorba = MEDCouplingFieldDoubleServant._this(fres)
             
-        except Exception, e:
-            if verbose(): print e
+        except Exception as e:
+            if verbose(): print(e)
             pass
         
         if verbose(): 
-            print "End of PYCALCULATOR::Mul"
+            print("End of PYCALCULATOR::Mul")
             pass
         
         self.endService("PYCALCULATOR::Mul")
@@ -177,9 +183,9 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA
         self.beginService("PYCALCULATOR::AddConstant")
 
         if verbose(): 
-            print "Begin of PYCALCULATOR::AddConstant"
-            print "            field    : ", field
-            print "            constant : ", val
+            print("Begin of PYCALCULATOR::AddConstant")
+            print("            field    : ", field)
+            print("            constant : ", val)
             pass
 
         frescorba = None
@@ -194,12 +200,12 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA
             # create CORBA field
             frescorba = MEDCouplingFieldDoubleServant._this(fres)
             
-        except Exception, e:
-            if verbose(): print e
+        except Exception as e:
+            if verbose(): print(e)
             pass
         
         if verbose(): 
-            print "End of PYCALCULATOR::AddConstant"
+            print("End of PYCALCULATOR::AddConstant")
             pass
         
         self.endService("PYCALCULATOR::AddConstant")
@@ -211,9 +217,9 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA
         self.beginService("PYCALCULATOR::MulConstant")
 
         if verbose(): 
-            print "Begin of PYCALCULATOR::MulConstant"
-            print "            field    : ", field
-            print "            constant : ", val
+            print("Begin of PYCALCULATOR::MulConstant")
+            print("            field    : ", field)
+            print("            constant : ", val)
             pass
 
         frescorba = None
@@ -228,12 +234,12 @@ class PYCALCULATOR(PYCALCULATOR_ORB__POA.PYCALCULATOR_Gen, SALOME_ComponentPy.SA
             # create CORBA field
             frescorba = MEDCouplingFieldDoubleServant._this(fres)
             
-        except Exception, e:
-            if verbose(): print e
+        except Exception as e:
+            if verbose(): print(e)
             pass
         
         if verbose(): 
-            print "End of PYCALCULATOR::MulConstant"
+            print("End of PYCALCULATOR::MulConstant")
             pass
         
         self.endService("PYCALCULATOR::MulConstant")