Salome HOME
Porting to Python 3
authorGilles DAVID <gilles-g.david@edf.fr>
Fri, 24 Mar 2017 13:58:25 +0000 (14:58 +0100)
committerGilles DAVID <gilles-g.david@edf.fr>
Fri, 24 Mar 2017 13:58:25 +0000 (14:58 +0100)
15 files changed:
bin/runHOMARD.py
doc/files/tutorial_util.py
doc/files/yacs_script.py
doc/files/yacs_script_test.py
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 1a2c4d9988fcaf003eacfff33827682a6f5b4531..59390ec68637d1e66ac2d9a71365077647d134d6 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 préalablement
- positionnée (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'arrêt 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)
 
 # -----------------------------------------------------------------------------
 #
-# Vérification 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 exploitée 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
 
 
 # -----------------------------------------------------------------------------
 #
-# Définition 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("/myStudyManager")
 
@@ -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 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 2bb3ca2666e754c0c1ce38f91964e173d03bed95..d2a6e28fbac16de312ece89ce84ca558586185a3 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(salome.myStudy)
   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 fd92d1f8b7f06daa27110f276829a411e2c01d87..9e0c6dbe41c2bb3b5d747db0fb9f4e5feefce4fb 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(salome.myStudy)
   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 ddaa7a16b5459767ce21e0accf19ffe839a6b759..5c8e4bb00b2bc5b11606f6405bb5e30c7318c08f 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(salome.myStudy)
   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 e4facd3df597330535f5a2fabdcf4bc6e1cae424..90a0d280af684a12f29cf19274f31634c87e6e8c 100755 (executable)
@@ -128,7 +128,7 @@ 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)
   #
@@ -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,7 +213,7 @@ 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)
@@ -221,11 +221,11 @@ Python script for HOMARD
     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)
@@ -233,11 +233,11 @@ Python script for HOMARD
     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,7 +320,7 @@ try :
   ERROR = geom_smesh_exec(salome.myStudy)
   if ERROR :
     raise Exception('Pb in geom_smesh_exec')
-except Exception, eee:
+except Exception as eee:
   raise Exception('Pb in geom_smesh_exec: '+eee.message)
 
 HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
@@ -333,7 +333,7 @@ try :
   ERROR = homard_exec(salome.myStudy)
   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 07aa93f30da1a45702e5a72544a577c42a0bded4..27a0f89f8ba7a2b1a046aa96db854b0b56b7c070 100755 (executable)
@@ -167,7 +167,7 @@ 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)
   #
@@ -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,7 +308,7 @@ try :
   ERROR = mesh_exec(salome.myStudy)
   if ERROR :
     raise Exception('Pb in mesh_exec')
-except Exception, eee:
+except Exception as eee:
   raise Exception('Pb in mesh_exec: '+eee.message)
 
 HOMARD = salome.lcc.FindOrLoadComponent('FactoryServer', 'HOMARD')
@@ -321,7 +321,7 @@ try :
   ERROR = homard_exec(salome.myStudy)
   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 201490bfbafad641db509902d019c24e21cd2b96..5aceb08f19edc3e9df5884ca057db46226ba5999 100755 (executable)
@@ -123,7 +123,7 @@ try :
   ERROR = homard_exec(salome.myStudy)
   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 ee9802de4205a26e2b4ce71d6698f5ec322b15f6..ef643aa6ba011d430e9c477343126ca14c7d75c9 100755 (executable)
@@ -134,7 +134,7 @@ try :
   ERROR = homard_exec(salome.myStudy)
   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 8a043061f7c21190edcb476c877051c8898255de..edf7196016c6a18cc0e9121471dd72cdd0f055dc 100755 (executable)
@@ -163,7 +163,7 @@ try :
   ERROR = homard_exec(salome.myStudy)
   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 676b2876cfc648fb15eda9f3b9964cb55fa89ea7..55b8c8dc7a17aeaf04f550d4056dd11ba597e441 100755 (executable)
@@ -150,7 +150,7 @@ try :
   ERROR = homard_exec(salome.myStudy)
   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 c79201f0422dcf4475959fda3a65f8927032c8cd..a03fccb0da15cc3a4ac8b37da110736b4925c7a7 100755 (executable)
@@ -134,7 +134,7 @@ try :
   ERROR = homard_exec(salome.myStudy)
   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