Salome HOME
Merge Python 3 porting.
authorrnv <rnv@opencascade.com>
Thu, 22 Jun 2017 15:53:35 +0000 (18:53 +0300)
committerrnv <rnv@opencascade.com>
Thu, 22 Jun 2017 15:53:35 +0000 (18:53 +0300)
16 files changed:
bin/runHOMARD.py
doc/files/tutorial_util.py
doc/files/yacs_script.py
doc/files/yacs_script_test.py
src/HOMARD_I/HOMARD_Gen_i.cxx
src/HOMARD_SWIG/HOMARD_shared_modules.py
src/tests/Test/test_1.py
src/tests/Test/test_2.py
src/tests/Test/test_3.py
src/tests/Test/test_4.py
src/tests/Test/test_5.py
src/tests/Test/tutorial_1.py
src/tests/Test/tutorial_2.py
src/tests/Test/tutorial_3.py
src/tests/Test/tutorial_4.py
src/tests/Test/tutorial_5.py

index 1012c6370a731dd30161a1e34d56dfe501752b91..76ddece9b77ffe34132833d94425480e20d40723 100755 (executable)
@@ -23,31 +23,31 @@ usage="""USAGE: runHOMARD.py [options]
 [command line options] :
 --help                        : affichage de l'aide
 --gui                         : lancement du GUI
---logger                     : redirection des messages dans un fichier
---xterm                              : les serveurs ouvrent une fen�tre xterm et les messages sont affich�s dans cette fen�tre
---modules=module1,module2,... : o� modulen est le nom d'un module Salome � charger dans le catalogue
+--logger                      : redirection des messages dans un fichier
+--xterm                       : les serveurs ouvrent une fen??tre xterm et les messages sont affich??s dans cette fen??tre
+--modules=module1,module2,... : o?? modulen est le nom d'un module Salome ?? charger dans le catalogue
 --containers=cpp,python,superv: lancement des containers cpp, python et de supervision
---killall                    : arr�t des serveurs de salome
+--killall                     : arr??t des serveurs de salome
 
- La variable d'environnement <modulen>_ROOT_DIR doit etre pralablement
- positionne (modulen doit etre en majuscule).
+ La variable d'environnement <modulen>_ROOT_DIR doit etre pr??alablement
+ positionn??e (modulen doit etre en majuscule).
  KERNEL_ROOT_DIR est obligatoire.
 """
 
 # -----------------------------------------------------------------------------
 #
-# Fonction d'arrt de salome
+# Fonction d'arr??t de salome
 #
 
 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)
+         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")
    
 # -----------------------------------------------------------------------------
@@ -56,7 +56,7 @@ def killSalome():
 #
 
 def message(code, msg=''):
-    if msg: print msg
+    if msg: print(msg)
     sys.exit(code)
 
 import sys,os,string,glob,time,signal,pickle,getopt
@@ -78,7 +78,7 @@ with_container_superv=0
 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
@@ -92,49 +92,49 @@ try:
       liste_containers = [x.lower() for x in a.split(',')]
       for r in liste_containers:
         if r not in ('cpp', 'python', 'superv'):
-          message(1, 'Invalid -c/--containers option: %s' % a)
+           message(1, 'Invalid -c/--containers option: %s' % a)
       if 'cpp' in liste_containers:
-          with_container_cpp=1
+         with_container_cpp = 1
       else:
-          with_container_cpp=0
+         with_container_cpp = 0
       if 'python' in liste_containers:
-          with_container_python=1
+         with_container_python = 1
       else:
-          with_container_python=0
+         with_container_python = 0
       if 'superv' in liste_containers:
-          with_container_superv=1
+         with_container_superv = 1
       else:
-          with_container_superv=0
+         with_container_superv = 0
     elif o in ('-k', '--killall'):
       filedict='/tmp/'+os.getenv('USER')+'_SALOME_pidict'
       #filedict='/tmp/'+os.getlogin()+'_SALOME_pidict'
       found = 0
       try:
          fpid=open(filedict, 'r')
-        found = 1
+         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)
          fpid.close()
          killSalome()
-        process_id={}
+         process_id = {}
          os.remove(filedict)
-       
-except getopt.error, msg:
-  print usage
+
+except getopt.error as msg:
+  print(usage)
   sys.exit(1)
 
 # -----------------------------------------------------------------------------
 #
-# Vrification des variables d'environnement
+# V??rification des variables d'environnement
 #
 try:
   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 :
@@ -143,12 +143,12 @@ 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
 # - l'ordre des modules dans le catalogue sera identique
-# - la liste des modules presents dans le catalogue est exploite pour charger les modules CORBA python,
+# - la liste des modules presents dans le catalogue est exploit??e pour charger les modules CORBA python,
 #   il faut charger les modules python du KERNEL en premier
 
 if "KERNEL" in liste_modules:liste_modules.remove("KERNEL")
@@ -156,21 +156,21 @@ liste_modules[:0]=["KERNEL"]
 #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
 
 
 # -----------------------------------------------------------------------------
 #
-# Dfinition des classes d'objets pour le lancement des Server CORBA
+# D??finition des classes d'objets pour le lancement des Server CORBA
 #
 
 class Server:
    CMD=[]
    if with_xterm:
-       ARGS=['xterm', '-iconic', '-sb', '-sl', '500', '-e']
+     ARGS = ['xterm', '-iconic', '-sb', '-sl', '500', '-e']
    else:
-       ARGS=[] 
+      ARGS = []
 
    def run(self):
       args = self.ARGS+self.CMD
@@ -187,9 +187,9 @@ class CatalogServer(Server):
       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
+      self.CMD = self.SCMD1 + [':'.join(cata_path)] + self.SCMD2
 
 class SalomeDSServer(Server):
    CMD=['SALOMEDS_Server']
@@ -310,7 +310,7 @@ def startGUI():
   #
   # Activation du GUI de Session Server
   #
-       
+
   session.GetInterface()
   
 #
@@ -333,8 +333,8 @@ def startSalome():
   #  disponibilite dans le naming service
   #
   if with_logger:
-       LoggerServer().run()
-       clt.waitLogger("Logger")
+    LoggerServer().run()
+    clt.waitLogger("Logger")
 
   #
   # Lancement Registry Server
@@ -342,7 +342,7 @@ def startSalome():
   RegistryServer().run()
 
   #
-  # Attente de la disponibilit du Registry dans le Naming Service
+  # Attente de la disponibilit?? du Registry dans le Naming Service
   #
   clt.waitNS("/Registry")
 
@@ -354,7 +354,7 @@ def startSalome():
   cataServer.run()
 
   #
-  # Attente de la disponibilit du Catalog Server dans le Naming Service
+  # Attente de la disponibilit?? du Catalog Server dans le Naming Service
   #
   import SALOME_ModuleCatalog
   clt.waitNS("/Kernel/ModulCatalog",SALOME_ModuleCatalog.ModuleCatalog)
@@ -367,12 +367,12 @@ def startSalome():
   SalomeDSServer().run()
 
   if "GEOM" in liste_modules:
-       print "GEOM OCAF Resources"
-       os.environ["CSF_GEOMDS_ResourcesDefaults"]=os.path.join(modules_root_dir["GEOM"],"share","salome","resources")
+    print("GEOM OCAF Resources")
+    os.environ["CSF_GEOMDS_ResourcesDefaults"] = os.path.join(modules_root_dir["GEOM"], "share", "salome", "resources")
 
 
   #
-  # Attente de la disponibilit du SalomeDS dans le Naming Service
+  # Attente de la disponibilit?? du SalomeDS dans le Naming Service
   #
   clt.waitNS("/Study")
 
@@ -382,7 +382,7 @@ def startSalome():
   SessionServer().run()
 
   #
-  # Attente de la disponibilit du Session Server dans le Naming Service
+  # Attente de la disponibilit?? du Session Server dans le Naming Service
   #
   import SALOME
   session=clt.waitNS("/Kernel/Session",SALOME.Session)
@@ -397,41 +397,41 @@ def startSalome():
   # Lancement Container C++ local
   #
   if with_container_cpp:
-         ContainerCPPServer().run()
-         #
-         # Attente de la disponibilit� du Container C++ local 
-          # dans le Naming Service
-         #
-         clt.waitNS("/Containers/" + theComputer + "/FactoryServer")
+    ContainerCPPServer().run()
+    #
+    # Attente de la disponibilit?? du Container C++ local
+    # dans le Naming Service
+    #
+    clt.waitNS("/Containers/" + theComputer + "/FactoryServer")
   #
   # Lancement Container Python local
   #
   if with_container_python:
