Salome HOME
Merge remote-tracking branch 'origin/master' into V9_dev
[modules/yacs.git] / src / yacsorb / YACS.py
index 36ca3a2900a2d43e8cf03a8f8a9a0cb05be3eee4..5ce0f7ff68b1797cbe6dd146c0ba407ac5c90b2d 100644 (file)
@@ -1,9 +1,9 @@
-# Copyright (C) 2006-2012  CEA/DEN, EDF R&D
+# Copyright (C) 2006-2016  CEA/DEN, EDF R&D
 #
 # This library is free software; you can redistribute it and/or
 # modify it under the terms of the GNU Lesser General Public
 # License as published by the Free Software Foundation; either
-# version 2.1 of the License.
+# version 2.1 of the License, or (at your option) any later version.
 #
 # This library is distributed in the hope that it will be useful,
 # but WITHOUT ANY WARRANTY; without even the implied warranty of
@@ -46,6 +46,9 @@ class proc_i(YACS_ORB__POA.ProcExec):
     def getNodeState(self,numid):
         return self.p.getNodeState(numid)
 
+    def getNodeProgress(self,numid):
+        return self.p.getNodeProgress(numid)
+
     def getXMLState(self, numid):
         return self.p.getXMLState(numid)
 
@@ -97,9 +100,9 @@ class proc_i(YACS_ORB__POA.ProcExec):
         return self.p.getIds()
 
     def runProc(self,debug, isPyThread, fromscratch):
-      print "**************************Begin schema execution %s**************************" % self.xmlFile
+      print("**************************Begin schema execution %s**************************" % self.xmlFile)
       self.e.RunPy(self.p,debug, isPyThread, fromscratch)
-      print "**************************End schema execution %s****************************" % self.xmlFile
+      print("**************************End schema execution %s****************************" % self.xmlFile)
 
     def Run(self):
         if self.run1 is not None:
@@ -109,7 +112,7 @@ class proc_i(YACS_ORB__POA.ProcExec):
             self.run1 = None
 
         if self.run1 is None:
-            self.run1 = threading.Thread(None, self.runProc, "CORBAExec", (0,1,1))
+            self.run1 = threading.Thread(None, self.runProc, "CORBAExec", (0,True,True))
             self.run1.start()
 
     def RunFromState(self, xmlFile):
@@ -129,21 +132,21 @@ class proc_i(YACS_ORB__POA.ProcExec):
             sp = loader.stateParser()
             sl = loader.stateLoader(sp,self.p)
             sl.parse(xmlFile)
-          except IOError, ex:
-            print "IO Error: ", ex
+          except IOError as ex:
+            print("IO Error: ", ex)
             return
-          except ValueError,ex:
-            print "Caught ValueError Exception:",ex
+          except ValueError as ex:
+            print("Caught ValueError Exception:",ex)
             return
-          except pilot.Exception,ex:
-            print ex.what()
+          except pilot.Exception as ex:
+            print(ex.what())
             return
           except:
-            print "Unknown exception!"
+            print("Unknown exception!")
             return
 
         if self.run1 is None:
-            self.run1 = threading.Thread(None, self.runProc, "CORBAExec", (0,1,0))
+            self.run1 = threading.Thread(None, self.runProc, "CORBAExec", (0,True,False))
             self.run1.start()
 
     def RestartFromState(self, xmlFile):
@@ -172,7 +175,7 @@ class proc_i(YACS_ORB__POA.ProcExec):
             pass
 
         if self.run1 is None:
-            self.run1 = threading.Thread(None, self.runProc, "CORBAExec", (0,1,0))
+            self.run1 = threading.Thread(None, self.runProc, "CORBAExec", (0,True,False))
             self.run1.start()
 
     def addObserver(self, obs, numid, event):
@@ -237,10 +240,10 @@ class YACS(YACS_ORB__POA.YACS_Gen,
     """
     def __init__ ( self, orb, poa, contID, containerName, instanceName,
                    interfaceName ):
-        print "YACS.__init__: ", containerName, ';', instanceName
+        print("YACS.__init__: ", containerName, ';', instanceName)
         SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(self, orb, poa, contID,
                                                          containerName, instanceName,
-                                                         interfaceName, 0)
+                                                         interfaceName, False)
         SALOME_DriverPy.SALOME_DriverPy_i.__init__(self, interfaceName)
 
         # --- store a naming service interface instance in _naming_service atribute
@@ -259,6 +262,18 @@ class YACS(YACS_ORB__POA.YACS_Gen,
         except :
           pass
 
+    """
+    Get version information.
+    """
+    def getVersion( self ):
+        try:
+            rt = SALOMERuntime.getSALOMERuntime()
+            version = rt.getVersion()
+        except:
+            version = ""
+            pass
+        return version
+
     def LoadProc(self,xmlFile):
         """
         load an XML graph in a YACS::ENGINE::proc, create a CORBA servant
@@ -268,18 +283,18 @@ class YACS(YACS_ORB__POA.YACS_Gen,
             procExec_i = proc_i(xmlFile)
             logger=procExec_i.p.getLogger("parser")
             if not logger.isEmpty():
-              print "The imported file has errors :"
-              print logger.getStr()
+              print("The imported file has errors :")
+              print(logger.getStr())
               sys.stdout.flush()
               return None
-        except IOError, ex:
-            print >> sys.stderr ,"IO Error: ", ex
+        except IOError as ex:
+            print("IO Error: ", ex, file=sys.stderr)
             return None
-        except ValueError,ex:
-            print >> sys.stderr ,"Caught ValueError Exception:",ex
+        except ValueError as ex:
+            print("Caught ValueError Exception:",ex, file=sys.stderr)
             return None
-        except pilot.Exception,ex:
-            print >> sys.stderr ,ex.what()
+        except pilot.Exception as ex:
+            print(ex.what(), file=sys.stderr)
             return None
         except:
             traceback.print_exc()