23 import SALOME_ComponentPy
24 import SALOME_DriverPy
36 class proc_i(YACS_ORB__POA.ProcExec):
38 self.
l = loader.YACSLoader()
39 self.
e = pilot.ExecutorSwig()
42 self.
p = self.l.load(xmlFile)
47 return self.p.getNodeState(numid)
50 return self.p.getNodeProgress(numid)
53 return self.p.getXMLState(numid)
57 return self.p.getInPortValue(nodeNumid, portName)
64 return self.p.setInPortValue(nodeName, portName, value)
71 return self.p.getOutPortValue(nodeNumid, portName)
77 return self.p.getNodeErrorDetails(nodeNumid)
80 return self.p.getNodeErrorReport(nodeNumid)
83 return self.p.getNodeContainerLog(nodeNumid)
86 return self.p.shutdown(level)
89 return self.e.getExecutorState()
92 numids = self.p.getNumIds()
97 return self.p.getNumIds()
100 return self.p.getIds()
102 def runProc(self,debug, isPyThread, fromscratch):
103 print "**************************Begin schema execution %s**************************" % self.
xmlFile
104 self.e.RunPy(self.
p,debug, isPyThread, fromscratch)
105 print "**************************End schema execution %s****************************" % self.
xmlFile
108 if self.
run1 is not None:
109 execState = self.e.getExecutorState()
110 if execState >= pilot.FINISHED:
114 if self.
run1 is None:
115 self.
run1 = threading.Thread(
None, self.
runProc,
"CORBAExec", (0,
True,
True))
119 """Start an execution from the state given by the file xmlFile
120 If xmlFile == "", start execution from the current state
122 if self.
run1 is not None:
123 execState = self.e.getExecutorState()
124 if execState >= pilot.FINISHED:
131 self.p.exUpdateState();
132 sp = loader.stateParser()
133 sl = loader.stateLoader(sp,self.
p)
136 print "IO Error: ", ex
138 except ValueError,ex:
139 print "Caught ValueError Exception:",ex
141 except pilot.Exception,ex:
145 print "Unknown exception!"
148 if self.
run1 is None:
149 self.
run1 = threading.Thread(
None, self.
runProc,
"CORBAExec", (0,
True,
False))
153 """Reset the procedure state to ready state for all nodes in error
154 if xmlFile exists first try to load the state from this file.
157 if self.
run1 is not None:
158 execState = self.e.getExecutorState()
159 if execState >= pilot.FINISHED:
166 if os.path.exists(xmlFile):
168 sp = loader.stateParser()
169 sl = loader.stateLoader(sp,self.
p)
173 self.p.exUpdateState();
177 if self.
run1 is None:
178 self.
run1 = threading.Thread(
None, self.
runProc,
"CORBAExec", (0,
True,
False))
182 disp = SALOMERuntime.SALOMEDispatcher_getSALOMEDispatcher()
183 disp.addObserver(obs, numid, event)
187 if mode == YACS_ORB.CONTINUE:
188 self.e.setExecMode(0)
190 if mode == YACS_ORB.STEPBYSTEP:
191 self.e.setExecMode(1)
193 if mode == YACS_ORB.STOPBEFORENODES:
194 self.e.setExecMode(2)
199 self.e.setListOfBreakPoints(listOfBreakPoints)
203 return self.e.getTasksToLoad()
206 return self.e.setStepsToExecute(listToExecute)
209 return self.e.resumeCurrentBreakPoint()
212 return self.e.isNotFinished()
215 self.e.stopExecution()
219 return self.e.saveState(xmlFile)
222 self.e.setStopOnError(dumpRequested, xmlFile)
226 self.e.unsetStopOnError()
232 class YACS(YACS_ORB__POA.YACS_Gen,
233 SALOME_ComponentPy.SALOME_ComponentPy_i,
234 SALOME_DriverPy.SALOME_DriverPy_i):
236 To be a SALOME component, this Python class must have the component name
237 (YACS) and inherit the YACS_Gen class build from idl compilation
238 with omniidl and also the class SALOME_ComponentPy_i which defines general
239 SALOME component behaviour.
241 def __init__ ( self, orb, poa, contID, containerName, instanceName,
243 print "YACS.__init__: ", containerName,
';', instanceName
244 SALOME_ComponentPy.SALOME_ComponentPy_i.__init__(self, orb, poa, contID,
245 containerName, instanceName,
246 interfaceName,
False)
247 SALOME_DriverPy.SALOME_DriverPy_i.__init__(self, interfaceName)
252 SALOMERuntime.RuntimeSALOME_setRuntime(1)
253 SALOMERuntime.SALOMEDispatcher_setSALOMEDispatcher()
258 modul_catalog = self._naming_service.Resolve(
"/Kernel/ModulCatalog")
259 ior= orb.object_to_string(modul_catalog)
260 cata=r.loadCatalog(
"session",ior)
266 Get version information.
270 rt = SALOMERuntime.getSALOMERuntime()
271 version = rt.getVersion()
279 load an XML graph in a YACS::ENGINE::proc, create a CORBA servant
280 associated to the proc, and return a ref on the servant.
283 procExec_i =
proc_i(xmlFile)
284 logger=procExec_i.p.getLogger(
"parser")
285 if not logger.isEmpty():
286 print "The imported file has errors :"
287 print logger.getStr()
291 print >> sys.stderr ,
"IO Error: ", ex
293 except ValueError,ex:
294 print >> sys.stderr ,
"Caught ValueError Exception:",ex
296 except pilot.Exception,ex:
297 print >> sys.stderr ,ex.what()
300 traceback.print_exc()
302 procExec_o = procExec_i._this()
307 load a SUPERV xml graph, convert it and return the new filename.
310 r = pilot.getRuntime()
311 lo = salomeloader.SalomeLoader()
312 e = pilot.ExecutorSwig()
314 s = pilot.SchemaSave(p)
315 hnd, convertedFile = tempfile.mkstemp(
".xml",
"yacs_",
"/tmp")
316 s.save(convertedFile)