-         ContainerPYServer().run()
-         #
-         # Attente de la disponibilit� du Container Python local 
-          #  dans le Naming Service
-         #
-         clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy")
+    ContainerPYServer().run()
+    #
+    # Attente de la disponibilit?? du Container Python local
+    #  dans le Naming Service
+    #
+    clt.waitNS("/Containers/" + theComputer + "/FactoryServerPy")
 
   if with_container_superv:
-       #
-       # Lancement Container Supervision local
-       #
-       ContainerSUPERVServer().run()
-       #
-       # Attente de la disponibilit� du Container Supervision local 
-        # dans le Naming Service
-       #
-       clt.waitNS("/Containers/" + theComputer + "/SuperVisionContainer")
+    #
+    # Lancement Container Supervision local
+    #
+    ContainerSUPERVServer().run()
+    #
+    # Attente de la disponibilit?? du Container Supervision local
+    # dans le Naming Service
+    #
+    clt.waitNS("/Containers/" + theComputer + "/SuperVisionContainer")
   #
   # Activation du GUI de Session Server
   #
   #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
 
@@ -440,13 +440,14 @@ def startSalome():
 #
 
 if __name__ == "__main__":
+   import codecs
    clt=None
    try:
       clt = startSalome()
    except:
-      print
-      print
-      print "--- erreur au lancement Salome ---"
+      print()
+      print()
+      print("--- erreur au lancement Salome ---")
    
    #print process_id
    
@@ -454,32 +455,31 @@ if __name__ == "__main__":
    filedict='/tmp/'+os.getenv('USER')+'_SALOME_pidict'
    #filedict='/tmp/'+os.getlogin()+'_SALOME_pidict'
    
-   fpid=open(filedict, 'w')
-   pickle.dump(process_id,fpid)
-   fpid.close()
+   with codecs.open(filedict, 'w') as fpid:
+      pickle.dump(process_id, fpid)
    
-   print """
+   print("""
 
 Sauvegarde du dictionnaire des process dans , %s
 Pour tuer les process SALOME, executer : python killSalome.py depuis
 une console, ou bien killSalome() depuis le present interpreteur,
-s'il n'est pas ferm.
+s'il n'est pas ferm??.
 
 runHOMARD, avec l'option --killall, commence par tuer les process restants 
-d'une execution pr�c�dente.
+d'une execution pr??c??dente.
 
 Pour lancer uniquement le GUI, executer startGUI() depuis le present interpreteur,
-s'il n'est pas ferm.
+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")
@@ -487,16 +487,15 @@ s'il n'est pas ferm�.
      container =  clt.waitNS("/Containers/" + socket.gethostname().split('.')[0] + "/FactoryServerPy")
    
    if os.path.isfile("~/.salome/pystartup"):
-      f=open(os.path.expanduser("~/.salome/pystartup"),'w')
-      PYTHONSTARTUP=f.read()
-      f.close()
+      with codecs.open(os.path.expanduser("~/.salome/pystartup")) as f:
+          PYTHONSTARTUP = f.read()
    else:
       PYTHONSTARTUP="""
 # Add auto-completion and a stored history file of commands to your Python
 # interactive interpreter. Requires Python 2.0+, readline. Autocomplete is
 # bound to the TAB key by default (you can change it - see readline docs).
 #
-# Store the history in ~/.salome/pyhistory, 
+# Store the history in ~/.salome/pyhistory,
 #
 import atexit
 import os
@@ -516,9 +515,7 @@ if os.path.exists(historyPath):
 atexit.register(save_history)
 del os, atexit, readline, rlcompleter, save_history, historyPath
 """
-      f=open(os.path.expanduser("~/.salome/pystartup"),'w')
-      f.write(PYTHONSTARTUP)
-      f.close()
+      with codecs.open(os.path.expanduser("~/.salome/pystartup"), 'w') as f:
+          f.write(PYTHONSTARTUP)
 
