+class PyScriptNode_i (Engines__POA.PyScriptNode,Generic):
+ """The implementation of the PyScriptNode CORBA IDL that executes a script"""
+ def __init__(self, nodeName,code,poa,my_container):
+ """Initialize the node : compilation in the local context"""
+ Generic.__init__(self,poa)
+ self.nodeName=nodeName
+ self.code=code
+ self.my_container=my_container._container
+ linecache.cache[nodeName]=0,None,string.split(code,'\n'),nodeName
+ self.ccode=compile(code,nodeName,'exec')
+ self.context={}
+ self.context["my_container"] = self.my_container
+
+ def execute(self,outargsname,argsin):
+ """Execute the script stored in attribute ccode with pickled args (argsin)"""
+ try:
+ argsname,kws=cPickle.loads(argsin)
+ self.context.update(kws)
+ exec self.ccode in self.context
+ argsout=[]
+ for arg in outargsname:
+ if not self.context.has_key(arg):
+ raise KeyError("There is no variable %s in context" % arg)
+ argsout.append(self.context[arg])
+ argsout=cPickle.dumps(tuple(argsout),-1)
+ return argsout
+ except:
+ exc_typ,exc_val,exc_fr=sys.exc_info()
+ l=traceback.format_exception(exc_typ,exc_val,exc_fr)
+ raise SALOME.SALOME_Exception(SALOME.ExceptionStruct(SALOME.BAD_PARAM,"".join(l),"PyScriptNode: %s, outargsname: %s" % (self.nodeName,outargsname),0))