pass
# kill processes
for process_id in process_ids:
- #print process_id
+ # print(process_id)
for pid, cmd in list(process_id.items()):
try:
os.kill(int(pid),signal.SIGKILL)
sys.stdout.write(out)
if err:
sys.stderr.write(err)
- #print 'Thank you for using SALOME!'
+ # print('Thank you for using SALOME!')
sys.exit(returncode)
except SalomeContextException as e:
import logging
salome_instance.stop()
if sys.platform == 'win32':
timer.cancel()
-# print "Exit test with status code:", res
+# print("Exit test with status code:", res)
# exit(res)
#
if __name__ == "__main__":
if not os.path.isfile("hello.py"):
with open("hello.py", "w") as f:
- f.write("print 'Hello!'")
+ f.write("print('Hello!')")
unittest.main()
#
# make hello.py
echo "
#!/usr/bin/env python
-print 'Hello\!'
+print('Hello\!')
" > ${BASE_DIR}/hello.py
# Build output folders
args = _opts
args['user_config'] = user_config
- #print "User Configuration file: ", args['user_config']
+ # print("User Configuration file: ", args['user_config'])
# set default values for options which are NOT set in config files
for aKey in listKeys:
elif os.path.exists( os.path.join(d2,"{0}.xml".format(salomeappname)) ):
dirs.append( d2 )
else:
- #print "* '"+m+"' should be deleted from ",args[modules_nam]
+ # print("* '"+m+"' should be deleted from ",args[modules_nam])
pass
# Test
# return arguments
os.environ[config_var] = os.pathsep.join(dirs)
- #print "Args: ", args
+ # print("Args: ", args)
return args
hname = getShortHostName();
else:
hname = socket.gethostname();
- #print "hname=",hname
+ # print("hname=",hname)
with open(os.environ["OMNIORB_CONFIG"]) as f:
ss = re.findall("NameService=corbaname::" + hname + ":\d+", f.read())
try:
os.mkdir(upath)
except:
- #print "Can't create " + upath
+ # print("Can't create " + upath)
pass
#os.system("touch " + upath + "/dummy")
#os.system("rm -f " + upath + "/omninames* " + upath + "/dummy " + upath + "/*.log")
#aSedCommand="s/.*NameService=corbaname::" + hname + ":\([[:digit:]]*\)/\1/"
- #print "sed command = ", aSedCommand
+ # print("sed command = ", aSedCommand)
#aPort = commands.getoutput("sed -e\"" + aSedCommand + "\"" + os.environ["OMNIORB_CONFIG"])
- #print "port=", aPort
+ # print("port=", aPort)
if sys.platform == "win32":
- #print "start omniNames -start " + aPort + " -logdir " + upath
+ # print("start omniNames -start " + aPort + " -logdir " + upath)
self.CMD = ['omniNames', '-start' , aPort , '-nohostname', '-logdir' , os.path.realpath(upath), '-errlog', os.path.realpath(os.path.join(upath,'omniNameErrors.log'))]
#os.system("start omniNames -start " + aPort + " -logdir " + upath)
else:
The -c option can be used to specify the command to execute in the interpreter.
A script can also be used.
For example:
- salome connect -p 2810 -c 'print "Hello"'
+ salome connect -p 2810 -c 'print("Hello")'
salome connect -p 2810 hello.py
"""
parser = MyParser(usage=usage, epilog=epilog)
# and wait until it is registered in naming service
#
- #print "ARGS = ",args
+ # print("ARGS = ",args)
if ('study' not in args['embedded']) | (args["gui"] == 0):
print("RunStudy")
myServer=SalomeDSServer(args)
print()
print("--- Error during Salome launch ---")
- #print process_id
+ # print(process_id)
from addToKillList import addToKillList
from killSalomeWithPort import getPiDict
+ os.getenv("LD_LIBRARY_PATH")]
myargs = myargs +['-T']+self.CMD[:1]+['-e'] + env_ld_library_path
command = myargs + self.CMD
- #print "command = ", command
+ # print("command = ", command)
if sys.platform == "win32":
import subprocess
pid = subprocess.Popen(command).pid
#*** Test additional option
#*** args = launchConfigureParser.get_env([o_j])
- #*** if args.has_key("join"): print args["join"]
+ #*** if args.has_key("join"): print(args["join"])
# Check variables <module>_ROOT_DIR
# and set list of used modules (without KERNEL)
#file = "/tmp/ggg.hdf"
-print " ------- We will save to", file, "-----------"
+print(" ------- We will save to", file, "-----------")
batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)
openedStudy=batchmode_geompy.myStudyManager.Open(file)
c = A.TextColor();
if c.R != 234 or c.G != 345 or c.B != 231:
- print "Error: wrong value of AttributeTextColor"
+ print("Error: wrong value of AttributeTextColor")
# save / restore study
#============================================================
c = A.TextColor();
if c.R != 234 or c.G != 345 or c.B != 231:
- print "Error: wrong value of AttributeTextColor"
+ print("Error: wrong value of AttributeTextColor")
c = A.TextHighlightColor();
if c.R != 256 or c.G != 256 or c.B != 256:
- print "Error: wrong value of AttributeTextHighlightColor"
+ print("Error: wrong value of AttributeTextHighlightColor")
# save / restore study
#============================================================
res, A = father.FindAttribute("AttributeTextHighlightColor")
-print res, A
+print(res, A)
if res == 0 or A == None:
raise RuntimeError, "Error: not found AttributeTextHighlightColor"
c = A.TextHighlightColor();
if c.R != 256 or c.G != 256 or c.B != 256:
- print "Error: wrong value of AttributeTextTextHighlightColor"
+ print("Error: wrong value of AttributeTextTextHighlightColor")
aPixmap.SetPixMap( "ICON_OBJBROWSER_Geometry" );
if aPixmap.GetPixMap() != "ICON_OBJBROWSER_Geometry":
- print "Error: wrong value of AttributePixMap"
+ print("Error: wrong value of AttributePixMap")
# save / restore study
raise RuntimeError, "Can't create AttributePixMap attribute"
if A.GetPixMap() != "ICON_OBJBROWSER_Geometry":
- print "Error: wrong value of AttributePixMap"
+ print("Error: wrong value of AttributePixMap")
A.SetValue(763242882)
if A.Value() != 763242882:
- print "Error: wrong value of AttributeLocalID"
+ print("Error: wrong value of AttributeLocalID")
# save / restore study
#=================================
A = A._narrow(SALOMEDS.AttributeLocalID)
if A.Value() != 763242882:
- print "Error: wrong value of AttributeLocalID"
+ print("Error: wrong value of AttributeLocalID")
A.Add(500)
A.Add(400)
A.Add(700)
-print "First transaction goes on : HasOpenCommand() = ", batchmode_geompy.myBuilder.HasOpenCommand()
+print("First transaction goes on : HasOpenCommand() = ", batchmode_geompy.myBuilder.HasOpenCommand())
batchmode_geompy.myBuilder.CommitCommand() #--------------
# 2nd transaction ------------------------------------------
raise RuntimeError, "GetAvailableUndos() = 0 but must not !"
if A.Length() != 4:
- print "Wrong length of SequenceOfInteger"
+ print("Wrong length of SequenceOfInteger")
if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 400 or A.Value(4) != 500:
raise RuntimeError, "Wrong value of AttributeSequenceOfInteger"
if A is None:
raise RuntimeError, "After first 'undo' can't find AttributeSequenceOfInteger"
if A.Length() != 5:
- print "Wrong length of SequenceOfInteger"
+ print("Wrong length of SequenceOfInteger")
if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 500 or A.Value(4) != 400 or A.Value(5) != 700:
- print A.Value(1), A.Value(2), A.Value(3), A.Value(4), A.Value(5)
+ print( A.Value(1), A.Value(2), A.Value(3), A.Value(4), A.Value(5))
raise RuntimeError, "Wrong value of AttributeSequenceOfInteger after the first 'undo'!"
# save
file2 = dir + "/test2.hdf"
if res ==0 or A== None :
raise RuntimeError, "AttributeSequenceOfInteger is not found but must be!"
if A.Length() != 4:
- print "Wrong length of SequenceOfInteger"
+ print("Wrong length of SequenceOfInteger")
if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 400 or A.Value(4) != 500:
raise RuntimeError, "Wrong value of AttributeSequenceOfInteger"
A = A._narrow(SALOMEDS.AttributeSequenceOfInteger)
if A.Length() != 4:
- print "Wrong length of SequenceOfInteger"
+ print("Wrong length of SequenceOfInteger")
if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 400 or A.Value(4) != 500:
- print "Wrong value of AttributeSequenceOfInteger"
+ print("Wrong value of AttributeSequenceOfInteger")
#----------------------------------------------------------------------
openedStudy=batchmode_geompy.myStudyManager.Open(file2);
A = A._narrow(SALOMEDS.AttributeSequenceOfInteger)
if A.Length() != 5:
- print "Wrong length of SequenceOfInteger"
+ print("Wrong length of SequenceOfInteger")
if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 500 or A.Value(4) != 400 or A.Value(5) != 700:
raise RuntimeError, "Wrong value of AttributeSequenceOfInteger after the first 'undo'!"
A.SetValue("AttributesTesting")
if A.Value() != "AttributesTesting":
- print "Wrong value of AttributeName"
+ print("Wrong value of AttributeName")
batchmode_geompy.myBuilder.CommitCommand()
#===========================================================
res, A = batchmode_geompy.myBuilder.FindAttribute(child, "AttributeComment")
-print "res = ", res
+print("res = ", res)
if A != None :
- print " AttributeComment was found"
+ print(" AttributeComment was found")
else:
- print " AttributeComment is not found. It's correct"
+ print(" AttributeComment is not found. It's correct")
attributes=[]
length = len(attributes)
-print "Attributes number = ", length
-print attributes
+print("Attributes number = ", length)
+print(attributes)
for i in range(0, length) :
attr = attributes[i]
if attr is None :
- print i,"None item of object attributes list"
+ print(i,"None item of object attributes list")
if length != 5 :
raise RuntimeError, "Wrong number of attributes"
N32.Prepend(N31)
N33.InsertAfter(N32)
N33.Append(N34)
-print "------------- ", N1, " ------------- "
-print "N1.Label() = ", N1.Label() , "IsRoot() = ", N1.IsRoot(), "Depth() = ", N1.Depth()
-print "N11.Label() = ", N11.Label() , "IsRoot() = ", N11.IsRoot(), "Depth() = ", N11.Depth()
-print "N111.Label() = ", N111.Label() , "IsRoot() = ", N111.IsRoot(), "Depth() = ", N111.Depth()
-print "N2.Label() = ", N2.Label() , "IsRoot() = ", N2.IsRoot(), "Depth() = ", N2.Depth()
-print "N3.Label() = ", N3.Label() , "IsRoot() = ", N3.IsRoot(), "Depth() = ", N3.Depth()
-print "N31.Label() = ", N31.Label() , "IsRoot() = ", N31.IsRoot(), "Depth() = ", N31.Depth()
-print "N32.Label() = ", N32.Label() , "IsRoot() = ", N32.IsRoot(), "Depth() = ", N32.Depth()
-print "N321.Label() = ", N321.Label() , "IsRoot() = ", N321.IsRoot(), "Depth() = ", N321.Depth()
-print "N33.Label() = ", N33.Label() , "IsRoot() = ", N33.IsRoot(), "Depth() = ", N33.Depth()
-print "N34.Label() = ", N34.Label() , "IsRoot() = ", N34.IsRoot(), "Depth() = ", N34.Depth()
-print "N1.IsRoot()=", N1.IsRoot()
-
-print "N1.HasNext() = ",N1.HasNext()
+print("------------- ", N1, " ------------- ")
+print("N1.Label() = ", N1.Label() , "IsRoot() = ", N1.IsRoot(), "Depth() = ", N1.Depth())
+print("N11.Label() = ", N11.Label() , "IsRoot() = ", N11.IsRoot(), "Depth() = ", N11.Depth())
+print("N111.Label() = ", N111.Label() , "IsRoot() = ", N111.IsRoot(), "Depth() = ", N111.Depth())
+print("N2.Label() = ", N2.Label() , "IsRoot() = ", N2.IsRoot(), "Depth() = ", N2.Depth())
+print("N3.Label() = ", N3.Label() , "IsRoot() = ", N3.IsRoot(), "Depth() = ", N3.Depth())
+print("N31.Label() = ", N31.Label() , "IsRoot() = ", N31.IsRoot(), "Depth() = ", N31.Depth())
+print("N32.Label() = ", N32.Label() , "IsRoot() = ", N32.IsRoot(), "Depth() = ", N32.Depth())
+print("N321.Label() = ", N321.Label() , "IsRoot() = ", N321.IsRoot(), "Depth() = ", N321.Depth())
+print("N33.Label() = ", N33.Label() , "IsRoot() = ", N33.IsRoot(), "Depth() = ", N33.Depth())
+print("N34.Label() = ", N34.Label() , "IsRoot() = ", N34.IsRoot(), "Depth() = ", N34.Depth())
+print("N1.IsRoot()=", N1.IsRoot())
+
+print("N1.HasNext() = ",N1.HasNext())
if N1.HasNext():
- print N1.Next().Label()
+ print(N1.Next().Label())
-print "N32.HasPrevious() = ",N32.HasPrevious()
+print("N32.HasPrevious() = ",N32.HasPrevious())
if N32.HasPrevious():
- print N32.GetPrevious().Label()
+ print(N32.GetPrevious().Label())
-print "N111.HasFirst()=",N111.HasFirst()
-print "N111.HasFather()=",N111.HasFather()
+print("N111.HasFirst()=",N111.HasFirst())
+print("N111.HasFather()=",N111.HasFather())
if N111.HasFather() :
- print "N111.GetFather().Label()=",N111.GetFather().Label()
+ print("N111.GetFather().Label()=",N111.GetFather().Label())
subShapeList = batchmode_geompy.SubShapeAll(box,ShapeType["Face"])
face=subShapeList[0]
name = "box_face"
-print name
+print(name)
idface= batchmode_geompy.addToStudyInFather(box,face,name)
# ---- add shell from box in study
subShellList= batchmode_geompy.SubShapeAll(box,ShapeType["Shell"])
shell = subShellList[0]
name = "box_shell"
-print name
+print(name)
idshell= batchmode_geompy.addToStudyInFather(box,shell,name)
# ---- add first edge of face in study
edgeList = batchmode_geompy.SubShapeAll(face,ShapeType["Edge"])
edge=edgeList[0];
name = "face_edge"
-print name
+print(name)
idedge= batchmode_geompy.addToStudyInFather(face,edge,name)
# ---- launch SMESH, init a Mesh with the box
# ---- create Hypothesis
-print "-------------------------- create Hypothesis ----------------------"
-print "-------------------------- LocalLength"
+print("-------------------------- create Hypothesis ----------------------")
+print("-------------------------- LocalLength")
hyp1 = smesh.CreateHypothesis("LocalLength", batchmode_geompy.myStudyId )
hypLen1 = hyp1._narrow(SMESH.SMESH_LocalLength)
hypLen1.SetLength(100)
-print hypLen1.GetName()
-print hypLen1.GetId()
-print hypLen1.GetLength()
+print(hypLen1.GetName())
+print(hypLen1.GetId())
+print(hypLen1.GetLength())
idlength = batchmode_smesh.AddNewHypothesis( orb.object_to_string(hypLen1) );
batchmode_smesh.SetName(idlength, "Local_Length_100");
-print "-------------------------- NumberOfSegments"
+print("-------------------------- NumberOfSegments")
hyp2 = smesh.CreateHypothesis("NumberOfSegments", batchmode_geompy.myStudyId )
hypNbSeg1=hyp2._narrow(SMESH.SMESH_NumberOfSegments)
hypNbSeg1.SetNumberOfSegments(7)
-print hypNbSeg1.GetName()
-print hypNbSeg1.GetId()
-print hypNbSeg1.GetNumberOfSegments()
+print(hypNbSeg1.GetName())
+print(hypNbSeg1.GetId())
+print(hypNbSeg1.GetNumberOfSegments())
idseg = batchmode_smesh.AddNewHypothesis( orb.object_to_string(hypNbSeg1) );
batchmode_smesh.SetName(idseg, "NumberOfSegments_7");
-print "-------------------------- MaxElementArea"
+print("-------------------------- MaxElementArea")
hyp3 = smesh.CreateHypothesis("MaxElementArea", batchmode_geompy.myStudyId)
hypArea1=hyp3._narrow(SMESH.SMESH_MaxElementArea)
hypArea1.SetMaxElementArea(2500)
-print hypArea1.GetName()
-print hypArea1.GetId()
-print hypArea1.GetMaxElementArea()
+print(hypArea1.GetName())
+print(hypArea1.GetId())
+print(hypArea1.GetMaxElementArea())
idarea1 = batchmode_smesh.AddNewHypothesis( orb.object_to_string(hypArea1) );
batchmode_smesh.SetName(idarea1, "MaxElementArea_2500");
-print "-------------------------- MaxElementArea"
+print("-------------------------- MaxElementArea")
hyp3 = smesh.CreateHypothesis("MaxElementArea", batchmode_geompy.myStudyId)
hypArea2 = hyp3._narrow(SMESH.SMESH_MaxElementArea)
hypArea2.SetMaxElementArea(500)
-print hypArea2.GetName()
-print hypArea2.GetId()
-print hypArea2.GetMaxElementArea()
+print(hypArea2.GetName())
+print(hypArea2.GetId())
+print(hypArea2.GetMaxElementArea())
idarea2 = batchmode_smesh.AddNewHypothesis( orb.object_to_string(hypArea2) );
batchmode_smesh.SetName(idarea2, "MaxElementArea_500");
-print "-------------------------- Regular_1D"
+print("-------------------------- Regular_1D")
alg1 = smesh.CreateHypothesis("Regular_1D", batchmode_geompy.myStudyId)
algo1 = alg1._narrow(SMESH.SMESH_Algo)
listHyp = algo1.GetCompatibleHypothesis()
for hyp in listHyp:
- print hyp
+ print(hyp)
algoReg=alg1._narrow(SMESH.SMESH_Regular_1D)
-print algoReg.GetName()
-print algoReg.GetId()
+print(algoReg.GetName())
+print(algoReg.GetId())
idreg = batchmode_smesh.AddNewAlgorithms( orb.object_to_string(algoReg) );
batchmode_smesh.SetName(idreg, "Regular_1D");
-print "-------------------------- MEFISTO_2D"
+print("-------------------------- MEFISTO_2D")
alg2 = smesh.CreateHypothesis("MEFISTO_2D", batchmode_geompy.myStudyId)
algo2 = alg2._narrow(SMESH.SMESH_Algo)
listHyp=algo2.GetCompatibleHypothesis()
for hyp in listHyp:
- print hyp
+ print(hyp)
algoMef=alg2._narrow(SMESH.SMESH_MEFISTO_2D)
-print algoMef.GetName()
-print algoMef.GetId()
+print(algoMef.GetName())
+print(algoMef.GetId())
idmef = batchmode_smesh.AddNewAlgorithms( orb.object_to_string(algoMef) );
batchmode_smesh.SetName(idmef, "MEFISTO_2D");
# ---- add hypothesis to edge
-print "-------------------------- add hypothesis to edge"
+print("-------------------------- add hypothesis to edge")
edge = batchmode_geompy.IDToObject(idedge)
submesh = mesh.GetElementsOnShape(edge)
ret = mesh.AddHypothesis(edge,algoReg)
-print ret
+print(ret)
ret=mesh.AddHypothesis(edge,hypLen1)
-print ret
+print(ret)
idsm1 = batchmode_smesh.AddSubMeshOnShape( idmesh,
idedge,
batchmode_smesh.SetAlgorithms( idsm1, idreg );
batchmode_smesh.SetHypothesis( idsm1, idlength );
-print "-------------------------- add hypothesis to face"
+print("-------------------------- add hypothesis to face")
face=batchmode_geompy.IDToObject(idface)
submesh=mesh.GetElementsOnShape(face)
ret=mesh.AddHypothesis(face,hypArea2)
-print ret
+print(ret)
idsm2 = batchmode_smesh.AddSubMeshOnShape( idmesh,
idface,
# ---- add hypothesis to box
-print "-------------------------- add hypothesis to box"
+print("-------------------------- add hypothesis to box")
box=batchmode_geompy.IDToObject(idbox)
submesh=mesh.GetElementsOnShape(box)
ret=mesh.AddHypothesis(box,algoReg)
-print ret
+print(ret)
ret=mesh.AddHypothesis(box,hypNbSeg1)
-print ret
+print(ret)
ret=mesh.AddHypothesis(box,algoMef)
-print ret
+print(ret)
ret=mesh.AddHypothesis(box,hypArea1)
-print ret
+print(ret)
batchmode_smesh.SetAlgorithms( idmesh, idreg );
batchmode_smesh.SetHypothesis( idmesh, idseg );
# ---- compute box
-print "-------------------------- compute box"
+print("-------------------------- compute box")
ret=smesh.Compute(mesh,box)
-print ret
+print(ret)
log=mesh.GetLog(0); # no erase trace
for linelog in log:
- print linelog
+ print(linelog)
#=======================================================
if dir == None:
raise RuntimeError, "SUPERV_ROOT_DIR is not defined"
xmlfile = dir +"/examples/GraphEssai.xml"
-print "--------------\n"+xmlfile+"\n--------------\n"
+print("--------------\n"+xmlfile+"\n--------------\n")
myGraph = Graph ( xmlfile )
# This DataFlow is "valid" : no loop, correct links between Nodes etc...
-print myGraph.IsValid()
+print(myGraph.IsValid())
# Get Nodes
myGraph.PrintNodes()
Divz = Div.Port('z')
# This DataFlow is "executable" : all pending Ports are defined with Datas
-print myGraph.IsExecutable()
+print(myGraph.IsExecutable())
# Starts only execution of that DataFlow and gets control immediatly
-print myGraph.Run()
+print(myGraph.Run())
# That DataFlow is running ==> 0 (false)
-print myGraph.IsDone()
+print(myGraph.IsDone())
# Events of execution :
aStatus,aNode,anEvent,aState = myGraph.Event()
while aStatus :
- print aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState
+ print(aNode.Thread(),aNode.SubGraph(),aNode.Name(),anEvent,aState)
aStatus,aNode,anEvent,aState = myGraph.Event()
-print myGraph.IsDone()
+print(myGraph.IsDone())
# Wait for Completion (but it is already done after event loop ...)
-print "Done : ",myGraph.DoneW()
+print("Done : ",myGraph.DoneW())
# Get result
-print "Result : ",Divz.ToString()
+print("Result : ",Divz.ToString())
# Intermediate results :
-print "Intermediate Result Add\z : ",Addz.ToString()
-print "Intermediate Result Sub\z : ",Subz.ToString()
-print "Intermediate Result Mul\z : ",Mulz.ToString()
+print("Intermediate Result Add\z : ",Addz.ToString())
+print("Intermediate Result Sub\z : ",Subz.ToString())
+print("Intermediate Result Mul\z : ",Mulz.ToString())
-print " "
-#print "Type : print myGraph.IsDone()"
-#print " If execution is finished ==> 1 (true)"
+print(" ")
+#print("Type : print(myGraph.IsDone()")
+#print(" If execution is finished ==> 1 (true)")
res=myGraph.IsDone()
if res != 1:
raise RuntimeError, "myGraph.Run() is not done"
-print " "
-print "Type : print Divz.ToString()"
-print " You will get the result"
+print(" ")
+print("Type : print(Divz.ToString()")
+print(" You will get the result")
Divz.ToString()
-print " "
-print "Type : myGraph.PrintPorts()"
-print " to see input and output values of the graph"
+print(" ")
+print("Type : myGraph.PrintPorts()")
+print(" to see input and output values of the graph")
myGraph.PrintPorts()
-print " "
-print "Type : Add.PrintPorts()"
+print(" ")
+print("Type : Add.PrintPorts()")
Add.PrintPorts()
-print "Type : Sub.PrintPorts()"
+print("Type : Sub.PrintPorts()")
Sub.PrintPorts()
-print "Type : Mul.PrintPorts()"
+print("Type : Mul.PrintPorts()")
Mul.PrintPorts()
-print "Type : Div.PrintPorts()"
-print " to see input and output values of nodes"
+print("Type : Div.PrintPorts()")
+print(" to see input and output values of nodes")
Div.PrintPorts()
# Export will create newsupervisionexample.xml and the corresponding .py file
if tmpdir is None:
tmpdir="/tmp"
file = tmpdir + "/newsupervisionexample"
-print "--------------\n"+file+"\n--------------\n"
+print("--------------\n"+file+"\n--------------\n")
myGraph.Export(file)
ior = batchmode_geompy.orb.object_to_string(myGraph.G)
addStudy(ior)
GraphName = myGraph.Name()
-print "Befor save ",
+print("Befor save ",)
nodes = myGraph.Nodes()
length_bs = len(nodes)
-print "ListOfNodes length = ", length_bs
+print("ListOfNodes length = ", length_bs)
names=[]
for node in nodes:
names.append(node.Name())
-print names
+print(names)
#=================================
#==================================================
#1. SaveAs
#==================================================
-print " ------- We will save to", file, "-----------"
+print(" ------- We will save to", file, "-----------")
batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)
batchmode_geompy.myStudyManager.Close(batchmode_geompy.myStudy)
os.mkdir(str + "/test_dir")
#2.==================================================
-print " ------- We rename the file as " + str + "/test_dir/test_new.hdf"
+print(" ------- We rename the file as " + str + "/test_dir/test_new.hdf")
os.rename(file, str+"/test_dir/test_new.hdf")
#==================================================
#3. Open
#==================================================
-print " ------- We try to open " + str + "/test_dir/test_new.hdf"
+print(" ------- We try to open " + str + "/test_dir/test_new.hdf")
try:
openedStudy=batchmode_geompy.myStudyManager.Open(str+"/test_dir/test_new.hdf")
#while aChildIterator.More():
anSObject = aChildIterator.Value()
-#print "iterate: ", anSObject.GetID()
+#print("iterate: ", anSObject.GetID())
res, anAttr=anSObject.FindAttribute("AttributeIOR")
if res :
anAttr=anAttr._narrow(SALOMEDS.AttributeIOR)
Graph=SuperV.getGraph(ior)
ListOfNodes=Graph.Nodes()
length_as= len(ListOfNodes)
- print "ListOfNodes length = ", length_as
+ print("ListOfNodes length = ", length_as)
if length_as != length_bs:
raise RuntimeErrror, "defferent length of nodes after study open"
#aChildIterator.Next()
Graph=SuperV.getGraph(ior)
ListOfNodes=Graph.Nodes()
length_as= len(ListOfNodes)
- print "ListOfNodes length = ", length_as
+ print("ListOfNodes length = ", length_as)
if length_as != length_bs:
raise RuntimeErrror, "defferent length of nodes after study open"
#aChildIterator.Next()
A = A._narrow(SALOMEDS.AttributeStudyProperties)
batchmode_geompy.myBuilder.NewCommand();
-print "A.GetUserName()= ", A.GetUserName()
+print("A.GetUserName()= ", A.GetUserName())
res,mm,hh,dd,mnth,yy=A.GetCreationDate()
-print "A.GetCreationDate() = ", mm,hh,dd,mnth,yy
-print "A.GetCreationMode() = ", A.GetCreationMode()
-print "A.IsModified() = ", A.IsModified()
-print "A.IsLocked() = ", A.IsLocked()
+print("A.GetCreationDate() = ", mm,hh,dd,mnth,yy)
+print("A.GetCreationMode() = ", A.GetCreationMode())
+print("A.IsModified() = ", A.IsModified())
+print("A.IsLocked() = ", A.IsLocked())
if A.IsLocked() == 0 :
- A.SetUserName("tester"); print 'A.SetUserName("tester"), A.GetUserName() = ', A.GetUserName()
- A.SetCreationDate(11,11,11,11,2002); print 'A.SetCreationDate(11,11,11,11,2002), A.GetCreationDate() =', A.GetCreationDate()
- print "A.IsModified() = ", A.IsModified()
+ A.SetUserName("tester"); print('A.SetUserName("tester"), A.GetUserName() = ', A.GetUserName())
+ A.SetCreationDate(11,11,11,11,2002); print('A.SetCreationDate(11,11,11,11,2002), A.GetCreationDate() =', A.GetCreationDate())
+ print("A.IsModified() = ", A.IsModified())
A.SetLocked(1)
#check the transaction result
batchmode_geompy.myBuilder.CommitCommand()
if A.GetUserName() != "tester":
- print 'Control after transaction close : A.GetUserName() = ', A.GetUserName()
+ print('Control after transaction close : A.GetUserName() = ', A.GetUserName())
raise RuntimeError, "Field 'UserName' was not modified but had to!"
# try to make some changes wrapped by transaction
str = "/tmp"
file = str+"/test.hdf"
-print " ------- We will save to", file, "-----------"
+print(" ------- We will save to", file, "-----------")
batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)
#4.
myBuilder.NewCommand()
A.SetLocked(0);
-print "A.GetUserName()= ", A.GetUserName()
-print "A.GetCreationDate() = ", A.GetCreationDate()
-print "A.GetCreationMode() = ", A.GetCreationMode()
-print "A.IsModified() = ", A.IsModified()
+print("A.GetUserName()= ", A.GetUserName())
+print("A.GetCreationDate() = ", A.GetCreationDate())
+print("A.GetCreationMode() = ", A.GetCreationMode())
+print("A.IsModified() = ", A.IsModified())
myBuilder.CommitCommand()
#5.
myBuilder.NewCommand()
A.SetUserName("tester1")
myBuilder.CommitCommand()
-print "A.GetUserName()= ", A.GetUserName()
+print("A.GetUserName()= ", A.GetUserName())
#remove the document file
os.remove(file)
A.SetColumn(3,a)
# change attribute values
-print "A.GetValue(2,2) = ", A.GetValue(2,2)
-print "A.PutValue(2,2,625323)"
+print("A.GetValue(2,2) = ", A.GetValue(2,2))
+print("A.PutValue(2,2,625323)")
A.PutValue(625323,2,2)
-print "A.GetValue(2,2) = ", A.GetValue(2,2)
+print("A.GetValue(2,2) = ", A.GetValue(2,2))
#set Titles
#check the table
-print "Common title : ",A.GetTitle()
-print "Rows titles : ", A.GetRowTitles()
+print("Common title : ",A.GetTitle())
+print("Rows titles : ", A.GetRowTitles())
rnb = A.GetNbRows()
for i in range(1, rnb):
b=A.GetRow(i)
- print b
+ print(b)
cnb = A.GetNbColumns()
-print "Columns title : ", A.GetColumnTitles()
+print("Columns title : ", A.GetColumnTitles())
for i in range(1, cnb):
b=A.GetColumn(i)
- print b
+ print(b)
# set titles
#titles=["11","12","13"]
str = "/tmp"
file = str+"/test.hdf"
-print " ------- We will save to", file, "-----------"
+print(" ------- We will save to", file, "-----------")
batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)
A = A._narrow(SALOMEDS.AttributeTableOfInteger)
#check the table
-print "Common title : ",A.GetTitle()
-print "Rows titles : ", A.GetRowTitles()
+print("Common title : ",A.GetTitle())
+print("Rows titles : ", A.GetRowTitles())
rnb = A.GetNbRows()
for i in range(1, rnb):
b=A.GetRow(i)
- print b
+ print(b)
cnb = A.GetNbColumns()
-print "Columns title : ", A.GetColumnTitles()
+print("Columns title : ", A.GetColumnTitles())
for i in range(1, cnb):
b=A.GetColumn(i)
- print b
+ print(b)
titles=["ff","ss","tt"]
A.SetRowTitles(titles)
-print "Rows titles : ", A.GetRowTitles()
+print("Rows titles : ", A.GetRowTitles())
titles=["ww","zz","cc"]
A.SetColumnTitles(titles)
-print "Column titles : ", A.GetColumnTitles()
+print("Column titles : ", A.GetColumnTitles())
A.SetColumn(3,a)
# change attribute values
-print "A.GetValue(2,2) = ", A.GetValue(2,2)
-print "A.PutValue(2,2,625323)"
+print("A.GetValue(2,2) = ", A.GetValue(2,2))
+print("A.PutValue(2,2,625323)")
A.PutValue(625323,2,2)
-print "A.GetValue(2,2) = ", A.GetValue(2,2)
+print("A.GetValue(2,2) = ", A.GetValue(2,2))
#set Titles
#check the table
-print "Common title : ",A.GetTitle()
-print "Rows titles : ", A.GetRowTitles()
+print("Common title : ",A.GetTitle())
+print("Rows titles : ", A.GetRowTitles())
rnb = A.GetNbRows() + 1
for i in range(1, rnb):
b=A.GetRow(i)
- print b
+ print(b)
cnb = A.GetNbColumns() + 1
-print "Columns title : ", A.GetColumnTitles()
+print("Columns title : ", A.GetColumnTitles())
for i in range(1, cnb):
b=A.GetColumn(i)
- print b
+ print(b)
# set titles
#titles=["11","12","13"]
str = "/tmp"
file = str+"/test.hdf"
-print " ------- We will save to", file, "-----------"
+print(" ------- We will save to", file, "-----------")
batchmode_geompy.myStudyManager.SaveAs(file, batchmode_geompy.myStudy)
A = A._narrow(SALOMEDS.AttributeTableOfReal)
#check the table
-print "Common title : ",A.GetTitle()
-print "Rows titles : ", A.GetRowTitles()
+print("Common title : ",A.GetTitle())
+print("Rows titles : ", A.GetRowTitles())
rnb = A.GetNbRows() + 1
for i in range(1, rnb):
b=A.GetRow(i)
- print b
+ print(b)
cnb = A.GetNbColumns() + 1
-print "Columns title : ", A.GetColumnTitles()
+print("Columns title : ", A.GetColumnTitles())
for i in range(1, cnb):
b=A.GetColumn(i)
- print b
+ print(b)
titles=["ff","ss","tt"]
A.SetRowTitles(titles)
-print "Rows titles : ", A.GetRowTitles()
+print("Rows titles : ", A.GetRowTitles())
titles=["ww","zz","cc"]
A.SetColumnTitles(titles)
-print "Column titles : ", A.GetColumnTitles()
+print("Column titles : ", A.GetColumnTitles())
aStudy.SetContext("/User data/Case1")
#Print the current study context
-print aStudy.GetContext()
+print(aStudy.GetContext())
#Add a sub directory 'aSubCase' to 'Case1' (under the current context)
aBuilder.AddDirectory("aSubCase")
A.Add(0.928e+100)
A.Add(83.287)
-print "initial values ",A.Value(1), A.Value(2), A.Value(3), A.Value(4)
+print("initial values ",A.Value(1), A.Value(2), A.Value(3), A.Value(4))
A.Remove(3)
-print "after remove ", A.Value(1), A.Value(2), A.Value(3)
+print("after remove ", A.Value(1), A.Value(2), A.Value(3))
A.ChangeValue(2,76.265)
-print "after second item change", A.Value(1), A.Value(2), A.Value(3)
+print("after second item change", A.Value(1), A.Value(2), A.Value(3))
if A.Length() != 3:
- print "Error : wrong length of SequenceOfReal"
+ print("Error : wrong length of SequenceOfReal")
if A.Value(1) != 0.0293 or A.Value(2) != 76.265 or A.Value(3) != 83.287:
- print "Error : wrong value of AttributeSequenceOfReal"
+ print("Error : wrong value of AttributeSequenceOfReal")
# save / restore study
#=================================
A = A._narrow(SALOMEDS.AttributeSequenceOfReal)
if A.Length() != 3:
- print "Error : wrong length of SequenceOfReal"
+ print("Error : wrong length of SequenceOfReal")
if A.Value(1) != 0.0293 or A.Value(2) != 76.265 or A.Value(3) != 83.287:
- print "Error : wrong value of AttributeSequenceOfReal"
-print "after restoring ", A.Value(1), A.Value(2), A.Value(3)
+ print("Error : wrong value of AttributeSequenceOfReal")
+print("after restoring ", A.Value(1), A.Value(2), A.Value(3))
if A.Length() != 4:
- print "Wrong length of SequenceOfInteger"
+ print("Wrong length of SequenceOfInteger")
if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 400 or A.Value(4) != 700:
- print "Wrong value of AttributeSequenceOfInteger"
+ print("Wrong value of AttributeSequenceOfInteger")
# save / restore study
A = A._narrow(SALOMEDS.AttributeSequenceOfInteger)
if A.Length() != 4:
- print "Wrong length of SequenceOfInteger"
+ print("Wrong length of SequenceOfInteger")
if A.Value(1) != 100 or A.Value(2) != 300 or A.Value(3) != 400 or A.Value(4) != 700:
- print "Wrong value of AttributeSequenceOfInteger"
+ print("Wrong value of AttributeSequenceOfInteger")
A.SetValue("AttributesTesting")
if A.Value() != "AttributesTesting":
- print "Wrong value of AttributeName"
+ print("Wrong value of AttributeName")
# save / restore study
raise RuntimeError, "Can't create AttributeName attribute"
if A.Value() != "AttributesTesting":
- print "Wrong value of AttributeName"
+ print("Wrong value of AttributeName")
iter.InitEx(True) # init recursive mode
while iter.More():
c = iter.Value()
- print c.GetID()
+ print(c.GetID())
iter.Next()
pass
# WARN: This may still add duplicate entries to path on
# case-insensitive filesystems
if os.path.isdir(subdir) and subdir not in __path__:
- print "INFO - The directory %s is appended to sys.path" % subdir
+ print("INFO - The directory %s is appended to sys.path" % subdir)
__path__.append(subdir)
extend_path(ROOT_PYTHONPACKAGE_NAME)
\code
from salome_instance import SalomeInstance
instance = SalomeInstance.start()
-print "Instance created and now running on port", instance.get_port()
+print("Instance created and now running on port", instance.get_port())
...
instance.stop()
\endcode
AC_MSG_RESULT($swig_ok)
fi
-numpydir=`$PYTHON -c "import numpy;print numpy.get_include()" 2>/dev/null`
+numpydir=`$PYTHON -c "import numpy;print(numpy.get_include())" 2>/dev/null`
if test -d "$numpydir"; then
numpy_ok=yes
PYTHON_INCLUDES="-I$numpydir $PYTHON_INCLUDES"
changequote(,)dnl
py_makefile="`$PYTHON -c '
import sys
-print \"%s/lib/python%s/config/Makefile\"%(sys.exec_prefix, sys.version[:3])'`"
+print(\"%s/lib/python%s/config/Makefile\"%(sys.exec_prefix, sys.version[:3]))'`"
changequote([,])dnl
if test ! -f "$py_makefile"; then
AC_MSG_ERROR([*** Couldn't find the python config makefile. Maybe you are
import sys
ver = sys.version[:3]
pre = sys.exec_prefix
-print \"-L%s/lib/python%s/config\" % (pre, ver),
+print(\"-L%s/lib/python%s/config\" % (pre, ver)),
if ver == \"1.4\":
- print \"-lPython -lObjects -lParser\"
+ print(\"-lPython -lObjects -lParser\")
else:
- print \"-lpython\" + ver
+ print(\"-lpython\" + ver)
changequote([,])dnl
changequote(,)dnl
py_config_in="`$PYTHON -c '
import sys
-print \"%s/lib/python%s/config/config.c.in\"%(sys.exec_prefix, sys.version[:3])'`"
+print(\"%s/lib/python%s/config/config.c.in\"%(sys.exec_prefix, sys.version[:3]))'`"
changequote([,])dnl
if test ! -f "$py_config_in"; then
AC_MSG_ERROR([*** Couldn't find the config.c.in file. Maybe you are
AC_SUBST(PYTHONHOME)
changequote(<<, >>)dnl
- PYTHON_VERSION=`$PYTHON -c "import sys; print sys.version[:3]"`
+ PYTHON_VERSION=`$PYTHON -c "import sys; print(sys.version[:3])"`
changequote([, ])dnl
AC_SUBST(PYTHON_VERSION)
dnl to know which OS Python thinks this is.
AC_SUBST(PYTHON_PLATFORM)
- PYTHON_PLATFORM=`$PYTHON -c "import sys; print sys.platform"`
+ PYTHON_PLATFORM=`$PYTHON -c "import sys; print(sys.platform)"`
AC_SUBST(PYTHON_SITE)
AC_ARG_WITH(python-site,
myStudyName = myStudy._get_Name()
myStudyId = myStudy._get_StudyId()
-#print myStudyId
+# print(myStudyId)
# import sys
# from salome.kernel import termcolor
# if termcolor.canDisplayColor(sys.stdout):
-# print termcolor.makeColoredMessage("Hello world!", termcolor.BLUE)
+# print(termcolor.makeColoredMessage("Hello world!", termcolor.BLUE))
# else:
-# print "Hello world!"
+# print("Hello world!")
# \endcode
# \}
import sys
from salome.kernel import termcolor
if termcolor.canDisplayColor(sys.stdout):
- print termcolor.makeColoredMessage("Hello world!", termcolor.BLUE)
+ print(termcolor.makeColoredMessage("Hello world!", termcolor.BLUE))
else:
- print "Hello world!"
+ print("Hello world!")
"""