# See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
#
-import xmlrpclib,sys
+import xmlrpc.client,sys
data="""
<methodCall>
</methodCall>
"""
def echo(args):
- print args
+ print(args)
return 96785439
f=open("input")
data=f.read()
f.close()
-params, method = xmlrpclib.loads(data)
+params, method = xmlrpc.client.loads(data)
try:
call=eval(method)
response = (response,)
except:
# report exception back to server
- response = xmlrpclib.dumps( xmlrpclib.Fault(1, "%s:%s" % sys.exc_info()[:2]))
+ response = xmlrpc.client.dumps( xmlrpc.client.Fault(1, "%s:%s" % sys.exc_info()[:2]))
else:
- response = xmlrpclib.dumps( response, methodresponse=1)
+ response = xmlrpc.client.dumps( response, methodresponse=1)
-print response
+print(response)
f=open("output",'w')
f.write(response)
f.close()
def add_text(self, value):
"""Adds text corresponding to `value` into `self.pieces`."""
- if type(value) in (types.ListType, types.TupleType):
+ if type(value) in (list, tuple):
self.pieces.extend(value)
else:
self.pieces.append(value)
kind = node.attributes['kind'].value
if kind in ('class', 'struct'):
prot = node.attributes['prot'].value
- if prot <> 'public':
+ if prot != 'public':
return
names = ('compoundname', 'briefdescription',
'detaileddescription', 'includes')
first = self.get_specific_nodes(node, names)
for n in names:
- if first.has_key(n):
+ if n in first:
self.parse(first[n])
self.add_text(['";','\n'])
for n in node.childNodes:
- if n not in first.values():
+ if n not in list(first.values()):
self.parse(n)
elif kind in ('file', 'namespace'):
nodes = node.getElementsByTagName('sectiondef')
def do_parameterlist(self, node):
text='unknown'
- for key, val in node.attributes.items():
+ for key, val in list(node.attributes.items()):
if key == 'kind':
if val == 'param': text = 'Parameters'
elif val == 'exception': text = 'Exceptions'
if name[:8] == 'operator': # Don't handle operators yet.
return
- if not first.has_key('definition') or \
+ if 'definition' not in first or \
kind in ['variable', 'typedef']:
return
self.add_text(' %s::%s "\n%s'%(cname, name, defn))
for n in node.childNodes:
- if n not in first.values():
+ if n not in list(first.values()):
self.parse(n)
self.add_text(['";', '\n'])
if not os.path.exists(fname):
fname = os.path.join(self.my_dir, fname)
if not self.quiet:
- print "parsing file: %s"%fname
+ print("parsing file: %s"%fname)
p = Doxy2SWIG(fname, self.include_function_definition, self.quiet)
p.generate()
self.pieces.extend(self.clean_pieces(p.pieces))
C = compo.compo()
z = C.addvec(x, y)
-print 'x = ', x
-print 'y = ', y
-print 'z = ', z
-print C.prdscl(x,y)
+print('x = ', x)
+print('y = ', y)
+print('z = ', z)
+print(C.prdscl(x,y))
S = systeme.Systeme()
-print "create U1 ..."
+print("create U1 ...")
S.touch('U1')
-print "dir : ", S.dir()
+print("dir : ", S.dir())
-print "copy U1 to U2 ..."
+print("copy U1 to U2 ...")
S.cp('U1', 'U2')
-print "dir : ", S.dir()
+print("dir : ", S.dir())
-print "delete U1 ..."
+print("delete U1 ...")
S.rm('U1')
-print "dir : ", S.dir()
+print("dir : ", S.dir())
-print "delete U2 ..."
+print("delete U2 ...")
S.rm('U2')
-print "dir : ", S.dir()
+print("dir : ", S.dir())
v2 = [ 3, 4, 5 ]
v3 = o.addvec(v1, v2)
-print v3
+print(v3)
-print o.prdscl(v1, v3)
+print(o.prdscl(v1, v3))
cp.setWCKey("P11U50:CARBONES") ; cp.setNbProcs(5) ; cp.setMaxDuration("00:05")
assert(not rss.isInteractive())
a,b=efx.run(session)
-print("************",a,b)
-print efx.getResults()
+print(("************",a,b))
+print(efx.getResults())
fn_name = args.def_name
functions,errors = get_properties(text_file)
- print "global errors:", errors
+ print("global errors:", errors)
for f in functions:
- print f
+ print(f)
fn_properties = next((f for f in functions if f.name == fn_name), None)
if fn_properties is not None :
fn_properties.inputs, fn_properties.outputs,
args.output)
else:
- print "\n".join(fn_properties.errors)
+ print("\n".join(fn_properties.errors))
else:
- print "Function not found:", fn_name
+ print("Function not found:", fn_name)
\ No newline at end of file
"""
import sys,os
from qt import *
-import Tree
-import PanelManager
-import BoxManager
-import Icons
-import Items
-import adapt
-import Item
-import logview
+from . import Tree
+from . import PanelManager
+from . import BoxManager
+from . import Icons
+from . import Items
+from . import adapt
+from . import Item
+from . import logview
import pilot
import threading
import time
-import CONNECTOR
-import catalog
+from . import CONNECTOR
+from . import catalog
import traceback
import glob
def run(self):
try:
self.executor.RunW(self.proc,0)
- except ValueError,ex:
+ except ValueError as ex:
#traceback.print_exc()
QApplication.postEvent(self.parent, ErrorEvent('YACS execution error',str(ex)))
if __name__ == "__main__":
- from Item import Item
+ from .Item import Item
app = QApplication(sys.argv)
t=Appli()
t.objectBrowser.additem(Item("item1"))
#
from qt import *
-import CONNECTOR
+from . import CONNECTOR
class BoxManager(QWidgetStack):
""" A BoxManager manages a collection of widget
CONNECTOR.Connect(self.rootItem,"selected",self.setview,())
def setview(self,item):
- if not self.panels.has_key(item):
+ if item not in self.panels:
CONNECTOR.Connect(item,"changed",self.changePanel,(item,))
panel=item.box(self)
self.panels[item]=panel
self.raiseWidget(self.panels[item])
def changePanel(self,item):
- print "changePanel",item
- if self.panels.has_key(item):
+ print("changePanel",item)
+ if item in self.panels:
self.removeWidget(self.panels[item])
panel=item.box(self)
self.panels[item]=panel
from qtcanvas import *
import pilot
import pypilot
-import Item
+from . import Item
import math
dispatcher=pilot.Dispatcher.getDispatcher()
return menu
def delete(self):
- print "delete link"
+ print("delete link")
def tooltip(self,view,pos):
r = QRect(pos.x(), pos.y(), pos.x()+10, pos.y()+10)
return menu
def connect(self):
- print "ControlItem.connect",self.context
- print self.port
+ print("ControlItem.connect",self.context)
+ print(self.port)
item=Item.adapt(self.port)
- print item
+ print(item)
item.connect()
self.context.connecting(item)
#self.context.connecting(self)
#Protocol to link 2 objects (ports, at first)
#First, notify the canvas View (or any view that can select) we are connecting (see method connect above)
#Second (and last) make the link in the link method of object that was declared connecting
- print "link:",obj
+ print("link:",obj)
def tooltip(self,view,pos):
r = QRect(pos.x(), pos.y(), self.width(), self.height())
def link(self,obj):
#Here we create the link between self and obj.
#self has been declared connecting in connect method
- print "link:",obj
+ print("link:",obj)
if isinstance(obj,OutControlItem):
#Connection possible
l=LinkItem(obj,self,self.canvas())
def link(self,obj):
#Here we create the link between self and obj.
#self has been declared connecting in connect method
- print "link:",obj
+ print("link:",obj)
if isinstance(obj,InControlItem):
#Connection possible
l=LinkItem(self,obj,self.canvas())
return menu
def connect(self):
- print "PortItem.connect",self.context
- print self.port
+ print("PortItem.connect",self.context)
+ print(self.port)
item=Item.adapt(self.port)
- print item
+ print(item)
self.context.connecting(item)
#self.context.connecting(self)
def link(self,obj):
- print "PortItem.link:",obj
+ print("PortItem.link:",obj)
def tooltip(self,view,pos):
r = QRect(pos.x(),pos.y(),self.width(), self.height())
def link(self,obj):
#Here we create the link between self and obj.
#self has been declared connecting in connect method
- print "link:",obj
+ print("link:",obj)
if isinstance(obj,OutPortItem):
#Connection possible
l=LinkItem(obj,self,self.canvas())
def link(self,obj):
#Here we create the link between self and obj.
#self has been declared connecting in connect method
- print "link:",obj
+ print("link:",obj)
if isinstance(obj,InPortItem):
#Connection possible
l=LinkItem(self,obj,self.canvas())
color= self.colors.get(color,Qt.white)
self.setBrush(QBrush(color))
else:
- print "Unknown custom event type:", event.type()
+ print("Unknown custom event type:", event.type())
def moveBy(self,dx,dy):
QCanvasRectangle.moveBy(self,dx,dy)
#QToolTip(view).tip( r, s )
def browse(self):
- print "browse"
+ print("browse")
def selected(self):
"""The canvas item has been selected"""
def Connect(self, object, channel, function, args):
###print "Connect",object, channel, function, args
idx = id(object)
- if self.connections.has_key(idx):
+ if idx in self.connections:
channels = self.connections[idx]
else:
channels = self.connections[idx] = {}
- if channels.has_key(channel):
+ if channel in channels:
receivers = channels[channel]
else:
receivers = channels[channel] = []
try:
receivers = self.connections[id(object)][channel]
except KeyError:
- raise ConnectorError, \
- 'no receivers for channel %s of %s' % (channel, object)
+ raise ConnectorError('no receivers for channel %s of %s' % (channel, object))
for funct,fargs in receivers[:]:
if funct() is None:
del self.connections[id(object)]
return
- raise ConnectorError,\
- 'receiver %s%s is not connected to channel %s of %s' \
- % (function, args, channel, object)
+ raise ConnectorError('receiver %s%s is not connected to channel %s of %s' \
+ % (function, args, channel, object))
def Emit(self, object, channel, *args):
try:
func=rfunc()
if func:
- apply(func, args + fargs)
+ func(*args + fargs)
else:
# Le receveur a disparu
if (rfunc,fargs) in receivers:receivers.remove((rfunc,fargs))
class BoundMethodWeakref(object):
def __init__(self,callable):
- self.Self=weakref.ref(callable.im_self)
- self.Func=weakref.ref(callable.im_func)
+ self.Self=weakref.ref(callable.__self__)
+ self.Func=weakref.ref(callable.__func__)
def __call__(self):
target=self.Self()
class A:pass
class B:
def add(self,a):
- print "add",self,a
+ print("add",self,a)
def __del__(self):
- print "__del__",self
+ print("__del__",self)
def f(a):
- print f,a
- print "a=A()"
+ print(f,a)
+ print("a=A()")
a=A()
- print "b=B()"
+ print("b=B()")
b=B()
- print "c=B()"
+ print("c=B()")
c=B()
Connect(a,"add",b.add,())
Connect(a,"add",b.add,())
Connect(a,"add",c.add,())
Connect(a,"add",f,())
Emit(a,"add",1)
- print "del b"
+ print("del b")
del b
Emit(a,"add",1)
- print "del f"
+ print("del f")
del f
Emit(a,"add",1)
Disconnect(a,"add",c.add,())
#self.canvas().update()
def addNode(self):
- print "addNode"
+ print("addNode")
def zoomIn(self):
m = self.worldMatrix()
def connecting(self,obj):
"""Method called by an item to notify canvasView a connection has begun"""
- print "connecting",obj
+ print("connecting",obj)
self.__connecting=obj
def contentsMouseMoveEvent(self,e):
return menu
def delete(self):
- print "delete link"
+ print("delete link")
def tooltip(self,view,pos):
r = QRect(pos.x(), pos.y(), pos.x()+10, pos.y()+10)
return menu
def connect(self):
- print "connect",self.context
+ print("connect",self.context)
self.context.connecting(self)
def link(self,obj):
- print "link:",obj
+ print("link:",obj)
def tooltip(self,view,pos):
r = QRect(self.x(), self.y(), self.width(), self.height())
link.setToPoint( int(self.x()), int(self.y()) )
def link(self,obj):
- print "link:",obj
+ print("link:",obj)
if isinstance(obj,OutPortItem):
#Connection possible
l=LinkItem(obj,self,self.canvas())
link.setFromPoint( int(self.x()), int(self.y()) )
def link(self,obj):
- print "link:",obj
+ print("link:",obj)
if isinstance(obj,InPortItem):
#Connection possible
l=LinkItem(self,obj,self.canvas())
view.tip( r, s )
def browse(self):
- print "browse"
+ print("browse")
def selected(self):
- print "selected"
+ print("selected")
if __name__=='__main__':
app=QApplication(sys.argv)
import os
from qt import QPixmap
-from imagesxpm import dico_xpm
+from .imagesxpm import dico_xpm
dico_images={}
def get_image(name):
- if dico_images.has_key(name):
+ if name in dico_images:
return dico_images[name]
else :
- if dico_xpm.has_key(name):
+ if name in dico_xpm:
image=QPixmap(dico_xpm[name])
else:
fic_image = os.path.join(os.path.dirname(__file__),"icons",name)
import sys
from qt import *
-import CONNECTOR
-import adapt
+from . import CONNECTOR
+from . import adapt
class Item:
def __init__(self,label=""):
ADAPT=adapt.adapt
items={}
def adapt(obj):
- if items.has_key(obj.ptr()):
+ if obj.ptr() in items:
return items[obj.ptr()]
else:
item= ADAPT(obj,Item)
import sys
import pilot
import SALOMERuntime
-import Item
-import adapt
+from . import Item
+from . import adapt
from qt import *
from qtcanvas import *
-import Editor
-import CItems
+from . import Editor
+from . import CItems
import pygraphviz
import traceback
-import CONNECTOR
-import graph
-import panels
+from . import CONNECTOR
+from . import graph
+from . import panels
class DataLinkItem(Item.Item):
def __init__(self,pin,pout):
return tabWidget
def addNode(self,service):
- print "Composed.addNode",service
+ print("Composed.addNode",service)
#add node service in the parent self which is a ComposedNode
new_node=service.clone(None)
ItemComposedNode.n=ItemComposedNode.n+1
panels=[("Panel1",panel1)]
def addLink(self,link):
- print "Composed.addLink",link
+ print("Composed.addLink",link)
if isinstance(link,DataLinkItem):
self.datalinks.addLink(link)
elif isinstance(link,StreamLinkItem):
class ItemProc(ItemComposedNode):
"""Item pour la procedure"""
def connecting(self,item):
- print "ItemProc.connecting",item
+ print("ItemProc.connecting",item)
self._connecting=item
class ItemPort(Item.Item):
box=panel
def link(self,other):
- print "ItemPort.link:",self,other
+ print("ItemPort.link:",self,other)
def connect(self):
- print "ItemPort.connect:"
+ print("ItemPort.connect:")
self.root.connecting(self)
class ItemInPort(ItemPort):
if not cflink:
#add also a control flow link
fitem.addLink(ControlLinkItem(nodeS,nodeE))
- except ValueError,ex:
+ except ValueError as ex:
traceback.print_exc()
QMessageBox.warning(None,"YACS error",str(ex))
return
l=StreamLinkItem(other.port,self.port)
fitem=Item.adapt(father)
fitem.addLink(l)
- except ValueError,ex:
+ except ValueError as ex:
traceback.print_exc()
QMessageBox.warning(None,"YACS error",str(ex))
return
#
from qt import *
-import CONNECTOR
+from . import CONNECTOR
class PanelManager(QWidgetStack):
""" A PanelManager manages a collection of widget
CONNECTOR.Connect(self.rootItem,"dblselected",self.setview,())
def setview(self,item):
- if not self.panels.has_key(item):
+ if item not in self.panels:
panel=item.panel(self)
self.panels[item]=panel
idd=self.addWidget(panel)
import sys
from qt import *
-import Icons
-import CONNECTOR
+from . import Icons
+from . import CONNECTOR
class Tree(QListView):
"""Tree(parent=None)
if __name__ == "__main__":
- from Item import Item
+ from .Item import Item
app = QApplication(sys.argv)
t=Tree()
t.additem(Item("item1"))
else:
adapter = factory(obj, protocol, alternate)
if adapter is AdaptationError:
- raise AdaptationError,obj
+ raise AdaptationError(obj)
else:
return adapter
#
from qt import *
-import Tree
-from BoxManager import BoxManager
+from . import Tree
+from .BoxManager import BoxManager
class Browser(QVBox):
def __init__(self,parent,appli):
#
from qt import *
-import browser
-import cataitems
+from . import browser
+from . import cataitems
class Browser(browser.Browser):
def init(self):
self.connect( but1, SIGNAL("clicked()"), self.handleBut1 )
def handleBut1(self):
- print "handleBut1",self.selected
+ print("handleBut1",self.selected)
if hasattr(self.selected,"addNode"):
self.selected.addNode(self.appli)
return
import sys
from qt import *
-import browser
-import sessions
+from . import browser
+from . import sessions
import pilot
class Browser(browser.Browser):
from qt import *
-import Item
-import CONNECTOR
-import Items
+from . import Item
+from . import CONNECTOR
+from . import Items
class Obj(Item.Item):
def __init__(self,root=None):
def getChildren(self):
sublist=[]
- for service in self.compo._serviceMap.values():
+ for service in list(self.compo._serviceMap.values()):
itemservice=ItemService(service,self.root)
sublist.append(itemservice)
return sublist
def getChildren(self):
sublist=[]
- for name,typ in self.typeMap.items():
+ for name,typ in list(self.typeMap.items()):
itemtype=ItemType(typ,self.root,name)
sublist.append(itemtype)
return sublist
def getChildren(self):
sublist=[]
- for compo in self.compoMap.values():
+ for compo in list(self.compoMap.values()):
itemcompo=ItemCompo(compo,self.root)
sublist.append(itemcompo)
return sublist
def getChildren(self):
sublist=[]
- for node in self.nodesMap.values():
+ for node in list(self.nodesMap.values()):
itemnode=ItemNode(node,self.root)
sublist.append(itemnode)
return sublist
def getChildren(self):
sublist=[]
- for node in self.composedMap.values():
+ for node in list(self.composedMap.values()):
itemnode=ItemComposedNode(node,self.root)
sublist.append(itemnode)
return sublist
#
from qt import *
-import browser_session
-import browser_catalog
+from . import browser_session
+from . import browser_catalog
import pilot
class CatalogTool(QMainWindow):
return
filename = str(fn)
cata=pilot.getRuntime().loadCatalog("proc",filename)
- print cata
- print cata._nodeMap
- for name,node in cata._nodeMap.items():
- print name,node
+ print(cata)
+ print(cata._nodeMap)
+ for name,node in list(cata._nodeMap.items()):
+ print(name,node)
self.register(cata,filename)
def register(self,cata,name):
import sys
import pilot
-import Item
+from . import Item
from qt import *
from qtcanvas import *
-from GraphViewer import GraphViewer
-import Editor
-import CItems
+from .GraphViewer import GraphViewer
+from . import Editor
+from . import CItems
import pygraphviz
from pygraphviz import graphviz as gv
import traceback
-import CONNECTOR
+from . import CONNECTOR
import bisect
class MyCanvas(QCanvas):
citems[n.ptr()]=c
c.show()
- for k,n in citems.items():
+ for k,n in list(citems.items()):
for p in n.inports:
pitems[p.port.ptr()]=p
for p in n.outports:
self.layout("LR")
def addLink(self,link):
- print "graph.addLink",link
+ print("graph.addLink",link)
#CItem for outport
nodeS=self.citems[link.pout.getNode().ptr()]
nodeE=self.citems[link.pin.getNode().ptr()]
G.graph_attr["dpi"]="72"
dpi=72.
aspect=dpi/72
- for k,n in self.citems.items():
+ for k,n in list(self.citems.items()):
#k is node address (YACS)
#n is item in canvas
G.add_node(k)
continue
G.add_edge(pout.getNode().ptr(),pin.getNode().ptr())
- for k,n in self.citems.items():
+ for k,n in list(self.citems.items()):
for ndown in n.node.getOutNodes():
G.add_edge(n.node.ptr(),ndown.ptr())
self.canvas.update()
def clearLinks(self):
- items=self.citems.values()
+ items=list(self.citems.values())
for node in items:
for port in node.outports:
if not hasattr(port,"links"):
self.canvas.update()
def orthoLinks(self):
- items=self.citems.values()
+ items=list(self.citems.values())
g=grid(items)
for node in items:
for port in node.outports:
self.xs=xs
self.ys=ys
self.cols=[]
- for w in xrange(len(xs)-1):
+ for w in range(len(xs)-1):
col=[]
x=(xs[w]+xs[w+1])/2
- for h in xrange(len(ys)-1):
+ for h in range(len(ys)-1):
y=(ys[h]+ys[h+1])/2
col.append(node((x,y),(w,h)))
self.cols.append(col)
self.open.append((fromNode.total,fromNode))
toNode=self.get(toLoc)
if toNode.blocked:
- print "toNode is blocked"
+ print("toNode is blocked")
return []
destx,desty=toNode.coord
while self.open:
from qt import *
import traceback
-import Editor
-import Item
+from . import Editor
+from . import Item
class PanelScript(QVBox):
def __init__(self,parent,item):
from omniORB import CORBA
import CosNaming
-import Item
-import CONNECTOR
+from . import Item
+from . import CONNECTOR
class Sessions(Item.Item):
def __init__(self,port):
# @defreturn list of strings
def keys(self):
- return self.attrib.keys()
+ return list(self.attrib.keys())
##
# Gets element attributes, as a sequence. The attributes are
# @defreturn list of (string, string) tuples
def items(self):
- return self.attrib.items()
+ return list(self.attrib.items())
##
# Creates a tree iterator. The iterator loops over this element
elif tag is ProcessingInstruction:
file.write("<?%s?>" % _escape_cdata(node.text, encoding))
else:
- items = node.items()
+ items = list(node.items())
xmlns_items = [] # new namespaces in this scope
try:
if isinstance(tag, QName) or tag[:1] == "{":
append((event, None))
parser.EndNamespaceDeclHandler = handler
- def next(self):
+ def __next__(self):
while 1:
try:
item = self._events[self._index]
return self
except NameError:
def __getitem__(self, index):
- return self.next()
+ return next(self)
##
# Parses an XML document from a string constant. This function can
fixname = self._fixname
tag = fixname(tag)
attrib = {}
- for key, value in attrib_in.items():
+ for key, value in list(attrib_in.items()):
attrib[fixname(key)] = self._fixtext(value)
return self._target.start(tag, attrib)
}
display(G)
I=invert(G)
- print reachable(G,2)
- print reachable(I,6)
- print reachable(G,2) & reachable(I,6)
+ print(reachable(G,2))
+ print(reachable(I,6))
+ print(reachable(G,2) & reachable(I,6))
if __name__ == "__main__":
test()
"""
tree = ElementTree.ElementTree(file=filename)
root = tree.getroot()
- if debug:print "root.tag:",root.tag,root
+ if debug:print("root.tag:",root.tag,root)
procs=[]
if root.tag == "dataflow":
#only one dataflow
dataflow=root
- if debug:print dataflow
+ if debug:print(dataflow)
proc=SalomeProc(dataflow)
procs.append(proc)
else:
#one or more dataflows. The graph contains macros.
#All macros are defined at the same level in the XML file.
for dataflow in root.findall("dataflow"):
- if debug:print dataflow
+ if debug:print(dataflow)
proc=SalomeProc(dataflow)
- if debug:print "dataflow name:",proc.name
+ if debug:print("dataflow name:",proc.name)
procs.append(proc)
return procs
#Put macros in macro_dict
macro_dict={}
for p in procs:
- if debug:print "proc_name:",p.name,"coupled_node:",p.coupled_node
+ if debug:print("proc_name:",p.name,"coupled_node:",p.coupled_node)
macro_dict[p.name]=p
- if debug:print filename
+ if debug:print(filename)
yacsproc=ProcNode(proc,macro_dict,filename)
return yacsproc.createNode()
n.setScript(self.codes[0])
self.node=n
for para in self.service.inParameters:
- if not typeMap.has_key(para.type):
+ if para.type not in typeMap:
#create the missing type and add it in type map
typeMap[para.type]= currentProc.createInterfaceTc("",para.type,[objref])
- if not currentProc.typeMap.has_key(para.type):
+ if para.type not in currentProc.typeMap:
currentProc.typeMap[para.type]=typeMap[para.type]
n.edAddInputPort(para.name,typeMap[para.type])
for para in self.service.outParameters:
- if not typeMap.has_key(para.type):
+ if para.type not in typeMap:
#create the missing type and add it in type map
typeMap[para.type]= currentProc.createInterfaceTc("",para.type,[objref])
- if not currentProc.typeMap.has_key(para.type):
+ if para.type not in currentProc.typeMap:
currentProc.typeMap[para.type]=typeMap[para.type]
n.edAddOutputPort(para.name,typeMap[para.type])
return self.node
r = pilot.getRuntime()
- if self.container.components.has_key(self.sComponent):
+ if self.sComponent in self.container.components:
#a node for this component already exists
compo_node=self.container.components[self.sComponent]
#It's a node associated with another node of the same component instance
#add dataflow ports in out
for para in self.service.inParameters:
- if not typeMap.has_key(para.type):
+ if para.type not in typeMap:
#Create the missing type and adds it into types table
typeMap[para.type]= currentProc.createInterfaceTc("",para.type,[objref])
- if not currentProc.typeMap.has_key(para.type):
+ if para.type not in currentProc.typeMap:
currentProc.typeMap[para.type]=typeMap[para.type]
n.edAddInputPort(para.name,typeMap[para.type])
for para in self.service.outParameters:
- if not typeMap.has_key(para.type):
+ if para.type not in typeMap:
#Create the missing type and adds it into types table
typeMap[para.type]= currentProc.createInterfaceTc("",para.type,[objref])
- if not currentProc.typeMap.has_key(para.type):
+ if para.type not in currentProc.typeMap:
currentProc.typeMap[para.type]=typeMap[para.type]
pout=n.edAddOutputPort(para.name,typeMap[para.type])
#add datastream ports in and out
for para in self.inStreams:
- if debug:print para.name,para.type,para.dependency,para.schema, para.interpolation,
- if debug:print para.extrapolation
+ if debug:print(para.name,para.type,para.dependency,para.schema, para.interpolation, end=' ')
+ if debug:print(para.extrapolation)
pin=n.edAddInputDataStreamPort(para.name,typeMap[streamTypes[para.type]])
for para in self.outStreams:
- if debug:print para.name,para.type,para.dependency,para.values
+ if debug:print(para.name,para.type,para.dependency,para.values)
pout=n.edAddOutputDataStreamPort(para.name,typeMap[streamTypes[para.type]])
for d in self.datas:
n.inner_nodes=loops[n]
n.G=graph.InducedSubgraph(loops[n],G)
- if debug:print "all loops"
- if debug:print loops
+ if debug:print("all loops")
+ if debug:print(loops)
#Get most external loops
- outer_loops=loops.keys()
+ outer_loops=list(loops.keys())
for l in loops:
for ll in outer_loops:
if loops[l] < loops[ll]:
break
#In the end all remaining loops in outer_loops are the most external
- if debug:print outer_loops
+ if debug:print(outer_loops)
#We remove all internal nodes of most external loops
for l in outer_loops:
#outcoming links of internal nodes. Probably not complete.
inputs={}
for link in l.endloop.links:
- if debug:print link.from_node,link.to_node,link.from_param,link.to_param
+ if debug:print(link.from_node,link.to_node,link.from_param,link.to_param)
inputs[link.to_param]=link.from_node,link.from_param
for s in suiv:
for link in s.links:
if link.from_node == l.endloop:
link.from_node,link.from_param=inputs[link.from_param]
- if debug:print link.from_node,link.to_node,link.from_param,link.to_param
+ if debug:print(link.from_node,link.to_node,link.from_param,link.to_param)
if debug:graph.display(G)
"""This method connects the salome macros in macro_dict to the master YACS Proc.
"""
- if debug:print "connect_macros",self.node,macro_dict
+ if debug:print("connect_macros",self.node,macro_dict)
for node in self.G:
if isinstance(node,MacroNode):
#node is a macro, connect its definition to self.
#node.node is the YACS Bloc equivalent to node
p=macro_dict[node.coupled_node]
bloc=node.node
- if debug:print "macronode:",node.name,node.coupled_node,p
+ if debug:print("macronode:",node.name,node.coupled_node,p)
#Create a hierarchical graph from the salome graph
G=p.create_graph()
node.G=G
init.setScript(self.codes[0])
init.setFname(self.fnames[0])
for para in self.service.inParameters:
- if not typeMap.has_key(para.type):
+ if para.type not in typeMap:
#create the missing type and add it in type map
typeMap[para.type]= currentProc.createInterfaceTc("",para.type,[objref])
- if not currentProc.typeMap.has_key(para.type):
+ if para.type not in currentProc.typeMap:
currentProc.typeMap[para.type]=typeMap[para.type]
init.edAddInputPort(para.name,typeMap[para.type])
for para in self.service.outParameters:
- if not typeMap.has_key(para.type):
+ if para.type not in typeMap:
#create the missing type and add it in type map
typeMap[para.type]= currentProc.createInterfaceTc("",para.type,[objref])
- if not currentProc.typeMap.has_key(para.type):
+ if para.type not in currentProc.typeMap:
currentProc.typeMap[para.type]=typeMap[para.type]
init.edAddOutputPort(para.name,typeMap[para.type])
bloop.edAddChild(init)
next.setScript(self.codes[2])
next.setFname(self.fnames[2])
for para in self.service.inParameters:
- if not typeMap.has_key(para.type):
+ if para.type not in typeMap:
#create the missing type and add it in type map
typeMap[para.type]= currentProc.createInterfaceTc("",para.type,[objref])
- if not currentProc.typeMap.has_key(para.type):
+ if para.type not in currentProc.typeMap:
currentProc.typeMap[para.type]=typeMap[para.type]
next.edAddInputPort(para.name,typeMap[para.type])
for para in self.service.outParameters:
- if not typeMap.has_key(para.type):
+ if para.type not in typeMap:
#create the missing type and add it in type map
typeMap[para.type]= currentProc.createInterfaceTc("",para.type,[objref])
- if not currentProc.typeMap.has_key(para.type):
+ if para.type not in currentProc.typeMap:
currentProc.typeMap[para.type]=typeMap[para.type]
next.edAddOutputPort(para.name,typeMap[para.type])
blnode.edAddChild(next)
more.setScript(self.codes[1])
more.setFname(self.fnames[1])
for para in self.service.inParameters:
- if not typeMap.has_key(para.type):
+ if para.type not in typeMap:
#create the missing type and add it in type map
typeMap[para.type]= currentProc.createInterfaceTc("",para.type,[objref])
- if not currentProc.typeMap.has_key(para.type):
+ if para.type not in currentProc.typeMap:
currentProc.typeMap[para.type]=typeMap[para.type]
more.edAddInputPort(para.name,typeMap[para.type])
more.edAddOutputPort("DoLoop",typeMap["int"])
for para in self.service.outParameters:
- if not typeMap.has_key(para.type):
+ if para.type not in typeMap:
#create the missing type and add it in type map
typeMap[para.type]= currentProc.createInterfaceTc("",para.type,[objref])
- if not currentProc.typeMap.has_key(para.type):
+ if para.type not in currentProc.typeMap:
currentProc.typeMap[para.type]=typeMap[para.type]
more.edAddOutputPort(para.name,typeMap[para.type])
blnode.edAddChild(more)
currentProc.typeMap["CALCIUM_real"]=typeMap["CALCIUM_real"]
#create all containers
- for name,container in _containers.items():
+ for name,container in list(_containers.items()):
cont=r.createContainer()
cont.setName(name)
cont.setProperty("hostname",container.mach)
#each node has 2 lists of datastream links (inStreams, outStreams)
def parse(self,dataflow):
- if debug:print "All XML nodes"
+ if debug:print("All XML nodes")
for node in dataflow:
- if debug:print node.tag,node
+ if debug:print(node.tag,node)
#Parse dataflow info-list
self.dataflow_info=self.parseService(dataflow.find("info-list/node/service"))
- if debug:print self.dataflow_info
- if debug:print self.dataflow_info.inParameters
- if debug:print self.dataflow_info.outParameters
+ if debug:print(self.dataflow_info)
+ if debug:print(self.dataflow_info.inParameters)
+ if debug:print(self.dataflow_info.outParameters)
if debug:
for para in self.dataflow_info.inParameters:
- print "inParam:",para.name,para.name.split("__",1)
+ print("inParam:",para.name,para.name.split("__",1))
self.name=dataflow.findtext("info-list/node/node-name")
self.coupled_node=dataflow.findtext("info-list/node/coupled-node")
- if debug:print "All XML nodes dataflow/node-list"
+ if debug:print("All XML nodes dataflow/node-list")
nodes=[]
node_dict={}
#Parse all nodes
node.container= getContainer(container)
if not node.container:
node.container=addContainer(container)
- if debug:print "\tcontainer",node.container
+ if debug:print("\tcontainer",node.container)
elif kind == "3":
#It's a python function
node=MacroNode()
node.kind=10
else:
- raise UnknownKind,kind
+ raise UnknownKind(kind)
node.name=name
node.service=None
node.coupled_node=coupled_node
#Put nodes in a dict to ease search
node_dict[node.name]=node
- if debug:print "\tnode-name",node.name
- if debug:print "\tkind",node.kind,node.__class__.__name__
+ if debug:print("\tnode-name",node.name)
+ if debug:print("\tkind",node.kind,node.__class__.__name__)
s=n.find("service")
if s:
#Parse datastream ports
- if debug:print "DataStream ports"
+ if debug:print("DataStream ports")
inStreams=[]
for indata in n.findall("DataStream-list/inParameter"):
inStreams.append(self.parseInData(indata))
outStreams_dict[p.name]=p
node.outStreams=outStreams
node.outStreams_dict=outStreams_dict
- if debug:print "\t++++++++++++++++++++++++++++++++++++++++++++"
+ if debug:print("\t++++++++++++++++++++++++++++++++++++++++++++")
nodes.append(node)
self.nodes=nodes
<coord-list/>
</link>
"""
- if debug:print "All XML nodes dataflow/link-list"
+ if debug:print("All XML nodes dataflow/link-list")
links=[]
- if debug:print "\t++++++++++++++++++++++++++++++++++++++++++++"
+ if debug:print("\t++++++++++++++++++++++++++++++++++++++++++++")
for link in dataflow.findall('link-list/link'):
l=Link()
l.from_name=link.findtext("fromnode-name")
l.from_param=link.findtext("fromserviceparameter-name")
l.to_param=link.findtext("toserviceparameter-name")
links.append(l)
- if debug:print "\tfromnode-name",l.from_name
- if debug:print "\tfromserviceparameter-name",l.from_param
- if debug:print "\ttonode-name",l.to_name
- if debug:print "\ttoserviceparameter-name",l.to_param
- if debug:print "\t++++++++++++++++++++++++++++++++++++++++++++"
+ if debug:print("\tfromnode-name",l.from_name)
+ if debug:print("\tfromserviceparameter-name",l.from_param)
+ if debug:print("\ttonode-name",l.to_name)
+ if debug:print("\ttoserviceparameter-name",l.to_param)
+ if debug:print("\t++++++++++++++++++++++++++++++++++++++++++++")
self.links=links
- if debug:print "All XML nodes dataflow/data-list"
+ if debug:print("All XML nodes dataflow/data-list")
datas=[]
for data in dataflow.findall('data-list/data'):
d=self.parseData(data)
datas.append(d)
- if debug:print "\ttonode-name",d.tonode
- if debug:print "\ttoserviceparameter-name",d.tonodeparam
- if debug:print "\tparameter-value",d.value
- if debug:print "\tparameter-type",d.type
- if debug:print "\t++++++++++++++++++++++++++++++++++++++++++++"
+ if debug:print("\ttonode-name",d.tonode)
+ if debug:print("\ttoserviceparameter-name",d.tonodeparam)
+ if debug:print("\tparameter-value",d.value)
+ if debug:print("\tparameter-type",d.type)
+ if debug:print("\t++++++++++++++++++++++++++++++++++++++++++++")
self.datas=datas
def parseService(self,s):
service=Service()
service.name=s.findtext("service-name")
- if debug:print "\tservice-name",service.name
+ if debug:print("\tservice-name",service.name)
inParameters=[]
for inParam in s.findall("inParameter-list/inParameter"):
p=Parameter()
p.name=inParam.findtext("inParameter-name")
p.type=typeName(inParam.findtext("inParameter-type"))
- if debug:print "\tinParameter-name",p.name
- if debug:print "\tinParameter-type",p.type
+ if debug:print("\tinParameter-name",p.name)
+ if debug:print("\tinParameter-type",p.type)
inParameters.append(p)
service.inParameters=inParameters
- if debug:print "\t++++++++++++++++++++++++++++++++++++++++++++"
+ if debug:print("\t++++++++++++++++++++++++++++++++++++++++++++")
outParameters=[]
for outParam in s.findall("outParameter-list/outParameter"):
p=Parameter()
p.name=outParam.findtext("outParameter-name")
p.type=typeName(outParam.findtext("outParameter-type"))
- if debug:print "\toutParameter-name",p.name
- if debug:print "\toutParameter-type",p.type
+ if debug:print("\toutParameter-name",p.name)
+ if debug:print("\toutParameter-type",p.type)
outParameters.append(p)
service.outParameters=outParameters
- if debug:print "\t++++++++++++++++++++++++++++++++++++++++++++"
+ if debug:print("\t++++++++++++++++++++++++++++++++++++++++++++")
return service
def parseData(self,d):
return da
def parsePyFunction(self,pyfunc):
- if debug:print pyfunc.tag,":",pyfunc
- if debug:print "\tFuncName",pyfunc.findtext("FuncName")
+ if debug:print(pyfunc.tag,":",pyfunc)
+ if debug:print("\tFuncName",pyfunc.findtext("FuncName"))
text=""
for cdata in pyfunc.findall("PyFunc"):
if text:text=text+'\n'
"""
def parseInData(self,d):
- if debug:print d.tag,":",d
+ if debug:print(d.tag,":",d)
p=Parameter()
p.name=d.findtext("inParameter-name")
p.type=typeName(d.findtext("inParameter-type"))
p.schema=d.findtext("inParameter-schema")
p.interpolation=d.findtext("inParameter-interpolation")
p.extrapolation=d.findtext("inParameter-extrapolation")
- if debug:print "\tinParameter-name",p.name
+ if debug:print("\tinParameter-name",p.name)
return p
def parseOutData(self,d):
- if debug:print d.tag,":",d
+ if debug:print(d.tag,":",d)
p=Parameter()
p.name=d.findtext("outParameter-name")
p.type=typeName(d.findtext("outParameter-type"))
p.dependency=d.findtext("outParameter-dependency")
p.values=d.findtext("outParameter-values")
- if debug:print "\toutParameter-name",p.name
+ if debug:print("\toutParameter-name",p.name)
return p
def create_graph(self):
from_node=self.node_dict[link.from_name]
if link.from_param == "Gate" or link.to_param == "Gate":
#control link salome : add to_name node to neighbours
- if debug:print "add control link",link.from_name,link.to_name
+ if debug:print("add control link",link.from_name,link.to_name)
G[self.node_dict[link.from_name]].add(self.node_dict[link.to_name])
- elif from_node.outStreams_dict.has_key(link.from_param):
+ elif link.from_param in from_node.outStreams_dict:
# datastream link :
# 1- add link in link list
# 2- add in link references on from_node and to_node
- if debug:print "add stream link",link.from_name,link.to_name
+ if debug:print("add stream link",link.from_name,link.to_name)
self.node_dict[link.to_name].inStreamLinks.append(link)
self.node_dict[link.from_name].outStreamLinks.append(link)
link.from_node=self.node_dict[link.from_name]
if isinstance(to_node,LoopNode):
# If it's the link from EndOfLoop to Loop , we ignore it
if to_node.coupled_node == from_node.name:
- if debug:print "backlink loop:",from_node,to_node
+ if debug:print("backlink loop:",from_node,to_node)
#ignored
continue
- if debug:print "add dataflow link",link.from_name,link.to_name
+ if debug:print("add dataflow link",link.from_name,link.to_name)
G[self.node_dict[link.from_name]].add(self.node_dict[link.to_name])
if link.from_param != "DoLoop" and link.to_param != "DoLoop":
and isinstance(self.node_dict[link.to_name],InlineNode):
#Store the end loop inline node in attribute endloop
#self.node_dict[link.to_name] is the end node of the head loop node self.node_dict[link.from_name]
- if debug:print "add loop",link.from_name,link.to_name
+ if debug:print("add loop",link.from_name,link.to_name)
self.node_dict[link.from_name].endloop=self.node_dict[link.to_name]
self.node_dict[link.to_name].loop=self.node_dict[link.from_name]
for data in self.datas:
- if debug:print "datas",data
+ if debug:print("datas",data)
self.node_dict[data.tonode].datas.append(data)
self.G=G
salomeFile=sys.argv[1]
convertedFile=sys.argv[2]
except :
- print usage%(sys.argv[0])
+ print(usage%(sys.argv[0]))
sys.exit(3)
SALOMERuntime.RuntimeSALOME_setRuntime()
logger=p.getLogger("parser")
if not logger.isEmpty():
- print logger.getStr()
+ print(logger.getStr())
sys.exit(1)
if __name__ == "__main__":
pass
#
#
-print "Test Program of Cpp_Template_ component"
+print("Test Program of Cpp_Template_ component")
# ...
#
def killSalome():
- print "arret des serveurs SALOME"
- for pid, cmd in process_id.items():
- print "arret du process %s : %s"% (pid, cmd[0])
+ print("arret des serveurs SALOME")
+ for pid, cmd in list(process_id.items()):
+ print("arret du process %s : %s"% (pid, cmd[0]))
try:
os.kill(pid,signal.SIGKILL)
except:
- print " ------------------ process %s : %s inexistant"% (pid, cmd[0])
- print "arret du naming service"
+ print(" ------------------ process %s : %s inexistant"% (pid, cmd[0]))
+ print("arret du naming service")
os.system("killall -9 omniNames")
# -----------------------------------------------------------------------------
#
def message(code, msg=''):
- if msg: print msg
+ if msg: print(msg)
sys.exit(code)
import sys,os,string,glob,time,signal,pickle,getopt
try:
for o, a in opts:
if o in ('-h', '--help'):
- print usage
+ print(usage)
sys.exit(1)
elif o in ('-g', '--gui'):
with_gui=1
fpid=open(filedict, 'r')
found = 1
except:
- print "le fichier %s des process SALOME n'est pas accessible"% filedict
+ print("le fichier %s des process SALOME n'est pas accessible"% filedict)
if found:
process_id=pickle.load(fpid)
process_id={}
os.remove(filedict)
-except getopt.error, msg:
- print usage
+except getopt.error as msg:
+ print(usage)
sys.exit(1)
# -----------------------------------------------------------------------------
kernel_root_dir=os.environ["KERNEL_ROOT_DIR"]
modules_root_dir["KERNEL"]=kernel_root_dir
except:
- print usage
+ print(usage)
sys.exit(1)
for module in liste_modules :
module_root_dir=os.environ[module +"_ROOT_DIR"]
modules_root_dir[module]=module_root_dir
except:
- print usage
+ print(usage)
sys.exit(1)
# il faut KERNEL en premier dans la liste des modules
#print liste_modules
#print modules_root_dir
-os.environ["SALOMEPATH"]=":".join(modules_root_dir.values())
+os.environ["SALOMEPATH"]=":".join(list(modules_root_dir.values()))
if "SUPERV" in liste_modules:with_container_superv=1
for module in liste_modules:
module_root_dir=modules_root_dir[module]
module_cata=module+"Catalog.xml"
- print " ", module_cata
+ print(" ", module_cata)
cata_path.extend(glob.glob(os.path.join(module_root_dir,"share","salome","resources",module_cata)))
self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2
SalomeDSServer().run()
if "GEOM" in liste_modules:
- print "GEOM OCAF Resources"
+ print("GEOM OCAF Resources")
os.environ["CSF_GEOMDS_ResourcesDefaults"]=os.path.join(modules_root_dir["GEOM"],"share","salome","resources")
#session.GetInterface()
end_time = os.times()
- print
- print "Start SALOME, elpased time : %5.1f seconds"% (end_time[4] - init_time[4])
+ print()
+ print("Start SALOME, elpased time : %5.1f seconds"% (end_time[4] - init_time[4]))
return clt
try:
clt = startSalome()
except:
- print
- print
- print "--- erreur au lancement Salome ---"
+ print()
+ print()
+ print("--- erreur au lancement Salome ---")
#print process_id
pickle.dump(process_id,fpid)
fpid.close()
- print """
+ print("""
Sauvegarde du dictionnaire des process dans , %s
Pour tuer les process SALOME, executer : python killSalome.py depuis
Pour lancer uniquement le GUI, executer startGUI() depuis le present interpreteur,
s'il n'est pas fermé.
- """ % filedict
+ """ % filedict)
#
# Impression arborescence Naming Service
#
if clt != None:
- print
- print " --- registered objects tree in Naming Service ---"
+ print()
+ print(" --- registered objects tree in Naming Service ---")
clt.showNS()
session=clt.waitNS("/Kernel/Session")
catalog=clt.waitNS("/Kernel/ModulCatalog")
f.write(PYTHONSTARTUP)
f.close()
- exec PYTHONSTARTUP in {}
+ exec(PYTHONSTARTUP, {})
#
def killSalome():
- print "arret des serveurs SALOME"
- for pid, cmd in process_id.items():
- print "arret du process %s : %s"% (pid, cmd[0])
+ print("arret des serveurs SALOME")
+ for pid, cmd in list(process_id.items()):
+ print("arret du process %s : %s"% (pid, cmd[0]))
try:
os.kill(pid,signal.SIGKILL)
except:
- print " ------------------ process %s : %s inexistant"% (pid, cmd[0])
- print "arret du naming service"
+ print(" ------------------ process %s : %s inexistant"% (pid, cmd[0]))
+ print("arret du naming service")
os.system("killall -9 omniNames")
# -----------------------------------------------------------------------------
#
def message(code, msg=''):
- if msg: print msg
+ if msg: print(msg)
sys.exit(code)
import sys,os,string,glob,time,signal,pickle,getopt
try:
for o, a in opts:
if o in ('-h', '--help'):
- print usage
+ print(usage)
sys.exit(1)
elif o in ('-g', '--gui'):
with_gui=1
fpid=open(filedict, 'r')
found = 1
except:
- print "le fichier %s des process SALOME n'est pas accessible"% filedict
+ print("le fichier %s des process SALOME n'est pas accessible"% filedict)
if found:
process_id=pickle.load(fpid)
process_id={}
os.remove(filedict)
-except getopt.error, msg:
- print usage
+except getopt.error as msg:
+ print(usage)
sys.exit(1)
# -----------------------------------------------------------------------------
kernel_root_dir=os.environ["KERNEL_ROOT_DIR"]
modules_root_dir["KERNEL"]=kernel_root_dir
except:
- print usage
+ print(usage)
sys.exit(1)
for module in liste_modules :
module_root_dir=os.environ[module +"_ROOT_DIR"]
modules_root_dir[module]=module_root_dir
except:
- print usage
+ print(usage)
sys.exit(1)
# il faut KERNEL en premier dans la liste des modules
#print liste_modules
#print modules_root_dir
-os.environ["SALOMEPATH"]=":".join(modules_root_dir.values())
+os.environ["SALOMEPATH"]=":".join(list(modules_root_dir.values()))
if "SUPERV" in liste_modules:with_container_superv=1
for module in liste_modules:
module_root_dir=modules_root_dir[module]
module_cata=module+"Catalog.xml"
- print " ", module_cata
+ print(" ", module_cata)
cata_path.extend(glob.glob(os.path.join(module_root_dir,"share","salome","resources",module_cata)))
self.CMD=self.SCMD1 + [string.join(cata_path,':')] + self.SCMD2
SalomeDSServer().run()
if "GEOM" in liste_modules:
- print "GEOM OCAF Resources"
+ print("GEOM OCAF Resources")
os.environ["CSF_GEOMDS_ResourcesDefaults"]=os.path.join(modules_root_dir["GEOM"],"share","salome","resources")
#session.GetInterface()
end_time = os.times()
- print
- print "Start SALOME, elpased time : %5.1f seconds"% (end_time[4] - init_time[4])
+ print()
+ print("Start SALOME, elpased time : %5.1f seconds"% (end_time[4] - init_time[4]))
return clt
try:
clt = startSalome()
except:
- print
- print
- print "--- erreur au lancement Salome ---"
+ print()
+ print()
+ print("--- erreur au lancement Salome ---")
#print process_id
pickle.dump(process_id,fpid)
fpid.close()
- print """
+ print("""
Sauvegarde du dictionnaire des process dans , %s
Pour tuer les process SALOME, executer : python killSalome.py depuis
Pour lancer uniquement le GUI, executer startGUI() depuis le present interpreteur,
s'il n'est pas fermé.
- """ % filedict
+ """ % filedict)
#
# Impression arborescence Naming Service
#
if clt != None:
- print
- print " --- registered objects tree in Naming Service ---"
+ print()
+ print(" --- registered objects tree in Naming Service ---")
clt.showNS()
session=clt.waitNS("/Kernel/Session")
catalog=clt.waitNS("/Kernel/ModulCatalog")
f.write(PYTHONSTARTUP)
f.close()
- exec PYTHONSTARTUP in {}
+ exec(PYTHONSTARTUP, {})
"""Optional method called on initialization.
The type of "input" is returned by "getTCForAlgoInit"
"""
- print "Algo initialize, input = ", input.getIntValue()
+ print("Algo initialize, input = ", input.getIntValue())
def startToTakeDecision(self):
"""This method is called only once to launch the algorithm. It must
pool, do nothing (wait for more samples), or empty the pool and
return to finish the evaluation.
"""
- print "startToTakeDecision"
+ print("startToTakeDecision")
# fill the pool with samples
iter=0
self.pool.pushInSample(0, 0.5)
currentId=self.pool.getCurrentId()
valIn = self.pool.getCurrentInSample().getDoubleValue()
valOut = self.pool.getCurrentOutSample().getIntValue()
- print "Compute currentId=%s, valIn=%s, valOut=%s" % (currentId, valIn, valOut)
+ print("Compute currentId=%s, valIn=%s, valOut=%s" % (currentId, valIn, valOut))
iter=iter+1
if iter < 3:
def finish(self):
"""Optional method called when the algorithm has finished, successfully
or not, to perform any necessary clean up."""
- print "Algo finish"
+ print("Algo finish")
self.pool.destroyAll()
def getAlgoResult(self):
"""Optional method called on initialization.
The type of "input" is returned by "getTCForAlgoInit"
"""
- print "Algo initialize, input = ", input.getIntValue()
+ print("Algo initialize, input = ", input.getIntValue())
def start(self):
"""Start to fill the pool with samples to evaluate."""
- print "Algo start "
+ print("Algo start ")
self.iter=0
# pushInSample(id, value)
self.pool.pushInSample(self.iter, 0.5)
currentId=self.pool.getCurrentId()
valIn = self.pool.getCurrentInSample().getDoubleValue()
valOut = self.pool.getCurrentOutSample().getIntValue()
- print "Algo takeDecision currentId=%s, valIn=%s, valOut=%s" % (currentId, valIn, valOut)
+ print("Algo takeDecision currentId=%s, valIn=%s, valOut=%s" % (currentId, valIn, valOut))
self.iter=self.iter+1
if self.iter < 3:
def finish(self):
"""Optional method called when the algorithm has finished, successfully
or not, to perform any necessary clean up."""
- print "Algo finish"
+ print("Algo finish")
self.pool.destroyAll()
def getAlgoResult(self):
rootContext = obj._narrow(CosNaming.NamingContext)
if rootContext is None:
- print "Failed to narrow the root naming context"
+ print("Failed to narrow the root naming context")
sys.exit(1)
# Resolve the name "test.my_context/Echo.Object"
try:
obj = rootContext.resolve(name)
-except CosNaming.NamingContext.NotFound, ex:
- print "Name not found"
+except CosNaming.NamingContext.NotFound as ex:
+ print("Name not found")
sys.exit(1)
# Narrow the object to an eo::Echo
echo = obj._narrow(eo.Echo)
if echo is None:
- print "Object reference is not an eo::Echo"
+ print("Object reference is not an eo::Echo")
sys.exit(1)
# Invoke the echoString operation
message = "Hello from Python"
result = echo.echoString(message)
-print "I said '%s'. The object said '%s'." % (message,result)
+print("I said '%s'. The object said '%s'." % (message,result))
"""
struct S1
s2=eo.S2(s1)
r=echo.echoStruct(s2)
-print r
+print(r)
s3=eo.S3(x=1,y=2,s="aa",b=True,ob=None)
r=echo.echoStruct2(s3)
-print r
+print(r)
ob=echo.createObj(3)
-print ob
+print(ob)
oc=echo.createC()
-print oc
+print(oc)
s3=eo.S3(x=1,y=2,s="aa",b=True,ob=ob)
r=echo.echoStruct2(s3)
-print r
+print(r)
s3=eo.S3(x=1,y=2,s="aa",b=True,ob=oc)
r=echo.echoStruct2(s3)
-print r
+print(r)
r=echo.echoObjectVec([ob,ob])
-print r
+print(r)
r=echo.echoObjectVec([oc,oc])
-print r
+print(r)
r=echo.echoObjectVec([ob,oc])
-print r
+print(r)
#echo.shutdown()
The last node gives the sum of rank n (=2**n) and also a direct calculation of 2**n.
"""
- print """
+ print("""
<proc>
<!-- types -->
<!-- inline -->
<inline name="node_0_0" >
<script><code>
import time
-from decimal import *"""
- print "getcontext().prec = " + str(1+n/3)
- print """
+from decimal import *""")
+ print("getcontext().prec = " + str(1+n/3))
+ print("""
aa=Decimal(a)
bb=Decimal(b)
cc=aa+bb
<inport name="a" type="string"/>
<inport name="b" type="string"/>
<outport name="c" type="string"/>
-</inline>"""
+</inline>""")
- print """
+ print("""
<inline name="collect" >
-<script><code>"""
- print "import time"
- print "from decimal import *"
- print "getcontext().prec = " + str(1+n/3)
- print "tot = Decimal(0)"
- print "for i in range (" + str(n+1) + "):"
- print " v='a' + str(i)"
- print " tot+=Decimal(eval(v))"
- print "print tot"
- print "result=str(tot)"
- print "ref=Decimal(2)**" + str(n)
- print "reference=str(ref)"
- print "time.sleep(1)"
- print "</code></script>"
+<script><code>""")
+ print("import time")
+ print("from decimal import *")
+ print("getcontext().prec = " + str(1+n/3))
+ print("tot = Decimal(0)")
+ print("for i in range (" + str(n+1) + "):")
+ print(" v='a' + str(i)")
+ print(" tot+=Decimal(eval(v))")
+ print("print tot")
+ print("result=str(tot)")
+ print("ref=Decimal(2)**" + str(n))
+ print("reference=str(ref)")
+ print("time.sleep(1)")
+ print("</code></script>")
for i in range (n+1):
inport='<inport name="a' + str(i) + '" type="string"/>'
- print inport
+ print(inport)
pass
- print '<outport name="result" type="string"/>'
- print '<outport name="reference" type="string"/>'
- print "</inline>"
- print
+ print('<outport name="result" type="string"/>')
+ print('<outport name="reference" type="string"/>')
+ print("</inline>")
+ print()
for i in range (1,n+1):
for j in range (i+1):
node="node_" + str(i) +"_" + str(j)
nodetxt='<node name="'+node+'" type="node_0_0"></node>'
- print nodetxt
+ print(nodetxt)
pass
pass
- print """
+ print("""
<!-- service -->
<!-- control -->
- """
+ """)
for i in range (n):
for j in range (i+1):
tonode2="node_" + str(i+1) +"_" + str(j+1)
control1='<control> <fromnode>'+fromnode+'</fromnode> <tonode>'+tonode1+'</tonode> </control>'
control2='<control> <fromnode>'+fromnode+'</fromnode> <tonode>'+tonode2+'</tonode> </control>'
- print control1
- print control2
+ print(control1)
+ print(control2)
pass
pass
for i in range (n+1):
fromnode="node_" + str(n) +"_" + str(i)
control='<control> <fromnode>'+fromnode+'</fromnode> <tonode>collect</tonode> </control>'
- print control
+ print(control)
pass
- print """
+ print("""
<!-- datalinks -->
- """
+ """)
for i in range (n):
for j in range (i+1):
datafrom='<fromnode>' + fromnode + '</fromnode> <fromport>c</fromport>'
datato1 ='<tonode>' + tonode1 + '</tonode> <toport>b</toport>'
datato2 ='<tonode>' + tonode2 + '</tonode> <toport>a</toport>'
- print '<datalink>'
- print ' ' + datafrom
- print ' ' + datato1
- print '</datalink>'
- print '<datalink>'
- print ' ' + datafrom
- print ' ' + datato2
- print '</datalink>'
+ print('<datalink>')
+ print(' ' + datafrom)
+ print(' ' + datato1)
+ print('</datalink>')
+ print('<datalink>')
+ print(' ' + datafrom)
+ print(' ' + datato2)
+ print('</datalink>')
pass
pass
for i in range (n+1):
datafrom='<fromnode>' + fromnode + '</fromnode> <fromport>c</fromport>'
toport='a' + str(i)
datato ='<tonode>collect</tonode> <toport>' + toport + '</toport>'
- print '<datalink>'
- print ' ' + datafrom
- print ' ' + datato
- print '</datalink>'
+ print('<datalink>')
+ print(' ' + datafrom)
+ print(' ' + datato)
+ print('</datalink>')
- print """
+ print("""
<!--parameters -->
- """
+ """)
- print """
+ print("""
<parameter>
<tonode>node_0_0</tonode> <toport>a</toport>
<value><string>0</string></value>
<tonode>node_0_0</tonode> <toport>b</toport>
<value><string>1</string></value>
</parameter>
- """
+ """)
for i in range (1,n+1):
node1="node_" + str(i) +"_" + str(0)
node2="node_" + str(i) +"_" + str(i)
tonode1 =' <tonode>' + node1 + '</tonode> <toport>a</toport>'
tonode2 =' <tonode>' + node2 + '</tonode> <toport>b</toport>'
- print '<parameter>'
- print tonode1
- print ' <value><string>0</string></value>'
- print '</parameter>'
+ print('<parameter>')
+ print(tonode1)
+ print(' <value><string>0</string></value>')
+ print('</parameter>')
- print '<parameter>'
- print tonode2
- print ' <value><string>0</string></value>'
- print '</parameter>'
+ print('<parameter>')
+ print(tonode2)
+ print(' <value><string>0</string></value>')
+ print('</parameter>')
- print """
+ print("""
</proc>
- """
+ """)
if __name__ == "__main__":
import sys
if rank <2:
raise ValueError("rank must be >1")
except (IndexError, ValueError):
- print usage%(sys.argv[0])
+ print(usage%(sys.argv[0]))
sys.exit(1)
pass
triangle(rank)
The last node gives the sum of rank n (=2**n) and also a direct calculation of 2**n.
"""
- print debut
+ print(debut)
- print """
+ print("""
<inline name="collect" >
-<script><code>"""
- print "tot = 0"
- print "for i in range (" + str(n+1) + "):"
- print " v='a' + str(i)"
- print " tot+=eval(v)"
- print "result=tot"
- print "print result"
- print "reference=2**" + str(n)
- print "print reference"
- print "</code></script>"
+<script><code>""")
+ print("tot = 0")
+ print("for i in range (" + str(n+1) + "):")
+ print(" v='a' + str(i)")
+ print(" tot+=eval(v)")
+ print("result=tot")
+ print("print result")
+ print("reference=2**" + str(n))
+ print("print reference")
+ print("</code></script>")
for i in range (n+1):
inport='<inport name="a' + str(i) + '" type="int"/>'
- print inport
+ print(inport)
pass
- print '<outport name="result" type="int"/>'
- print '<outport name="reference" type="int"/>'
- print "</inline>"
- print
+ print('<outport name="result" type="int"/>')
+ print('<outport name="reference" type="int"/>')
+ print("</inline>")
+ print()
for i in range (1,n+1):
for j in range (i+1):
node="node_" + str(i) +"_" + str(j)
nodetxt='<node name="'+node+'" type="node_0_0"></node>'
- print nodetxt
+ print(nodetxt)
pass
pass
- print """
+ print("""
<!-- service -->
<!-- control -->
- """
+ """)
for i in range (n):
for j in range (i+1):
tonode2="node_" + str(i+1) +"_" + str(j+1)
control1='<control> <fromnode>'+fromnode+'</fromnode> <tonode>'+tonode1+'</tonode> </control>'
control2='<control> <fromnode>'+fromnode+'</fromnode> <tonode>'+tonode2+'</tonode> </control>'
- print control1
- print control2
+ print(control1)
+ print(control2)
pass
pass
- print """
+ print("""
<!-- datalinks -->
- """
+ """)
for i in range (n):
for j in range (i+1):
datafrom='<fromnode>' + fromnode + '</fromnode> <fromport>c</fromport>'
datato1 ='<tonode>' + tonode1 + '</tonode> <toport>b</toport>'
datato2 ='<tonode>' + tonode2 + '</tonode> <toport>a</toport>'
- print '<datalink>'
- print ' ' + datafrom
- print ' ' + datato1
- print '</datalink>'
- print '<datalink>'
- print ' ' + datafrom
- print ' ' + datato2
- print '</datalink>'
+ print('<datalink>')
+ print(' ' + datafrom)
+ print(' ' + datato1)
+ print('</datalink>')
+ print('<datalink>')
+ print(' ' + datafrom)
+ print(' ' + datato2)
+ print('</datalink>')
pass
pass
datafrom='<fromnode>' + fromnode + '</fromnode> <fromport>c</fromport>'
toport='a' + str(i)
datato ='<tonode>collect</tonode> <toport>' + toport + '</toport>'
- print '<datalink>'
- print ' ' + datafrom
- print ' ' + datato
- print '</datalink>'
+ print('<datalink>')
+ print(' ' + datafrom)
+ print(' ' + datato)
+ print('</datalink>')
- print """
+ print("""
<!--parameters -->
- """
+ """)
- print """
+ print("""
<parameter>
<tonode>node_0_0</tonode> <toport>a</toport>
<value><int>0</int></value>
<tonode>node_0_0</tonode> <toport>b</toport>
<value><int>1</int></value>
</parameter>
- """
+ """)
for i in range (1,n+1):
node1="node_" + str(i) +"_" + str(0)
node2="node_" + str(i) +"_" + str(i)
tonode1 =' <tonode>' + node1 + '</tonode> <toport>a</toport>'
tonode2 =' <tonode>' + node2 + '</tonode> <toport>b</toport>'
- print '<parameter>'
- print tonode1
- print ' <value><int>0</int></value>'
- print '</parameter>'
+ print('<parameter>')
+ print(tonode1)
+ print(' <value><int>0</int></value>')
+ print('</parameter>')
- print '<parameter>'
- print tonode2
- print ' <value><int>0</int></value>'
- print '</parameter>'
+ print('<parameter>')
+ print(tonode2)
+ print(' <value><int>0</int></value>')
+ print('</parameter>')
- print """
+ print("""
</proc>
- """
+ """)
if __name__ == "__main__":
import sys
if rank >31:
raise ValueError("rank must be <32")
except (IndexError, ValueError):
- print usage%(sys.argv[0])
+ print(usage%(sys.argv[0]))
sys.exit(1)
pass
triangle(rank)
"""Optional method called on initialization.
The type of "input" is returned by "getTCForAlgoInit"
"""
- print "Algo initialize, input = ", input.getIntValue()
+ print("Algo initialize, input = ", input.getIntValue())
def start(self):
"""Start to fill the pool with samples to evaluate."""
- print "Algo start "
+ print("Algo start ")
self.iter=0
# pushInSample(id, value)
self.pool.pushInSample(self.iter, 1)
currentId=self.pool.getCurrentId()
valIn = self.pool.getCurrentInSample().getIntValue()
valOut = self.pool.getCurrentOutSample().getIntValue()
- print "Algo takeDecision currentId=%s, valIn=%s, valOut=%s" % (currentId, valIn, valOut)
+ print("Algo takeDecision currentId=%s, valIn=%s, valOut=%s" % (currentId, valIn, valOut))
self.iter=self.iter+1
if self.iter < 3:
def finish(self):
"""Optional method called when the algorithm has finished, successfully
or not, to perform any necessary clean up."""
- print "Algo finish"
+ print("Algo finish")
self.pool.destroyAll()
def getAlgoResult(self):
"""Optional method called on initialization.
The type of "input" is returned by "getTCForAlgoInit"
"""
- print "Algo initialize, input = ", input.getIntValue()
+ print("Algo initialize, input = ", input.getIntValue())
def start(self):
"""Start to fill the pool with samples to evaluate."""
- print "Algo start "
+ print("Algo start ")
self.iter=0
# pushInSample(id, value)
self.pool.pushInSample(self.iter, 1)
currentId=self.pool.getCurrentId()
valIn = self.pool.getCurrentInSample().getIntValue()
valOut = self.pool.getCurrentOutSample().getIntValue()
- print "Algo takeDecision currentId=%s, valIn=%s, valOut=%s" % (currentId, valIn, valOut)
+ print("Algo takeDecision currentId=%s, valIn=%s, valOut=%s" % (currentId, valIn, valOut))
self.iter=self.iter+1
if self.iter < 3:
def finish(self):
"""Optional method called when the algorithm has finished, successfully
or not, to perform any necessary clean up."""
- print "Algo finish"
+ print("Algo finish")
self.pool.destroyAll()
def getAlgoResult(self):
def test1_edit(self):
p = self.r.createProc("pr")
- print p.typeMap
+ print(p.typeMap)
t=p.getTypeCode("double")
- print t.kind()
+ print(t.kind())
t=p.typeMap["double"]
td=p.createType("double","double")
ti=p.createType("int","int")
tc1=p.createInterfaceTc("","Obj",[])
- print tc1.name(),tc1.id()
+ print(tc1.name(),tc1.id())
tc2=p.createInterfaceTc("","Obj2",[tc1])
- print tc2.name(),tc2.id()
+ print(tc2.name(),tc2.id())
tc3=p.createSequenceTc("","seqdbl",td)
- print tc3.name(),tc3.id(),tc3.contentType()
+ print(tc3.name(),tc3.id(),tc3.contentType())
tc4=p.createSequenceTc("","seqObj2",tc2)
tc5=p.createSequenceTc("","seqint",ti)
- print tc4.name(),tc4.id()
- print tc4.isA(tc1),0
- print tc2.isA(tc1),1
- print tc1.isA(tc2),0
- print td.isA(ti),0
- print td.isAdaptable(ti),1
- print ti.isAdaptable(td),0
- print tc5.isAdaptable(tc3),0
- print tc3.isAdaptable(tc5),1
+ print(tc4.name(),tc4.id())
+ print(tc4.isA(tc1),0)
+ print(tc2.isA(tc1),1)
+ print(tc1.isA(tc2),0)
+ print(td.isA(ti),0)
+ print(td.isAdaptable(ti),1)
+ print(ti.isAdaptable(td),0)
+ print(tc5.isAdaptable(tc3),0)
+ print(tc3.isAdaptable(tc5),1)
n=self.r.createScriptNode("","node1")
n.setScript("print 'coucou1'")
retex=None
try:
inport.edInitXML("<value><intt>5</int></value>")
- except ValueError, ex:
- print "Value Error: ", ex
+ except ValueError as ex:
+ print("Value Error: ", ex)
retex=ex
- except pilot.Exception,ex:
- print "YACS exception:",ex.what()
+ except pilot.Exception as ex:
+ print("YACS exception:",ex.what())
retex=ex.what()
- self.assert_(retex is not None, "exception not raised, or wrong type")
+ self.assertTrue(retex is not None, "exception not raised, or wrong type")
inport.edInitXML("<value><int>5</int></value>")
# --- create script node node2
try:
self.e.RunW(p,0)
- except pilot.Exception,ex:
- print ex.what()
+ except pilot.Exception as ex:
+ print(ex.what())
self.fail(ex)
#self.e.displayDot(p)
def test1_StepByStep(self):
# --- execution step by step
- print "================= Start of STEPBYSTEP ==================="
+ print("================= Start of STEPBYSTEP ===================")
self.e.setExecMode(1) # YACS::STEPBYSTEP
run1 = threading.Thread(None, self.e.RunPy, "stepbystep", (self.p,0))
self.e.waitPause()
#e.displayDot(p)
bp = self.e.getTasksToLoad()
- print "nexts possible steps = ", bp
+ print("nexts possible steps = ", bp)
if len(bp) > 0:
tte= bp[-1:] # only one node at each step, the last one in the list
r = self.e.setStepsToExecute(tte)
else:
tocont = False
pass
- print "toContinue = ", tocont
+ print("toContinue = ", tocont)
pass
self.e.resumeCurrentBreakPoint()
self.assertEqual(106, self.p.getChildByName('c0.c1.n1').getEffectiveState())
self.assertEqual(999, self.p.getChildByName('c0.n2').getEffectiveState())
self.assertEqual(888, self.p.getChildByName('node62').getEffectiveState())
- print "================= End of STEPBYSTEP ====================="
+ print("================= End of STEPBYSTEP =====================")
pass
def test2_StopToBreakpoint(self):
# --- start execution, set a breakpoint before node48, then continue
time.sleep(1)
- print "================= Start of BREAKPOINT ==================="
+ print("================= Start of BREAKPOINT ===================")
brp=['node48']
self.e.setListOfBreakPoints(brp)
self.e.setExecMode(2) # YACS::STOPBEFORENODES
time.sleep(0.1)
self.e.waitPause()
#self.e.displayDot(p)
- print "================= reach BREAKPOINT ======================"
+ print("================= reach BREAKPOINT ======================")
# --- resume from breakpoint
- print "=========== BREAKPOINT, start RESUME ===================="
+ print("=========== BREAKPOINT, start RESUME ====================")
time.sleep(1)
self.e.setExecMode(0) # YACS::CONTINUE
self.e.resumeCurrentBreakPoint()
self.assertEqual(106, self.p.getChildByName('c0.c1.n1').getEffectiveState())
self.assertEqual(999, self.p.getChildByName('c0.n2').getEffectiveState())
self.assertEqual(888, self.p.getChildByName('node62').getEffectiveState())
- print "================= End of RESUME ========================="
+ print("================= End of RESUME =========================")
pass
def test3_RunWithoutBreakpoints(self):
# --- start execution, run without breakpoints
time.sleep(1)
- print "================= Start of CONTINUE ====================="
+ print("================= Start of CONTINUE =====================")
self.e.setExecMode(0) # YACS::CONTINUE
run3 = threading.Thread(None, self.e.RunPy, "continue", (self.p,0))
run3.start()
self.assertEqual(106, self.p.getChildByName('c0.c1.n1').getEffectiveState())
self.assertEqual(999, self.p.getChildByName('c0.n2').getEffectiveState())
self.assertEqual(888, self.p.getChildByName('node62').getEffectiveState())
- print "================= End of CONTINUE ======================="
+ print("================= End of CONTINUE =======================")
pass
def test4_StopOnError(self):
# --- stop execution on first error and save state
time.sleep(1)
- print "================= Start of STOPONERROR =================="
+ print("================= Start of STOPONERROR ==================")
self.e.setStopOnError()
run4 = threading.Thread(None, self.e.RunPy, "continue", (self.p,0))
run4.start()
#self.e.displayDot(self.p)
s13 = self.p.getChildByName('node13').getEffectiveState()
s43 = self.p.getChildByName('node43').getEffectiveState()
- self.assert_((s13==999) or (s43==999))
- print "================= End of STOPONERROR ====================="
+ self.assertTrue((s13==999) or (s43==999))
+ print("================= End of STOPONERROR =====================")
pass
def test5_PartialExec(self):
# --- stop execution after breakpoint
time.sleep(1)
- print "================= Start of PARTIALEXEC ==================="
+ print("================= Start of PARTIALEXEC ===================")
brp=['node35']
self.e.setListOfBreakPoints(brp)
self.e.setExecMode(2) # YACS::STOPBEFORENODES
#self.e.displayDot(self.p)
self.assertEqual(106, self.p.getChildByName('node34').getEffectiveState())
self.assertEqual(101, self.p.getChildByName('node35').getEffectiveState())
- print "================= reach BREAKPOINT PARTIAL EXEC =========="
+ print("================= reach BREAKPOINT PARTIAL EXEC ==========")
pass
pass
retex=None
try:
p = self.l.load("nonexisting")
- except IOError, ex:
- print "IO Error: ", ex
+ except IOError as ex:
+ print("IO Error: ", ex)
retex=ex
#except pilot.invalid_argument,ex:
# print "invalid_argument:",ex.what()
# retex=ex.what()
- self.assert_(retex is not None, "exception not raised, or wrong type")
+ self.assertTrue(retex is not None, "exception not raised, or wrong type")
pass
def test2_parseError(self):
retex=None
try:
p = self.l.load("samples/bid.xml")
- except ValueError,ex:
- print "Caught ValueError Exception:",ex
+ except ValueError as ex:
+ print("Caught ValueError Exception:",ex)
retex = ex
expected="LogRecord: parser:ERROR:from node node5 does not exist in control link: node5->b2 context: b1. (samples/bid.xml:53)\n"
- self.assert_(p.getLogger("parser").getStr() == expected, "error not found: "+p.getLogger("parser").getStr())
+ self.assertTrue(p.getLogger("parser").getStr() == expected, "error not found: "+p.getLogger("parser").getStr())
pass
def test3_normal(self):
# --- File exists and no parsing problem
try:
p = self.l.load("samples/aschema.xml")
- print p.getLogger("parser").getStr()
- print p
- print p.getName()
- for k in p.typeMap: print k
- for k in p.nodeMap: print k
- for k in p.inlineMap: print k
- for k in p.serviceMap: print k
- print self.e.getTasksToLoad()
+ print(p.getLogger("parser").getStr())
+ print(p)
+ print(p.getName())
+ for k in p.typeMap: print(k)
+ for k in p.nodeMap: print(k)
+ for k in p.inlineMap: print(k)
+ for k in p.serviceMap: print(k)
+ print(self.e.getTasksToLoad())
self.e.RunW(p,0)
self.assertEqual(106, p.getChildByName('node48').getEffectiveState())
- except pilot.Exception,ex:
- print "YACS exception:",ex
+ except pilot.Exception as ex:
+ print("YACS exception:",ex)
self.fail(ex)
pass
pass
"""test delete following creation from class"""
co=self.r.createContainer()
self.assertEqual(co.getRefCnt(), 1)
- self.assert_(co.thisown)
+ self.assertTrue(co.thisown)
del co
def test1(self):
"""test delete following creation from createContainer and delitem from containerMap"""
co=self.p.createContainer("c2")
del self.p.containerMap["c2"]
- self.assert_(co.thisown)
+ self.assertTrue(co.thisown)
self.assertEqual(co.getRefCnt(), 1)
del co
co=self.p.createContainer("c2")
self.p.containerMap["c2"]=co
del self.p.containerMap["c2"]
- self.assert_(co.thisown)
+ self.assertTrue(co.thisown)
self.assertEqual(co.getRefCnt(), 1)
del co
del self.p.containerMap["c9"]
self.assertEqual(co.getName(), "c9")
self.assertEqual(co.getRefCnt(), 1)
- self.assert_(co.thisown)
+ self.assertTrue(co.thisown)
del co
def test4(self):
del self.p.containerMap["c10"]
self.assertEqual(co.getName(), "c10")
self.assertEqual(co.getRefCnt(), 1)
- self.assert_(co.thisown)
+ self.assertTrue(co.thisown)
del co
def test5(self):
del self.p
self.assertEqual(co.getName(), "c10")
self.assertEqual(co.getRefCnt(), 1)
- self.assert_(co.thisown)
+ self.assertTrue(co.thisown)
del co
def test6(self):
"""test ownership of container on getitem from containerMap"""
co=self.p.createContainer("c8")
self.assertEqual(co.getRefCnt(), 2)
- self.assert_(co.thisown)
+ self.assertTrue(co.thisown)
del co
self.assertEqual(self.p.containerMap["c8"].getRefCnt(), 2) # +1 for getitem
co=self.p.containerMap["c8"]
self.assertEqual(co.getRefCnt(), 2)
- self.assert_(co.thisown)
+ self.assertTrue(co.thisown)
del co
self.assertEqual(self.p.containerMap["c8"].getRefCnt(), 2) # +1 for getitem
del self.p.containerMap["c8"]
def test9(self):
"""test method values"""
self.p.createContainer("c8")
- for co in self.p.containerMap.values():
- self.assert_(co.thisown)
+ for co in list(self.p.containerMap.values()):
+ self.assertTrue(co.thisown)
self.assertEqual(co.getRefCnt(), 2)
def test10(self):
"""test method items"""
self.p.createContainer("c8")
- for k,co in self.p.containerMap.items():
- self.assert_(co.thisown)
+ for k,co in list(self.p.containerMap.items()):
+ self.assertTrue(co.thisown)
self.assertEqual(co.getRefCnt(), 2)
def test11(self):
"""test method clear"""
co=self.p.createContainer("c8")
self.p.containerMap.clear()
- self.assert_(co.thisown)
+ self.assertTrue(co.thisown)
self.assertEqual(co.getRefCnt(), 1)
def test12(self):
co=self.p.createContainer("c8")
d={"c1":co}
self.p.containerMap.update(d)
- self.assert_(co.thisown)
+ self.assertTrue(co.thisown)
self.assertEqual(co.getRefCnt(), 3)
class TestTypeCodeRef(unittest.TestCase):
"""test delete following creation from createSequenceTc"""
tc=pilot.TypeCode(pilot.Double)
self.assertEqual(tc.getRefCnt(), 1)
- self.assert_(tc.thisown)
+ self.assertTrue(tc.thisown)
def test1(self):
"""test delete following creation from createInterfaceTc and delitem from typeMap"""
tc=self.p.createInterfaceTc("","obj",[])
del self.p.typeMap["obj"]
- self.assert_(tc.thisown)
+ self.assertTrue(tc.thisown)
self.assertEqual(tc.getRefCnt(), 1)
def test2(self):
tc=self.p.createInterfaceTc("","obj",[])
self.p.typeMap["obj"]=tc
del self.p.typeMap["obj"]
- self.assert_(tc.thisown)
+ self.assertTrue(tc.thisown)
self.assertEqual(tc.getRefCnt(), 1)
def test3(self):
self.assertEqual(tc.getRefCnt(), 2)
del self.p.typeMap["obj"]
self.assertEqual(tc.getRefCnt(), 1)
- self.assert_(tc.thisown)
+ self.assertTrue(tc.thisown)
def test4(self):
"""test delete from typeMap following creation from createInterfaceTc"""
tc=self.p.createInterfaceTc("","obj",[])
del self.p.typeMap["obj"]
self.assertEqual(tc.getRefCnt(), 1)
- self.assert_(tc.thisown)
+ self.assertTrue(tc.thisown)
def test5(self):
"""test existence TypeCode following delete proc"""
tc=self.p.createInterfaceTc("","obj",[])
del self.p
self.assertEqual(tc.getRefCnt(), 1)
- self.assert_(tc.thisown)
+ self.assertTrue(tc.thisown)
def test6(self):
"""test ownership of TypeCode on getitem from typeMap"""
tc=self.p.createInterfaceTc("","obj",[])
self.assertEqual(tc.getRefCnt(), 2)
- self.assert_(tc.thisown)
+ self.assertTrue(tc.thisown)
del tc
self.assertEqual(self.p.typeMap["obj"].getRefCnt(), 2) # +1 for getitem
tc=self.p.typeMap["obj"]
self.assertEqual(tc.getRefCnt(), 2)
- self.assert_(tc.thisown)
+ self.assertTrue(tc.thisown)
del tc
self.assertEqual(self.p.typeMap["obj"].getRefCnt(), 2) # +1 for getitem
del self.p.typeMap["obj"]
def test9(self):
"""test method values"""
self.p.createInterfaceTc("","obj",[])
- for tc in self.p.typeMap.values():
+ for tc in list(self.p.typeMap.values()):
if tc.name()!="obj":continue
- self.assert_(tc.thisown)
+ self.assertTrue(tc.thisown)
self.assertEqual(tc.getRefCnt(), 2)
def test10(self):
"""test method items"""
self.p.createInterfaceTc("","obj",[])
- for k,tc in self.p.typeMap.items():
+ for k,tc in list(self.p.typeMap.items()):
if tc.name()!="obj":continue
- self.assert_(tc.thisown)
+ self.assertTrue(tc.thisown)
self.assertEqual(tc.getRefCnt(), 2)
def test11(self):
"""test method clear"""
tc=self.p.createInterfaceTc("","obj",[])
self.p.typeMap.clear()
- self.assert_(tc.thisown)
+ self.assertTrue(tc.thisown)
self.assertEqual(tc.getRefCnt(), 1)
def test12(self):
tc=self.p.createInterfaceTc("","obj",[])
d={"c1":tc}
self.p.typeMap.update(d)
- self.assert_(tc.thisown)
+ self.assertTrue(tc.thisown)
self.assertEqual(tc.getRefCnt(), 3)
if __name__ == '__main__':
# --- stop execution after breakpoint
time.sleep(1)
- print "================= Start of PARTIALEXEC ==================="
+ print("================= Start of PARTIALEXEC ===================")
brp=['b1.b2.node1']
self.e.setListOfBreakPoints(brp)
self.e.setExecMode(2) # YACS::STOPBEFORENODES
#self.e.displayDot(self.p)
self.assertEqual(101, self.p.getChildByName('b1.b2.node1').getEffectiveState())
self.assertEqual(106, self.p.getChildByName('b1.node1').getEffectiveState())
- print "================= reach BREAKPOINT PARTIAL EXEC =========="
+ print("================= reach BREAKPOINT PARTIAL EXEC ==========")
pass
def test2_ExecFromLoadState(self):
# --- reload state from previous partial execution then exec
time.sleep(1)
- print "================= Start of EXECLOADEDSTATE ==============="
+ print("================= Start of EXECLOADEDSTATE ===============")
sp = loader.stateParser()
sl = loader.stateLoader(sp,self.p)
sl.parse('dumpPartialBloc2.xml')
self.assertEqual(106, self.p.getChildByName('b1.b2.node1').getEffectiveState())
self.assertEqual(106, self.p.getChildByName('b1.b2.node2').getEffectiveState())
self.assertEqual(106, self.p.getChildByName('b1.b2.loop1.node1').getEffectiveState())
- print "================= End of EXECLOADEDSTATE ================="
+ print("================= End of EXECLOADEDSTATE =================")
pass
s.save(saveSchema2)
e.RunW(p,0)
e.saveState(dumpSchema2)
- except ValueError, ex:
- print "Value Error: ", ex
+ except ValueError as ex:
+ print("Value Error: ", ex)
pb = "problem on " + fileOrig + " : ValueError"
self.fail(pb)
- except pilot.Exception,ex:
- print ex.what()
+ except pilot.Exception as ex:
+ print(ex.what())
pb = "problem on " + fileOrig + " : " + ex.what()
self.fail(pb)
except:
pass
print "coucou from script1-%i -> %s"%(dbg,str(datetime.datetime.now()-ref))
"""
- for i in xrange(nbOfNodes):
+ for i in range(nbOfNodes):
node0=self.r.createFuncNode("DistPython","node%i"%(i))
p.edAddChild(node0)
node0.setFname("ff")
st=datetime.datetime.now()
# 1st exec
ex.RunW(p,0)
- print "Time spend of test0 to run 1st %s"%(str(datetime.datetime.now()-st))
+ print("Time spend of test0 to run 1st %s"%(str(datetime.datetime.now()-st)))
self.assertEqual(p.getState(),pilot.DONE)
# 2nd exec using the same already launched remote python interpreters
st=datetime.datetime.now()
ex.RunW(p,0)
- print "Time spend of test0 to run 2nd %s"%(str(datetime.datetime.now()-st))
+ print("Time spend of test0 to run 2nd %s"%(str(datetime.datetime.now()-st)))
self.assertEqual(p.getState(),pilot.DONE)
# 3rd exec using the same already launched remote python interpreters
st=datetime.datetime.now()
ex.RunW(p,0)
- print "Time spend of test0 to run 3rd %s"%(str(datetime.datetime.now()-st))
+ print("Time spend of test0 to run 3rd %s"%(str(datetime.datetime.now()-st)))
self.assertEqual(p.getState(),pilot.DONE)
pass
aa+=1.
"""
#
- for i in xrange(nbOfNodes):
+ for i in range(nbOfNodes):
nodeMiddle=self.r.createFuncNode("Salome","node%i_1"%(i)) # PyFuncNode remote
p.edAddChild(nodeMiddle)
nodeMiddle.setFname("ff")
self.assertEqual(p.getState(),pilot.READY)
st=datetime.datetime.now()
ex.RunW(p,0)
- print "Time spend of test1 to 1st run %s"%(str(datetime.datetime.now()-st))
+ print("Time spend of test1 to 1st run %s"%(str(datetime.datetime.now()-st)))
self.assertEqual(p.getState(),pilot.DONE)
# 2nd exec
st=datetime.datetime.now()
ex.RunW(p,0)
- print "Time spend of test1 to 2nd run %s"%(str(datetime.datetime.now()-st))
+ print("Time spend of test1 to 2nd run %s"%(str(datetime.datetime.now()-st)))
self.assertEqual(p.getState(),pilot.DONE)
# 3rd exec
st=datetime.datetime.now()
ex.RunW(p,0)
- print "Time spend of test1 to 3rd run %s"%(str(datetime.datetime.now()-st))
+ print("Time spend of test1 to 3rd run %s"%(str(datetime.datetime.now()-st)))
self.assertEqual(p.getState(),pilot.DONE)
pass
self.assertEqual(p.getState(),pilot.READY)
st=datetime.datetime.now()
ex.RunW(p,0)
- print "Time spend of test2 to 1st run %s"%(str(datetime.datetime.now()-st))
+ print("Time spend of test2 to 1st run %s"%(str(datetime.datetime.now()-st)))
self.assertEqual(p.getState(),pilot.DONE)
self.assertAlmostEqual(refExpected,o9.getPyObj(),5)
# 2nd exec
st=datetime.datetime.now()
ex.RunW(p,0)
- print "Time spend of test2 to 2nd run %s"%(str(datetime.datetime.now()-st))
+ print("Time spend of test2 to 2nd run %s"%(str(datetime.datetime.now()-st)))
self.assertEqual(p.getState(),pilot.DONE)
self.assertAlmostEqual(refExpected,o9.getPyObj(),5)
# 3rd exec
st=datetime.datetime.now()
ex.RunW(p,0)
- print "Time spend of test2 to 3rd run %s"%(str(datetime.datetime.now()-st))
+ print("Time spend of test2 to 3rd run %s"%(str(datetime.datetime.now()-st)))
self.assertEqual(p.getState(),pilot.DONE)
self.assertAlmostEqual(refExpected,o9.getPyObj(),5)
pass
self.assertEqual(p.getState(),pilot.READY)
st=datetime.datetime.now()
ex.RunW(p,0)
- print "Time spend of test3 to 1st run %s"%(str(datetime.datetime.now()-st))
+ print("Time spend of test3 to 1st run %s"%(str(datetime.datetime.now()-st)))
self.assertEqual(p.getState(),pilot.DONE)
self.assertAlmostEqual(refExpected,o9.getPyObj(),5)
# 2nd exec
st=datetime.datetime.now()
ex.RunW(p,0)
- print "Time spend of test3 to 2nd run %s"%(str(datetime.datetime.now()-st))
+ print("Time spend of test3 to 2nd run %s"%(str(datetime.datetime.now()-st)))
self.assertEqual(p.getState(),pilot.DONE)
self.assertAlmostEqual(refExpected,o9.getPyObj(),5)
# 3rd exec
st=datetime.datetime.now()
ex.RunW(p,0)
- print "Time spend of test3 to 3rd run %s"%(str(datetime.datetime.now()-st))
+ print("Time spend of test3 to 3rd run %s"%(str(datetime.datetime.now()-st)))
self.assertEqual(p.getState(),pilot.DONE)
self.assertAlmostEqual(refExpected,o9.getPyObj(),5)
pass
self.assertEqual(n1.getState(),pilot.DONE)
n1.edGetSeqOfSamplesPort().getPyObj()
a,b,c=n1.getPassedResults(ex)
- self.assertEqual(a,range(6))
- self.assertEqual([elt.getPyObj() for elt in b],[[6L, 12L, 16L, 18L, -4L, 10L]])
+ self.assertEqual(a,list(range(6)))
+ self.assertEqual([elt.getPyObj() for elt in b],[[6, 12, 16, 18, -4, 10]])
self.assertEqual(c,['n10_o2_interceptor'])
pass
self.assertEqual(n1.getState(),pilot.FAILED)
n1.edGetSeqOfSamplesPort().getPyObj()
a,b,c=n1.getPassedResults(ex)
- self.assertEqual(a,range(3))
- self.assertEqual([elt.getPyObj() for elt in b],[[6L,12L,16L]])
+ self.assertEqual(a,list(range(3)))
+ self.assertEqual([elt.getPyObj() for elt in b],[[6,12,16]])
self.assertEqual(c,['n10_o2_interceptor'])
pass
n1.edGetSeqOfSamplesPort().getPyObj()
a,b,c=n1.getPassedResults(ex)
self.assertEqual(a,[0,1,2,4,5])
- self.assertEqual([elt.getPyObj() for elt in b],[[6L,12L,16L,-4L,10L]])
+ self.assertEqual([elt.getPyObj() for elt in b],[[6,12,16,-4,10]])
self.assertEqual(c,['n10_o2_interceptor'])
p.getChildByName("n1").getChildByName("n10").setScript("""
n1.edGetSeqOfSamplesPort().getPyObj()
a,b,c=n1.getPassedResults(ex)
self.assertEqual(a,[1,2,3,4,5])
- self.assertEqual([elt.getPyObj() for elt in b],[[12L,16L,18L,-4L,10L]])
+ self.assertEqual([elt.getPyObj() for elt in b],[[12,16,18,-4,10]])
self.assertEqual(c,['n10_o2_interceptor'])
pass
n1.edGetSeqOfSamplesPort().getPyObj()
a,b,c=n1.getPassedResults(ex)
self.assertEqual(a,[0,1,2,4,5])
- self.assertEqual([elt.getPyObj() for elt in b],[[6L,12L,16L,-4L,10L]])
+ self.assertEqual([elt.getPyObj() for elt in b],[[6,12,16,-4,10]])
self.assertEqual(c,['n10_o2_interceptor'])
p.getChildByName("n1").getChildByName("n10").setScript("""
#
self.assertEqual(n1.getState(),pilot.DONE)
self.assertEqual(p.getState(),pilot.DONE)
- self.assertEqual(p.getChildByName("n2").getOutputPort("o4").getPyObj(),[6L,12L,16L,63L,-4L,10L])
+ self.assertEqual(p.getChildByName("n2").getOutputPort("o4").getPyObj(),[6,12,16,63,-4,10])
pass
def test10(self):
n1.edGetSeqOfSamplesPort().getPyObj()
a,b,c=n1.getPassedResults(ex)
self.assertEqual(a,[1,3,5,7,9,11])
- self.assertEqual([elt.getPyObj() for elt in b],[[12L,36L,60L,84L,108L,132L]])
+ self.assertEqual([elt.getPyObj() for elt in b],[[12,36,60,84,108,132]])
self.assertEqual(c,['n10_o2_interceptor'])
p.getChildByName("n1").getChildByName("n10").setScript("""
#
self.assertEqual(n1.getState(),pilot.DONE)
self.assertEqual(p.getState(),pilot.DONE)
- self.assertEqual(p.getChildByName("n2").getOutputPort("o4").getPyObj(),[0L,12L,30L,36L,60L,60L,90L,84L,120L,108L,150L,132L])
+ self.assertEqual(p.getChildByName("n2").getOutputPort("o4").getPyObj(),[0,12,30,36,60,60,90,84,120,108,150,132])
pass
pass
a,b,c=n1.getPassedResults(ex)
self.assertEqual(a,[0,2,4,6,8,10])
- self.assertEqual([elt.getPyObj() for elt in b],[[0L,4L,8L,12L,16L,20L]])
+ self.assertEqual([elt.getPyObj() for elt in b],[[0,4,8,12,16,20]])
p.getChildByName("n0").setScript("o0=[ 3*elt for elt in range(12) ]")
p.getChildByName("n1").getChildByName("n10").setScript("""
#
self.assertEqual(n1.getState(),pilot.DONE)
self.assertEqual(p.getState(),pilot.DONE)
- self.assertEqual(p.getChildByName("n2").getOutputPort("o4").getPyObj(),[0L,5L,4L,15L,8L,25L,12L,35L,16L,45L,20L,55L])
+ self.assertEqual(p.getChildByName("n2").getOutputPort("o4").getPyObj(),[0,5,4,15,8,25,12,35,16,45,20,55])
pass
def test12(self):
#
node0=self.r.createForEachLoop("ForEachLoop_int0",ti)
p.edAddChild(node0)
- node0.edGetSeqOfSamplesPort().edInitPy(range(4))
+ node0.edGetSeqOfSamplesPort().edInitPy(list(range(4)))
node0.edGetNbOfBranchesPort().edInitInt(2)
#
node00=self.r.createBloc("Bloc0")
node0.edAddChild(node00)
node000_0=self.r.createForEachLoop("ForEachLoop_int1",ti)
node00.edAddChild(node000_0)
- node000_0.edGetSeqOfSamplesPort().edInitPy(range(4))
+ node000_0.edGetSeqOfSamplesPort().edInitPy(list(range(4)))
node000_0.edGetNbOfBranchesPort().edInitInt(3)
#
node0000=self.r.createBloc("Bloc1")
#
n00.edAddLink(n000.edGetSamplePort(),i0)
#
- n000.edGetSeqOfSamplesPort().edInitPy(range(10))
+ n000.edGetSeqOfSamplesPort().edInitPy(list(range(10)))
n000.edGetNbOfBranchesPort().edInitInt(2)
#
n01=r.createScriptNode("Salome","test23/check") ; n0bis.edAddChild(n01)
#
nb=4
outs=[]
- for i in xrange(nb):
+ for i in range(nb):
node=self.r.createScriptNode("Salome","node%d"%i)
node.setExecutionMode("remote")
node.setContainer(cont)
res=node.edAddOutputPort("res",ti)
p.edAddChild(node)
l=[]
- for i in xrange(nb):
+ for i in range(nb):
elt="i%d"%i
inp=node.edAddInputPort(elt,ti) ; l.append(elt)
p.edAddChild(node)
node.setScript("res="+"+".join(l))
p.edAddCFLink(b,node)
#
- for i in xrange(10):
+ for i in range(10):
p.init()
ex = pilot.ExecutorSwig()
self.assertEqual(p.getState(),pilot.READY)
self.assertEqual(p.getState(),pilot.DONE)
self.assertEqual(n1.getState(),pilot.DONE)
self.assertEqual(a,[0,1])
- self.assertEqual([elt.getPyObj() for elt in b],[[0L,2L]])
+ self.assertEqual([elt.getPyObj() for elt in b],[[0,2]])
#
p.getChildByName("n0").setScript("o0=[ 3*elt for elt in range(6) ]")
p.getChildByName("n1").getChildByName("n10").setScript("""
#
self.assertEqual(n1.getState(),pilot.DONE)
self.assertEqual(p.getState(),pilot.DONE)
- self.assertEqual(p.getChildByName("n2").getOutputPort("o4").getPyObj(),[0L,2L,10L,15L,20L,25L])
+ self.assertEqual(p.getChildByName("n2").getOutputPort("o4").getPyObj(),[0,2,10,15,20,25])
pass
pass
time.sleep(0.5)
state = procEx.getExecutorState()
isRunning = (state < 304)
- print "executorState: ", state
+ print("executorState: ", state)
pass
procEx.saveState("res.xml")
i+=1
pass
-print procEx.getOutPortValue(dico["poly_7"],"Pn")
-print procEx.getInPortValue(dico["poly_7"],"x")
-print procEx.getInPortValue(dico["poly_7"],"notAPort")
-print procEx.getInPortValue(dico["Legendre.loopIter"],"nsteps")
+print(procEx.getOutPortValue(dico["poly_7"],"Pn"))
+print(procEx.getInPortValue(dico["poly_7"],"x"))
+print(procEx.getInPortValue(dico["poly_7"],"notAPort"))
+print(procEx.getInPortValue(dico["Legendre.loopIter"],"nsteps"))
# -----------------------------------------------------------------------------
# --- schema with errors (echoSrv must be launched)
time.sleep(0.5)
state = procEx.getExecutorState()
isRunning = (state < 304)
- print "executorState: ", state
+ print("executorState: ", state)
pass
procEx.saveState("res2.xml")
i+=1
pass
-print procEx.getErrorDetails(dico["c1"])
-print procEx.getErrorDetails(dico["node13"])
+print(procEx.getErrorDetails(dico["c1"]))
+print(procEx.getErrorDetails(dico["node13"]))
# -----------------------------------------------------------------------------
# --- schema with errors
time.sleep(0.5)
state = procEx.getExecutorState()
isRunning = (state < 304)
- print "executorState: ", state
+ print("executorState: ", state)
pass
#procEx.resumeCurrentBreakPoint()
time.sleep(0.5)
state = procEx.getExecutorState()
isRunning = (state < 304)
- print "executorState: ", state
+ print("executorState: ", state)
pass
procEx.saveState("partialExec.xml")
time.sleep(0.5)
state = procEx.getExecutorState()
isRunning = (state < 304)
- print "executorState: ", state
+ print("executorState: ", state)
pass
procEx.saveState("finishExec.xml")
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:
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:
"""
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, False)
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()