-   exec PYTHONSTARTUP in {}
-   
+   exec(PYTHONSTARTUP, {})
index 5960f12b279ac899f60a6e3888520f8e26c17271..34fb19ae75ce891856a3f4109538268ee92a50c3 100755 (executable)
@@ -110,7 +110,7 @@ num_tuto: number of the tutorial
 Copyright EDF-R&D 2014
   """
 #
-  if os.environ.has_key("LOGNAME") :
+  if "LOGNAME" in os.environ :
     user = os.environ ["LOGNAME"]
   else :
     user = "anonymous"
index be8303400a3efb37abf999b83ee23a57a5ea5d2b..587ec7e285b16a4fdadb18bb9b5bc12740476985 100755 (executable)
@@ -98,7 +98,7 @@ Exemples :
 #
 # 0.2. ==> Le user
 #
-  if os.environ.has_key("LOGNAME") :
+  if "LOGNAME" in os.environ :
     user = os.environ ["LOGNAME"]
   else :
     user = "salome"
@@ -187,13 +187,13 @@ Le constructeur de la classe Script
 #
     if self.verbose_max :
       nom_fonction = __name__ + "/__init__"
-      print "\nDans " + nom_fonction + ","
-      print ". rep_calc       :", self.rep_calc
-      print ". mesh_file      :", self.mesh_file
-      print ". numero         :", self.numero
-      print ". opt1           :", self.opt1
-      print ". opt2           :", self.opt2
-      print ". attente        :", self.attente
+      print("\nDans " + nom_fonction + ",")
+      print(". rep_calc       :", self.rep_calc)
+      print(". mesh_file      :", self.mesh_file)
+      print(". numero         :", self.numero)
+      print(". opt1           :", self.opt1)
+      print(". opt2           :", self.opt2)
+      print(". attente        :", self.attente)
 #
 #=========================  Fin de la fonction ===================================
 #
@@ -257,8 +257,8 @@ Lancement d'un calcul
       break
 #
     if self.verbose_max :
-      print blabla
-      print ". erreur :", erreur
+      print(blabla)
+      print(". erreur :", erreur)
 #
     return erreur, message_erreur, dico_resu
 #
@@ -279,10 +279,10 @@ Preparation d'un calcul
     message_erreur = " "
 #
     if self.verbose_max :
-      print blabla
-      print ". rep_calc       :", self.rep_calc
-      print ". mesh_file      :", self.mesh_file
-      print ". tr             :", self.tr
+      print(blabla)
+      print(". rep_calc       :", self.rep_calc)
+      print(". mesh_file      :", self.mesh_file)
+      print(". tr             :", self.tr)
 #
     while not erreur :
 #
@@ -316,8 +316,8 @@ Preparation d'un calcul
       break
 #
     if self.verbose_max :
-      print blabla, "a la fin"
-      print ". erreur :", erreur
+      print(blabla, "a la fin")
+      print(". erreur :", erreur)
 #
     return erreur, message_erreur
 #
@@ -349,14 +349,14 @@ Controle les arguments et stockage de quelques informations
     message_erreur = " "
 #
     if self.verbose_max :
-      print blabla
-      print ". rep_calc       :", self.rep_calc
-      print ". mesh_file      :", self.mesh_file
-      print ". numero         :", self.numero
-      print ". tr             :", self.tr
-      print ". opt1           :", self.opt1
-      print ". opt2           :", self.opt2
-      print ". attente        :", self.attente
+      print(blabla)
+      print(". rep_calc       :", self.rep_calc)
+      print(". mesh_file      :", self.mesh_file)
+      print(". numero         :", self.numero)
+      print(". tr             :", self.tr)
+      print(". opt1           :", self.opt1)
+      print(". opt2           :", self.opt2)
+      print(". attente        :", self.attente)
 #
     while not erreur :
 #
@@ -373,7 +373,7 @@ Controle les arguments et stockage de quelques informations
 #
 # 1.2. Le repertoire de calcul
 #
-      if os.environ.has_key("HOME") :
+      if "HOME" in os.environ :
         HOME = os.environ ["HOME"]
       else :
         HOME = "/local/home/salome"
@@ -410,7 +410,7 @@ Controle les arguments et stockage de quelques informations
 #
       self.nomcas = os.path.basename(self.rep_calc)
       if self.verbose_max :
-        print ". Cas :", self.nomcas
+        print(". Cas :", self.nomcas)
 #
 # 3. Le temps d'attente
 #
@@ -524,10 +524,10 @@ Controle les arguments et stockage de quelques informations
       message_erreur = messages_erreur[erreur]
 #
     if self.verbose_max :
-      print ". rep_calc  :", self.rep_calc
-      print ". mesh_file :", self.mesh_file
-      print ". opt1      :", self.opt1
-      print ". opt2      :", self.opt2
+      print(". rep_calc  :", self.rep_calc)
+      print(". mesh_file :", self.mesh_file)
+      print(". opt1      :", self.opt1)
+      print(". opt2      :", self.opt2)
 #
     return erreur, message_erreur
 #
@@ -550,9 +550,9 @@ Modification du fichier export et reperage de quelques informations
     message_erreur = " "
 #
     if self.verbose_max :
-      print blabla
-      print ". numero     :", self.numero
-      print ". mesh_file  :", self.mesh_file
+      print(blabla)
+      print(". numero     :", self.numero)
+      print(". mesh_file  :", self.mesh_file)
 #
     while not erreur :
 #
@@ -571,7 +571,7 @@ Modification du fichier export et reperage de quelques informations
       nomfic += "." + self.numero_str + ".export"
       self.nomfic_export = os.path.join(self.rep_calc, nomfic)
       if self.verbose_max :
-        print ". nouveau fic_export :", self.nomfic_export
+        print(". nouveau fic_export :", self.nomfic_export)
       fic = open (self.nomfic_export, "w")
 #
 # 3. Exploration des lignes
@@ -606,7 +606,7 @@ Modification du fichier export et reperage de quelques informations
           if ( typfic == "comm" ) :
 #
             if self.verbose_max :
-              print ". Commandes : mise a jour du nom du repertoire"
+              print(". Commandes : mise a jour du nom du repertoire")
             chgt = True
             nomfic_l_0 = os.path.basename(nomfic_0)
             nomfic = os.path.join(self.rep_calc, nomfic_l_0)
@@ -615,7 +615,7 @@ Modification du fichier export et reperage de quelques informations
 #
           elif ( ( statut == "R" ) or ( typfic == "mmed" ) ) :
             if self.verbose_max :
-              print ". Mise a jour du nom"
+              print(". Mise a jour du nom")
             chgt = True
 #
 # 3.2.2.1. Le fichier de maillage est celui passe en argument
@@ -739,13 +739,13 @@ Modification du fichier export et reperage de quelques informations
       message_erreur = messages_erreur[erreur]
 #
     if self.verbose_max :
-      print ". mclient    ", self.mclient
-      print ". uclient    ", self.uclient
-      print ". serveur    ", self.serveur
-      print ". username   ", self.username
-      print ". aster_root ", self.aster_root
-      print ". nomjob     ", self.nomjob
-      print ". mode       ", self.mode
+      print(". mclient    ", self.mclient)
+      print(". uclient    ", self.uclient)
+      print(". serveur    ", self.serveur)
+      print(". username   ", self.username)
+      print(". aster_root ", self.aster_root)
+      print(". nomjob     ", self.nomjob)
+      print(". mode       ", self.mode)
 #
     return erreur, message_erreur
 #
@@ -769,9 +769,9 @@ Modification du fichier de commandes lie au cas transitoire
     message_erreur = " "
 #
     if self.verbose_max :
-      print blabla
-      print ". opt1 :", self.opt1
-      print ". opt2 :", self.opt2
+      print(blabla)
+      print(". opt1 :", self.opt1)
+      print(". opt2 :", self.opt2)
 #
     while not erreur :
 #
@@ -795,7 +795,7 @@ Modification du fichier de commandes lie au cas transitoire
       for ligne in les_lignes :
 #
         if self.verbose_max :
-          print "ligne =", ligne[:-1]
+          print("ligne =", ligne[:-1])
 #
 # 3.1. Pas de modification, a priori
 #
@@ -875,10 +875,10 @@ Modification du fichier de commandes lie au cas de l'excavation
     message_erreur = " "
 #
     if self.verbose_max :
-      print blabla
-      print ". numero     :", self.numero
-      print ". nro_couche :", self.nro_couche
-      print ". nro_adap   :", self.nro_adap
+      print(blabla)
+      print(". numero     :", self.numero)
+      print(". nro_couche :", self.nro_couche)
+      print(". nro_adap   :", self.nro_adap)
 #
     while not erreur :
 #
@@ -902,7 +902,7 @@ Modification du fichier de commandes lie au cas de l'excavation
       for ligne in les_lignes :
 #
         if self.verbose_max :
-          print "ligne =", ligne[:-1]
+          print("ligne =", ligne[:-1])
 #
 # 3.1. Pas de modification, a priori
 #
@@ -974,8 +974,8 @@ Lancement d'un calcul
     message_erreur = " "
 #
     if self.verbose_max :
-      print ". mclient    ", self.mclient
-      print ". serveur    ", self.serveur
+      print(". mclient    ", self.mclient)
+      print(". serveur    ", self.serveur)
 #
 # 1. Copie du fichier export sur le serveur de calcul
 #
@@ -984,8 +984,8 @@ Lancement d'un calcul
       nomfic_export_dist = self.nomjob + ".export"
       commande = "scp " + self.nomfic_export + " " + self.username + "@" + self.serveur + ":" + nomfic_export_dist
       if self.verbose_max :
-        print "Copie du fichier export vers", self.serveur, ":"
-        print commande
+        print("Copie du fichier export vers", self.serveur, ":")
+        print(commande)
       erreur = os.system(commande)
 #
 # 2. Commande du lancement
@@ -1015,8 +1015,8 @@ Lancement d'un calcul
     commande += " 1>" + fic_caract
     commande += " 2>" + fic_caract_2
     if self.verbose_max :
-      print "Lancement sur", self.serveur, ":"
-      print commande
+      print("Lancement sur", self.serveur, ":")
+      print(commande)
 #
 # 3.2. Lancement vrai
 #
@@ -1029,10 +1029,10 @@ Lancement d'un calcul
       self.message_info += self.dico["rmed"]+"\n"
 #
     if self.verbose_max :
-      print blabla
-      print ". erreur     :", erreur
-      print ". self.mode  :", self.mode
-      print ". fic_caract :", fic_caract
+      print(blabla)
+      print(". erreur     :", erreur)
+      print(". self.mode  :", self.mode)
+      print(". fic_caract :", fic_caract)
 #
     if erreur :
       message_erreur = messages_erreur[erreur]
@@ -1057,11 +1057,11 @@ fic_caract : fichier caracteristique du job
     message_erreur = " "
 #
     if self.verbose_max :
-      print ". fic_caract :", fic_caract
-      print ". nomjob     :", self.nomjob
-      print ". rep_calc   :", self.rep_calc
-      print ". mode       :", self.mode
-      print ". attente    :", self.attente
+      print(". fic_caract :", fic_caract)
+      print(". nomjob     :", self.nomjob)
+      print(". rep_calc   :", self.rep_calc)
+      print(". mode       :", self.mode)
+      print(". attente    :", self.attente)
 #
     if ( self.mode != "interactif" ) :
 #
@@ -1088,7 +1088,7 @@ fic_caract : fichier caracteristique du job
             numjob = laux1[0]
   #
       if self.verbose :
-        print ". numjob :", numjob
+        print(". numjob :", numjob)
 #
 # 2. Commande de l'examen de l'etat du job,
 #
@@ -1098,7 +1098,7 @@ fic_caract : fichier caracteristique du job
       commande_base  = os.path.join(self.aster_root, "bin", "as_run")
       commande_base += " --actu " + numjob + " " + self.nomjob + " " + self.mode
       if self.verbose_max :
-        print "commande_base =", commande_base
+        print("commande_base =", commande_base)
       if ( self.mclient == self.serveur ) :
         commande  = commande_base
       else :
@@ -1107,8 +1107,8 @@ fic_caract : fichier caracteristique du job
       commande += " 1>" + fic_etat
       commande += " 2>" + fic_etat_2
       if self.verbose_max :
-        print "Examen sur", self.serveur, ":"
-        print commande
+        print("Examen sur", self.serveur, ":")
+        print(commande)
 #
 # 3. Examen de l'etat du job, jusqu'a la fin
 #
@@ -1117,7 +1117,7 @@ fic_caract : fichier caracteristique du job
   #
         if encore % 4 == 0 :
           aux = ((encore-1)*self.attente) / 60
-          print "..", aux, "mn"
+          print("..", aux, "mn")
           #print diag
   #
         time.sleep(self.attente)
@@ -1138,7 +1138,7 @@ fic_caract : fichier caracteristique du job
               laux1 = laux[1].split("=")
               diag = laux1[1]
               if self.verbose_max :
-                print etat, diag
+                print(etat, diag)
               if etat in ( "RUN", "PEND" ) :
                 encore += 1
               else :
@@ -1163,8 +1163,8 @@ fic_caract : fichier caracteristique du job
       os.remove(fic_etat_2)
 #
     if self.verbose_max :
-      print blabla
-      print ". erreur :", erreur
+      print(blabla)
+      print(". erreur :", erreur)
 #
     if erreur :
       message_erreur = "Erreur dans le calcul"
@@ -1191,8 +1191,7 @@ Affichage de resultats selon les cas
     message_erreur = " "
 #
     dico_resu = {}
-    for cle in dico_resu_init.keys() :
-      dico_resu[cle] = dico_resu_init[cle]
+    dico_resu.update(dico_resu_init)
 #
     while not erreur :
 #
@@ -1270,9 +1269,9 @@ Affichage de resultats selon les cas
       break
 #
     if self.verbose :
-      print blabla
-      print ". erreur :", erreur
-      print ". dico_resu :", dico_resu
+      print(blabla)
+      print(". erreur :", erreur)
+      print(". dico_resu :", dico_resu)
 #
     if erreur :
       message_erreur = messages_erreur[erreur]
@@ -1306,7 +1305,7 @@ info = la ou les lignes recherchees
     nom_fonction = __name__ + "/post_aster_1"
     blabla = "\nDans " + nom_fonction + " :"
     if self.verbose_max :
-      print blabla, "nomfic =", nomfic, "chaine =", chaine, ", nuocc =", nuocc
+      print(blabla, "nomfic =", nomfic, "chaine =", chaine, ", nuocc =", nuocc)
 #
     trouve = False
     erreur = 0
@@ -1353,8 +1352,8 @@ info = la ou les lignes recherchees
       erreur = -1
 #
     if ( self.verbose_max or ( erreur>0 ) ) :
-      print blabla, "nomfic =", nomfic, "chaine =", chaine, ", nuocc =", nuocc
-      print ". erreur =", erreur
+      print(blabla, "nomfic =", nomfic, "chaine =", chaine, ", nuocc =", nuocc)
+      print(". erreur =", erreur)
 #
     if erreur :
       message_erreur = messages_erreur[erreur]
@@ -1396,8 +1395,8 @@ Dump du resultat du calcul
       self.message_info += fic_dump+"\n"
 #
     if self.verbose_max :
-      print blabla
-      print ". erreur :", erreur
+      print(blabla)
+      print(". erreur :", erreur)
 #
     os.remove(nomfic_donn)
 #
index 74a4d08b0cfafc9d7b1e933d4fb6a7f131f685f7..12f4f581323019c0c76ffc18381187f3d637b702 100755 (executable)
@@ -100,10 +100,10 @@ Le constructeur de la classe Script
 #
     if self.verbose_max :
       nom_fonction = __name__ + "/__init__"
-      print "\nDans " + nom_fonction + ","
-      print ". rep_calc       :", self.rep_calc
-      print ". mesh_file      :", self.mesh_file
-      print ". numero         :", self.numero
+      print("\nDans " + nom_fonction + ",")
+      print(". rep_calc       :", self.rep_calc)
+      print(". mesh_file      :", self.mesh_file)
+      print(". numero         :", self.numero)
 #
 #=========================  Fin de la fonction ===================================
 #
@@ -141,8 +141,8 @@ Lancement d'un calcul
       break
 #
     if self.verbose_max :
-      print blabla
-      print ". erreur :", erreur
+      print(blabla)
+      print(". erreur :", erreur)
 #
     return erreur, message_erreur, dico_resu
 #
@@ -170,10 +170,10 @@ Controle les arguments et stockage de quelques informations
     message_erreur = " "
 #
     if self.verbose_max :
-      print blabla
-      print ". rep_calc       :", self.rep_calc
-      print ". mesh_file      :", self.mesh_file
-      print ". numero         :", self.numero
+      print(blabla)
+      print(". rep_calc       :", self.rep_calc)
+      print(". mesh_file      :", self.mesh_file)
+      print(". numero         :", self.numero)
 #
     while not erreur :
 #
@@ -190,7 +190,7 @@ Controle les arguments et stockage de quelques informations
 #
 # 1.2. Le repertoire de calcul
 #
-      if os.environ.has_key("HOME") :
+      if "HOME" in os.environ :
         HOME = os.environ ["HOME"]
       else :
         HOME = "/local/home/salome"
@@ -234,8 +234,8 @@ Controle les arguments et stockage de quelques informations
       message_erreur = messages_erreur[erreur]
 #
     if self.verbose_max :
-      print ". rep_calc  :", self.rep_calc
-      print ". mesh_file :", self.mesh_file
+      print(". rep_calc  :", self.rep_calc)
+      print(". mesh_file :", self.mesh_file)
 #
     return erreur, message_erreur
 #
index 8c2e4bbab28067fb8ac9313f64071c736434b694..915463dfbb6380834bb5c4d0e9ed4e22ac2201e6 100644 (file)
@@ -33,6 +33,7 @@
 #include "HOMARD_version.h"
 
 #include "utilities.h"
+#include "Basics_Utils.hxx"
 #include "Utils_SINGLETON.hxx"
 #include "Utils_CorbaException.hxx"
 #include "SALOMEDS_Tool.hxx"
@@ -120,7 +121,7 @@ HOMARD_Gen_i::~HOMARD_Gen_i()
 }
 //=============================================================================
 //=============================================================================
-// Utilitaires pour l'étude
+// Utilitaires pour l'??tude
 //=============================================================================
 //=============================================================================
 void HOMARD_Gen_i::UpdateStudy()
@@ -1303,13 +1304,13 @@ HOMARD::HOMARD_Cas_ptr HOMARD_Gen_i::CreateCaseFromIteration(const char* nomCas,
   char* MeshFile ;
   // le constructeur de ifstream permet d'ouvrir un fichier en lecture
   std::ifstream fichier( file_configuration.c_str() );
-  if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
+  if ( fichier ) // ce test ??choue si le fichier n'est pas ouvert
   {
     std::string ligne; // variable contenant chaque ligne lue
     std::string mot_cle;
     std::string argument;
     int decalage;
-    // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
+    // cette boucle sur les lignes s'arr??te d??s qu'une erreur de lecture survient
     while ( std::getline( fichier, ligne ) )
     {
       // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
@@ -1549,12 +1550,12 @@ std::string HOMARD_Gen_i::CreateCase1(const char* DirNameStart, CORBA::Long Numb
             CHDIR(DirName_1.c_str()) ;
 
             std::ifstream fichier( file_name_1.c_str() );
-            if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
+            if ( fichier ) // ce test ??choue si le fichier n'est pas ouvert
             {
               int NumeIter ;
               std::string ligne; // variable contenant chaque ligne lue
               std::string mot_cle;
-              // cette boucle sur les lignes s'arrête dès qu'une erreur de lecture survient
+              // cette boucle sur les lignes s'arr??te d??s qu'une erreur de lecture survient
               while ( std::getline( fichier, ligne ) )
               {
                 // B.1. Pour la ligne courante, on identifie le premier mot : le mot-cle
@@ -2584,7 +2585,7 @@ CORBA::Long HOMARD_Gen_i::Compute(const char* NomIteration, CORBA::Long etatMena
         text = "Error during the adaptation.\n" ;
         bool stopvu = false ;
         std::ifstream fichier( LogFile.c_str() );
-        if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
+        if ( fichier ) // ce test ??choue si le fichier n'est pas ouvert
         {
           std::string ligne; // variable contenant chaque ligne lue
           while ( std::getline( fichier, ligne ) )
@@ -3235,7 +3236,7 @@ void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIterati
         // Le type d'interpolation
         std::string TypeInterpstr = std::string((*ListField)[iaux+1]) ;
         MESSAGE( "... FieldName = " << FieldName << ", TypeInterp = " << TypeInterpstr );
-        // On cherche à savoir si des instants ont été précisés pour cette itération
+        // On cherche ?? savoir si des instants ont ??t?? pr??cis??s pour cette it??ration
         int tsrvu = 0;
         for (int jaux = 0; jaux< numberOfFieldsx3; jaux++)
         {
@@ -3258,7 +3259,7 @@ void HOMARD_Gen_i::DriverTexteFieldInterp(HOMARD::HOMARD_Iteration_var myIterati
           }
           jaux += 2 ;
         }
-        // Si aucun instant n'a été défini
+        // Si aucun instant n'a ??t?? d??fini
         if ( tsrvu == 0 )
         {
           NumField += 1 ;
@@ -3931,7 +3932,7 @@ void HOMARD_Gen_i::PublishFileUnderYACS(const char* nomYACS, const char* NomFich
 // Creation d'un schema YACS
 // nomCas : nom du cas a traiter
 // FileName : nom du fichier contenant le script de lancement du calcul
-// DirName : le repertoire de lancement des calculs du schéma
+// DirName : le repertoire de lancement des calculs du sch??ma
 //=============================================================================
 HOMARD::HOMARD_YACS_ptr HOMARD_Gen_i::CreateYACSSchema (const char* nomYACS, const char* nomCas, const char* ScriptFile, const char* DirName, const char* MeshFile)
 {
@@ -4112,7 +4113,7 @@ CORBA::Long HOMARD_Gen_i::YACSWriteOnFile(const char* nomYACS, const char* XMLFi
   // G. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
   YACSDriver* myDriver = new YACSDriver(XMLFile, DirName);
   std::ifstream fichier( XMLFile_base.c_str() );
-  if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
+  if ( fichier ) // ce test ??choue si le fichier n'est pas ouvert
   {
     // G.1. Lecture du schema de reference et insertion des donnees propres au fil de la rencontre des mots-cles
     std::string ligne; // variable contenant chaque ligne lue
@@ -4324,7 +4325,7 @@ SALOMEDS::TMPFile* HOMARD_Gen_i::Save(SALOMEDS::SComponent_ptr theComponent,
   // HOMARD data file name
   std::string aFileName = "";
   if (isMultiFile)
-    aFileName = SALOMEDS_Tool::GetNameFromPath(SMESH_Gen_i::getStudyServant()->URL());
+    aFileName = SALOMEDS_Tool::GetNameFromPath(Kernel_Utils::encode(SMESH_Gen_i::getStudyServant()->URL()));
   aFileName += "_HOMARD.dat";
 
   // initialize sequence of file names
@@ -4448,7 +4449,7 @@ CORBA::Boolean HOMARD_Gen_i::Load(SALOMEDS::SComponent_ptr theComponent,
   // HOMARD data file name
   std::string aFileName = "";
   if (isMultiFile)
-    aFileName = SALOMEDS_Tool::GetNameFromPath(SMESH_Gen_i::getStudyServant()->URL());
+    aFileName = SALOMEDS_Tool::GetNameFromPath(Kernel_Utils::encode(SMESH_Gen_i::getStudyServant()->URL()));
   aFileName = tmpDir + aFileName + "_HOMARD.dat";
 
   StudyContext& context = myStudyContext;
@@ -4984,7 +4985,7 @@ void HOMARD_Gen_i::SetPreferences( )
   File += "/bin/salome/VERSION" ;
   MESSAGE ( "File = "<<File ) ;
   std::ifstream fichier0( File.c_str() ) ;
-  if ( fichier0 ) // ce test échoue si le fichier n'est pas ouvert
+  if ( fichier0 ) // ce test ??choue si le fichier n'est pas ouvert
   {
     std::string ligne; // variable contenant chaque ligne lue
     while ( std::getline( fichier0, ligne ) )
@@ -5010,7 +5011,7 @@ void HOMARD_Gen_i::SetPreferences( )
     MESSAGE ( "PrefFile = "<<PrefFile ) ;
 
     std::ifstream fichier( PrefFile.c_str() );
-    if ( fichier ) // ce test échoue si le fichier n'est pas ouvert
+    if ( fichier ) // ce test ??choue si le fichier n'est pas ouvert
     {
       bool section_langue = false ;
       bool section_homard = false ;
index dab7822c38466457105d09053e998a8c895f37d6..ed29dda9d569e9647914a45a0b0354513f3d9b92 100644 (file)
@@ -29,7 +29,7 @@
 # see salome_shared_modules.py
 # (avoids incomplete import at run time)
 
-print "============== import HOMARD ======================="
+print("============== import HOMARD =======================")
 
 import HOMARD
 
index 4267c919271f021bbc0b5fea39662b4eba7cd18e..f9fe63ac54e0be8398569e22b870920381d5968d 100755 (executable)
@@ -87,7 +87,7 @@ Python script for HOMARD
     dico["-1"] = "deraffinement"
   # Creation of the hypothesis a10_1pc_de_mailles_a_raffiner_sur_ERRE_ELEM_SIGM
     hyponame_1 = "a10_1pc_de_mailles_a_raffiner_sur_ERRE_ELEM_SIGM"
-    print "-------- Creation of the hypothesis", hyponame_1
+    print("-------- Creation of the hypothesis", hyponame_1)
     hypo_1_1 = HOMARD.CreateHypothesis(hyponame_1)
     hypo_1_1.SetField('RESU____ERRE_ELEM_SIGM__________')
     hypo_1_1.SetUseComp(0)
@@ -95,32 +95,32 @@ Python script for HOMARD
     hypo_1_1.SetRefinThr(3, 10.1)
     hypo_1_1.AddFieldInterp('RESU____DEPL____________________')
     hypo_1_1.AddFieldInterp('RESU____ERRE_ELEM_SIGM__________')
-    print hyponame_1, " : champ utilisé :", hypo_1_1.GetFieldName()
-    print hyponame_1, " : composantes utilisées :", hypo_1_1.GetComps()
+    print(hyponame_1, " : champ utilisé :", hypo_1_1.GetFieldName())
+    print(hyponame_1, " : composantes utilisées :", hypo_1_1.GetComps())
     if ( len (hypo_1_1.GetFieldName()) > 0 ) :
-      print ".. caractéristiques de l'adaptation :", hypo_1_1.GetField()
-    print hyponame_1, " : champs interpolés :", hypo_1_1.GetFieldInterps()
+      print(".. caractéristiques de l'adaptation :", hypo_1_1.GetField())
+    print(hyponame_1, " : champs interpolés :", hypo_1_1.GetFieldInterps())
   # Creation of the hypothesis Zones_1_et_2
     hyponame_2 = "Zones_1_et_2"
-    print "-------- Creation of the hypothesis", hyponame_2
+    print("-------- Creation of the hypothesis", hyponame_2)
     zones_1_et_2 = HOMARD.CreateHypothesis(hyponame_2)
     zones_1_et_2.AddZone('Zone_1_1', 1)
     zones_1_et_2.AddZone('Zone_1_2', 1)
     laux = zones_1_et_2.GetZones()
-    nbzone = len(laux)/2
+    nbzone = len(laux) // 2
     jaux = 0
-    for iaux in range(nbzone) :
-      print hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux]
+    for _ in range(nbzone) :
+      print(hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux])
       jaux += 2
-    print hyponame_2, " : champ utilisé :", zones_1_et_2.GetFieldName()
+    print(hyponame_2, " : champ utilisé :", zones_1_et_2.GetFieldName())
     if ( len (zones_1_et_2.GetFieldName()) > 0 ) :
-      print ".. caractéristiques de l'adaptation :", zones_1_et_2.GetField()
-    print hyponame_2, " : champs interpolés :", zones_1_et_2.GetFieldInterps()
+      print(".. caractéristiques de l'adaptation :", zones_1_et_2.GetField())
+    print(hyponame_2, " : champs interpolés :", zones_1_et_2.GetFieldInterps())
   #
   # Creation of the cases
   # =====================
     # Creation of the case
-    print "-------- Creation of the case", TEST_NAME
+    print("-------- Creation of the case", TEST_NAME)
     mesh_file = os.path.join(REP_DATA, TEST_NAME + '.00.med')
     case_test_1 = HOMARD.CreateCase(TEST_NAME, 'MAILL', mesh_file)
     case_test_1.SetDirName(DIRCASE)
@@ -129,17 +129,17 @@ Python script for HOMARD
   # ==========================
   # Creation of the iteration 1
     iter_name = "I_" + TEST_NAME + "_1"
-    print "-------- Creation of the iteration", iter_name
+    print("-------- Creation of the iteration", iter_name)
     iter_test_1_1 = case_test_1.NextIteration(iter_name)
     iter_test_1_1.AssociateHypo(hyponame_1)
-    print ". Hypothese :", hyponame_1
+    print(". Hypothese :", hyponame_1)
     iter_test_1_1.SetMeshName('M1')
     iter_test_1_1.SetMeshFile(os.path.join(DIRCASE, 'maill.01.med'))
     iter_test_1_1.SetFieldFile(os.path.join(REP_DATA, TEST_NAME + '.00.med'))
     iter_test_1_1.SetTimeStepRank(1, 1)
     iter_test_1_1.SetFieldInterpTimeStep('RESU____DEPL____________________', 1)
     iter_test_1_1.SetFieldInterpTimeStepRank('RESU____ERRE_ELEM_SIGM__________', 1, 1)
-    print ". Instants d'interpolation :", iter_test_1_1.GetFieldInterpsTimeStepRank()
+    print(". Instants d'interpolation :", iter_test_1_1.GetFieldInterpsTimeStepRank())
     error = iter_test_1_1.Compute(1, 1)
     if error :
       error = 1
@@ -147,17 +147,17 @@ Python script for HOMARD
 
   # Creation of the iteration 2
     iter_name = "I_" + TEST_NAME + "_2"
-    print "-------- Creation of the iteration", iter_name
+    print("-------- Creation of the iteration", iter_name)
     iter_test_1_2 = iter_test_1_1.NextIteration(iter_name)
     iter_test_1_2.AssociateHypo(hyponame_1)
-    print ". Hypothese :", hyponame_1
+    print(". Hypothese :", hyponame_1)
     iter_test_1_2.SetMeshName('M2')
     iter_test_1_2.SetMeshFile(os.path.join(DIRCASE, 'maill.02.med'))
     iter_test_1_2.SetFieldFile(os.path.join(REP_DATA, TEST_NAME + '.01.med'))
     iter_test_1_2.SetTimeStepRank(1, 1)
     iter_test_1_2.SetFieldInterpTimeStep('RESU____DEPL____________________', 1)
     iter_test_1_2.SetFieldInterpTimeStepRank('RESU____ERRE_ELEM_SIGM__________', 1, 1)
-    print ". Instants d'interpolation :", iter_test_1_2.GetFieldInterpsTimeStepRank()
+    print(". Instants d'interpolation :", iter_test_1_2.GetFieldInterpsTimeStepRank())
     error = iter_test_1_2.Compute(1, 1)
     if error :
       error = 2
@@ -165,14 +165,14 @@ Python script for HOMARD
 
   # Creation of the iteration 3
     iter_name = "I_" + TEST_NAME + "_3"
-    print "-------- Creation of the iteration", iter_name
+    print("-------- Creation of the iteration", iter_name)
     iter_test_1_3 = iter_test_1_2.NextIteration(iter_name)
     iter_test_1_3.AssociateHypo(hyponame_2)
-    print ". Hypothese :", hyponame_2
+    print(". Hypothese :", hyponame_2)
     iter_test_1_3.SetMeshName('M3')
     iter_test_1_3.SetMeshFile(os.path.join(DIRCASE, 'maill.03.med'))
     iter_test_1_2.SetFieldFile(os.path.join(REP_DATA, TEST_NAME + '.02.med'))
-    print ". Instants d'interpolation :", iter_test_1_3.GetFieldInterpsTimeStepRank()
+    print(". Instants d'interpolation :", iter_test_1_3.GetFieldInterpsTimeStepRank())
     error = iter_test_1_3.Compute(1, 1)
     if error :
       error = 3
@@ -205,8 +205,8 @@ try :
   ERROR = homard_exec()
   if ERROR :
     raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
-  raise Exception('Pb in homard_exec: '+eee.message)
+except Exception as eee:
+  raise Exception('Pb in homard_exec: ' + str(eee))
 #
 # Test of the results
 #
index 3b903cc70b8e9794635af1a59b9a76c63ca9ef8c..12273aa594a339d5043427751f084c96dac86117 100755 (executable)
@@ -81,28 +81,28 @@ Python script for HOMARD
   # ==========================
   # Creation of the hypothesis 1
     hyponame_1 = "hypo_" + TEST_NAME + "_1"
-    print "-------- Creation of the hypothesis", hyponame_1
+    print("-------- Creation of the hypothesis", hyponame_1)
     hypo_test_2_1 = HOMARD.CreateHypothesis(hyponame_1)
     hypo_test_2_1.SetUnifRefinUnRef(1)
     hypo_test_2_1.AddGroup('EG')
     hypo_test_2_1.AddGroup('BANDE')
-    print hyponame_1, " : zones utilisées :", hypo_test_2_1.GetZones()
-    print hyponame_1, " : champ utilisé :", hypo_test_2_1.GetFieldName()
-    print hyponame_1, " : composantes utilisées :", hypo_test_2_1.GetComps()
+    print(hyponame_1, " : zones utilisées :", hypo_test_2_1.GetZones())
+    print(hyponame_1, " : champ utilisé :", hypo_test_2_1.GetFieldName())
+    print(hyponame_1, " : composantes utilisées :", hypo_test_2_1.GetComps())
     if ( len (hypo_test_2_1.GetFieldName()) > 0 ) :
-      print ".. caractéristiques de l'adaptation :", hypo_test_2_1.GetField()
+      print(".. caractéristiques de l'adaptation :", hypo_test_2_1.GetField())
 
   # Creation of the hypothesis 2
     hyponame_2 = "hypo_" + TEST_NAME + "_2"
-    print "-------- Creation of the hypothesis", hyponame_2
+    print("-------- Creation of the hypothesis", hyponame_2)
     hypo_test_2_2 = HOMARD.CreateHypothesis(hyponame_2)
     hypo_test_2_2.SetUnifRefinUnRef(1)
     hypo_test_2_2.AddGroup('M_D')
-    print hyponame_2, " : zones utilisées :", hypo_test_2_2.GetZones()
-    print hyponame_2, " : champ utilisé :", hypo_test_2_2.GetFieldName()
-    print hyponame_2, " : composantes utilisées :", hypo_test_2_2.GetComps()
+    print(hyponame_2, " : zones utilisées :", hypo_test_2_2.GetZones())
+    print(hyponame_2, " : champ utilisé :", hypo_test_2_2.GetFieldName())
+    print(hyponame_2, " : composantes utilisées :", hypo_test_2_2.GetComps())
     if ( len (hypo_test_2_2.GetFieldName()) > 0 ) :
-      print ".. caractéristiques de l'adaptation :", hypo_test_2_2.GetField()
+      print(".. caractéristiques de l'adaptation :", hypo_test_2_2.GetField())
   #
   # Creation of the cases
   # =====================
@@ -177,7 +177,7 @@ try :
   ERROR = homard_exec()
   if ERROR :
     raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
+except Exception as eee:
   raise Exception('Pb in homard_exec: '+eee.message)
 #
 # Test of the results
index 15ddbd7d9d30c50591442437ea564b8271317d9c..6c9b3dc63b67101ac36cf8f4407839f2dd3d816a 100755 (executable)
@@ -94,21 +94,21 @@ Python script for HOMARD
   # ==========================
   # Uniform refinement
     hyponame = "hypo_" + TEST_NAME
-    print "-------- Creation of the hypothesis", hyponame
+    print("-------- Creation of the hypothesis", hyponame)
     hypo_test_3 = HOMARD.CreateHypothesis(hyponame)
     hypo_test_3.SetUnifRefinUnRef(1)
-    print hyponame, " : zones utilisées :", hypo_test_3.GetZones()
-    print hyponame, " : champ utilisé :", hypo_test_3.GetFieldName()
-    print hyponame, " : composantes utilisées :", hypo_test_3.GetComps()
+    print(hyponame, " : zones utilisées :", hypo_test_3.GetZones())
+    print(hyponame, " : champ utilisé :", hypo_test_3.GetFieldName())
+    print(hyponame, " : composantes utilisées :", hypo_test_3.GetComps())
   #
     for num in range (N_BOUCLE+1) :
   #
-      print "-------- num =", num, "--------"
+      print("-------- num =", num, "--------")
   #
   # Creation of the case case_test_3
   # ===========================
       if ( num <= 1 ) :
-        print "-------- Creation of the case", TEST_NAME
+        print("-------- Creation of the case", TEST_NAME)
         mesh_file = os.path.join(REP_DATA, TEST_NAME + '.00.med')
         case_test_3 = HOMARD.CreateCase(TEST_NAME, 'MOYEU', mesh_file)
         case_test_3.SetDirName(DIRCASE)
@@ -122,7 +122,7 @@ Python script for HOMARD
   # ==========================
   # Creation of the iteration 1
       iter_name = "I_" + TEST_NAME + "_1"
-      print "-------- Creation of the iteration", iter_name
+      print("-------- Creation of the iteration", iter_name)
       iter_test_3_1 = case_test_3.NextIteration(iter_name)
       iter_test_3_1.SetMeshName('MOYEU_1')
       iter_test_3_1.SetMeshFile(os.path.join(DIRCASE, 'maill.01.med'))
@@ -134,7 +134,7 @@ Python script for HOMARD
 
   # Creation of the iteration 2
       iter_name = "I_" + TEST_NAME + "_2"
-      print "-------- Creation of the iteration", iter_name
+      print("-------- Creation of the iteration", iter_name)
       iter_test_3_2 = iter_test_3_1.NextIteration(iter_name)
       iter_test_3_2.SetMeshName('MOYEU_2')
       iter_test_3_2.SetMeshFile(os.path.join(DIRCASE, 'maill.02.med'))
@@ -150,7 +150,7 @@ Python script for HOMARD
       scriptfile = os.path.normpath(scriptfile)
       dirname = DIRCASE
       yacsname = "YACS_" + TEST_NAME
-      print "-------- Creation of the schema", yacsname
+      print("-------- Creation of the schema", yacsname)
       yacs_test_3 = case_test_3.CreateYACSSchema(yacsname, scriptfile, dirname, mesh_file)
       yacs_test_3.SetType(2)
       yacs_test_3.SetMaxIter(2)
@@ -163,7 +163,7 @@ Python script for HOMARD
   # ============
   # Destruction of the schema, sauf a la fin
       if ( num < N_BOUCLE ) :
-        print "-------- Destruction of the schema", yacs_test_3.GetName()
+        print("-------- Destruction of the schema", yacs_test_3.GetName())
         error = yacs_test_3.Delete(1)
         if error :
           error = 10*num + 6
@@ -171,27 +171,27 @@ Python script for HOMARD
   # After the first loop, the case is deleted, except the final mesh files
   # All the iterations are deleted
       if ( num == 0 ) :
-        print "-------- Destruction of the case", case_test_3.GetName()
+        print("-------- Destruction of the case", case_test_3.GetName())
         error = case_test_3.Delete(0)
         if error :
           break
   # After the second loop, the iterations are deleted, with the final mesh files
       elif ( num == 1 ) :
   # Recursive destruction of the iterations
-        print "-------- Recursive destruction of the iteration", iter_test_3_1.GetName()
+        print("-------- Recursive destruction of the iteration", iter_test_3_1.GetName())
         error = iter_test_3_1.Delete(1)
         if error :
           error = 10*num + 3
           break
   # Destruction and creation of the hypothese
         if ( num == 1 ) :
-          print "-------- Destruction of the hypothese", hypo_test_3.GetName()
+          print("-------- Destruction of the hypothese", hypo_test_3.GetName())
           error = hypo_test_3.Delete()
           if error :
             error = 10*num + 4
             break
           hyponame = "hypo_test_3"
-          print "-------- Creation of the hypothesis", hyponame
+          print("-------- Creation of the hypothesis", hyponame)
           hypo_test_3 = HOMARD.CreateHypothesis(hyponame)
           hypo_test_3.SetUnifRefinUnRef(1)
   #
@@ -211,7 +211,7 @@ try :
   ERROR = homard_exec()
   if ERROR :
     raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
+except Exception as eee:
   raise Exception('Pb in homard_exec: '+eee.message)
 #
 # Test of the results
index f294ceaf0c7b326d6dc43821238fd627f9809abc..eadda0ce20bee7195417fa225f0c581db55f07c1 100755 (executable)
@@ -128,9 +128,9 @@ Python script for GEOM and SMESH
     try:
       ficmed = os.path.join(DIRCASE, 'maill.00.med')
       box_m.ExportMED( ficmed, 0, SMESH.MED_V2_2, 1, None, 1)
-    except Exception, eee:
+    except Exception as eee:
       error = 2
-      raise Exception('ExportToMEDX() failed. '+eee.message)
+      raise Exception('ExportToMEDX() failed. ' + str(eee))
   #
     break
   #
@@ -166,7 +166,7 @@ Python script for MEDCoupling
       valeur[iaux] = 1.e0 / max ( 1.e-5, np.sqrt(distance) )
     #print ". valeur", valeur
     nparr = valeur.toNumPyArray()
-    print ". mini/maxi", nparr.min(), nparr.max()
+    print(". mini/maxi", nparr.min(), nparr.max())
   #
   # Creation of the field
   # =====================
@@ -213,31 +213,31 @@ Python script for HOMARD
     dico["-1"] = "deraffinement"
   # Creation of the hypothesis hypo_4_1
     hyponame_1 = "Zone_1"
-    print "-------- Creation of the hypothesis", hyponame_1
+    print("-------- Creation of the hypothesis", hyponame_1)
     hypo_4_1 = HOMARD.CreateHypothesis(hyponame_1)
     hypo_4_1.AddZone('Zone_4_1', 1)
     hypo_4_1.SetExtraOutput(2)
     laux = hypo_4_1.GetZones()
-    nbzone = len(laux)/2
+    nbzone = len(laux) // 2
     jaux = 0
     for iaux in range(nbzone) :
-      print hyponame_1, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux]
+      print(hyponame_1, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux])
       jaux += 2
   # Creation of the hypothesis hypo_4_2
     hyponame_2 = "Zone_2"
-    print "-------- Creation of the hypothesis", hyponame_2
+    print("-------- Creation of the hypothesis", hyponame_2)
     hypo_4_2 = HOMARD.CreateHypothesis(hyponame_2)
     hypo_4_2.AddZone('Zone_4_2', 1)
     hypo_4_2.SetExtraOutput(2)
     laux = hypo_4_2.GetZones()
-    nbzone = len(laux)/2
+    nbzone = len(laux) // 2
     jaux = 0
     for iaux in range(nbzone) :
-      print hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux]
+      print(hyponame_2, " : ", dico[laux[jaux+1]], "sur la zone", laux[jaux])
       jaux += 2
   # Creation of the hypothesis DISTANCE INVERSE
     hyponame_3 = "DISTANCE INVERSE"
-    print "-------- Creation of the hypothesis", hyponame_3
+    print("-------- Creation of the hypothesis", hyponame_3)
     hypo_4_3 = HOMARD.CreateHypothesis(hyponame_3)
     hypo_4_3.SetField('DISTANCE')
     hypo_4_3.SetUseComp(0)
@@ -245,17 +245,17 @@ Python script for HOMARD
     hypo_4_3.SetUnRefThr(1, 0.2)
     hypo_4_3.AddFieldInterp('DISTANCE')
     hypo_4_3.SetExtraOutput(2)
-    print hyponame_3, " : zones utilisées :", hypo_4_3.GetZones()
-    print hyponame_3, " : champ utilisé :", hypo_4_3.GetFieldName()
-    print hyponame_3, " : composantes utilisées :", hypo_4_3.GetComps()
+    print(hyponame_3, " : zones utilisées :", hypo_4_3.GetZones())
+    print(hyponame_3, " : champ utilisé :", hypo_4_3.GetFieldName())
+    print(hyponame_3, " : composantes utilisées :", hypo_4_3.GetComps())
     if ( len (hypo_4_3.GetFieldName()) > 0 ) :
-      print ".. caractéristiques de l'adaptation :", hypo_4_3.GetField()
-    print hyponame_3, " : champs interpolés :", hypo_4_3.GetFieldInterps()
+      print(".. caractéristiques de l'adaptation :", hypo_4_3.GetField())
+    print(hyponame_3, " : champs interpolés :", hypo_4_3.GetFieldInterps())
   #
   # Creation of the cases
   # =====================
     # Creation of the case
-    print "-------- Creation of the case", TEST_NAME
+    print("-------- Creation of the case", TEST_NAME)
     mesh_file = os.path.join(DIRCASE, 'maill.00.med')
     case_test_4 = HOMARD.CreateCase(TEST_NAME, 'MESH', mesh_file)
     case_test_4.SetDirName(DIRCASE)
@@ -264,10 +264,10 @@ Python script for HOMARD
   # ==========================
   # Creation of the iteration 1
     iter_name = "I_" + TEST_NAME + "_1"
-    print "-------- Creation of the iteration", iter_name
+    print("-------- Creation of the iteration", iter_name)
     iter_test_4_1 = case_test_4.NextIteration(iter_name)
     iter_test_4_1.AssociateHypo(hyponame_1)
-    print ". Hypothese :", hyponame_1
+    print(". Hypothese :", hyponame_1)
     iter_test_4_1.SetMeshName('M1')
     iter_test_4_1.SetMeshFile(os.path.join(DIRCASE, 'maill.01.med'))
     error = iter_test_4_1.Compute(1, 2)
@@ -277,10 +277,10 @@ Python script for HOMARD
 
   # Creation of the iteration 2
     iter_name = "I_" + TEST_NAME + "_2"
-    print "-------- Creation of the iteration", iter_name
+    print("-------- Creation of the iteration", iter_name)
     iter_test_4_2 = iter_test_4_1.NextIteration(iter_name)
     iter_test_4_2.AssociateHypo(hyponame_2)
-    print ". Hypothese :", hyponame_2
+    print(". Hypothese :", hyponame_2)
     iter_test_4_2.SetMeshName('M2')
     iter_test_4_2.SetMeshFile(os.path.join(DIRCASE, 'maill.02.med'))
     error = iter_test_4_2.Compute(1, 2)
@@ -296,10 +296,10 @@ Python script for HOMARD
       break
   #
     iter_name = "I_" + TEST_NAME + "_3"
-    print "-------- Creation of the iteration", iter_name
+    print("-------- Creation of the iteration", iter_name)
     iter_test_4_3 = iter_test_4_2.NextIteration(iter_name)
     iter_test_4_3.AssociateHypo(hyponame_3)
-    print ". Hypothese :", hyponame_3
+    print(". Hypothese :", hyponame_3)
     iter_test_4_3.SetMeshName('M3')
     iter_test_4_3.SetFieldFile(os.path.join(DIRCASE, 'maill.02.med'))
     iter_test_4_3.SetMeshFile(os.path.join(DIRCASE, 'maill.03.med'))
@@ -320,8 +320,8 @@ try :
   ERROR = geom_smesh_exec()
   if ERROR :
     raise Exception('Pb in geom_smesh_exec')
-except Exception, eee:
-  raise Exception('Pb in geom_smesh_exec: '+eee.message)
+except Exception as eee:
+  raise Exception('Pb in geom_smesh_exec: ' + str(eee))
 
 HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
 assert HOMARD is not None, "Impossible to load homard engine"
@@ -333,8 +333,8 @@ try :
   ERROR = homard_exec()
   if ERROR :
     raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
-  raise Exception('Pb in homard_exec: '+eee.message)
+except Exception as eee:
+  raise Exception('Pb in homard_exec: ' + str(eee))
 #
 # Test of the results
 #
index afcb13e11003f9eba361f8b17ee5fe17c06ac8b5..38ed4b017cab959f1354f0040a4a113e0f788f94 100755 (executable)
@@ -167,9 +167,9 @@ Python script for MED
       ficmed = os.path.join(DIRCASE, 'maill.00.med')
       #print "Ecriture du maillage dans le fichier", ficmed
       meshMEDFile3D.write(ficmed, 2)
-    except Exception, eee:
+    except Exception as eee:
       error = 2
-      raise Exception('ExportToMEDX() failed. '+eee.message)
+      raise Exception('ExportToMEDX() failed. ' + str(eee))
   #
     break
   #
@@ -214,7 +214,7 @@ Python script for MEDCoupling
       valeur[num_mail] = 1.e0 / max ( 1.e-5, distance)
     #print ". valeur", valeur
     nparr = valeur.toNumPyArray()
-    print ". mini/maxi", nparr.min(), nparr.max()
+    print(". mini/maxi", nparr.min(), nparr.max())
   #
   # Creation of the field
   # =====================
@@ -246,19 +246,19 @@ Python script for HOMARD
   # Creation of the hypothese DISTANCE INVERSE
   # ==========================================
     hyponame = "DISTANCE INVERSE"
-    print "-------- Creation of the hypothesis", hyponame
+    print("-------- Creation of the hypothesis", hyponame)
     hypo_5 = HOMARD.CreateHypothesis(hyponame)
     hypo_5.SetField('DISTANCE')
     hypo_5.SetUseComp(0)
     hypo_5.SetRefinThr(1, 0.020)
     hypo_5.SetUnRefThr(1, 0.015)
-    print hyponame, " : champ utilisé :", hypo_5.GetFieldName()
-    print ".. caractéristiques de l'adaptation :", hypo_5.GetField()
+    print(hyponame, " : champ utilisé :", hypo_5.GetFieldName())
+    print(".. caractéristiques de l'adaptation :", hypo_5.GetField())
   #
   # Creation of the cases
   # =====================
     # Creation of the case
-    print "-------- Creation of the case", TEST_NAME
+    print("-------- Creation of the case", TEST_NAME)
     mesh_file = os.path.join(DIRCASE, 'maill.00.med')
     case_test_5 = HOMARD.CreateCase(TEST_NAME, 'MESH', mesh_file)
     case_test_5.SetDirName(DIRCASE)
@@ -282,7 +282,7 @@ Python script for HOMARD
     # Creation of the iteration
     #
       iter_name = "I_" + TEST_NAME + "_" + s_niterp1
-      print "-------- Creation of the iteration", iter_name
+      print("-------- Creation of the iteration", iter_name)
       if ( niter == 0 ) :
         iter_test_5 = case_test_5.NextIteration(iter_name)
       else :
@@ -308,8 +308,8 @@ try :
   ERROR = mesh_exec()
   if ERROR :
     raise Exception('Pb in mesh_exec')
-except Exception, eee:
-  raise Exception('Pb in mesh_exec: '+eee.message)
+except Exception as eee:
+  raise Exception('Pb in mesh_exec: ' + str(eee))
 
 HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
 assert HOMARD is not None, "Impossible to load homard engine"
@@ -321,8 +321,8 @@ try :
   ERROR = homard_exec()
   if ERROR :
     raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
-  raise Exception('Pb in homard_exec: '+eee.message)
+except Exception as eee:
+  raise Exception('Pb in homard_exec: ' + str(eee))
 #
 # Test of the results
 #
index 5b49365cbdab24be4cd52602114bf03c8e85c9b6..06566b9b9d9d3f845432c6bb94c1e32da5b2d674 100755 (executable)
@@ -123,7 +123,7 @@ try :
   ERROR = homard_exec()
   if ERROR :
     raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
+except Exception as eee:
   raise Exception('Pb in homard_exec: '+eee.message)
 #
 # Test of the results
index 6c486104d4e608131ba081c4238aff9f17a28890..58c456dcd50b8f8e613ae7ad9dba3ecfaf5095e9 100755 (executable)
@@ -134,7 +134,7 @@ try :
   ERROR = homard_exec()
   if ERROR :
     raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
+except Exception as eee:
   raise Exception('Pb in homard_exec: '+eee.message)
 #
 # Test of the results
index 337dd83d5504bc57797ee7b193f082f84d48fc2c..d982d9b4a1081da893ca585ce6799b2d9dbdbf76 100755 (executable)
@@ -163,7 +163,7 @@ try :
   ERROR = homard_exec()
   if ERROR :
     raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
+except Exception as eee:
   raise Exception('Pb in homard_exec: '+eee.message)
 #
 # Test of the results
index 12cddf95aca252f89c5f9d5f54f90da5830e1168..8d22a0ea75c58b2fc02ce342276deb0146ad3925 100755 (executable)
@@ -150,7 +150,7 @@ try :
   ERROR = homard_exec()
   if ERROR :
     raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
+except Exception as eee:
   raise Exception('Pb in homard_exec: '+eee.message)
 #
 # Test of the results
index d5ffc6949c5b15d02fb8aca60140d538bbfa6d87..784b9a41f31cb49d44020aee07cd69e5d6d35742 100755 (executable)
@@ -134,7 +134,7 @@ try :
   ERROR = homard_exec()
   if ERROR :
     raise Exception('Pb in homard_exec at iteration %d' %ERROR )
-except Exception, eee:
+except Exception as eee:
   raise Exception('Pb in homard_exec: '+eee.message)
 #
 # Test of the results