From 4646393f6cca6e3d29aec0bd5dc7778c7da5ee97 Mon Sep 17 00:00:00 2001 From: Gilles DAVID Date: Wed, 24 May 2017 11:54:21 +0200 Subject: [PATCH] Porting Python 3 --- bin/smesh_setenv.py | 3 +- doc/salome/examples/testme.py | 2 +- doc/salome/gui/SMESH/collect_mesh_methods.py | 54 ++++--- src/Tools/Verima/Base/dataBase.py | 28 ++-- src/Tools/Verima/Base/exportToCSV.py | 16 +- src/Tools/Verima/Base/importFromCSV.py | 32 ++-- src/Tools/Verima/Base/tableDeBase.py | 4 +- src/Tools/Verima/Base/tableGroupeRatios.py | 4 +- src/Tools/Verima/Base/tableGroupeTailles.py | 4 +- src/Tools/Verima/Base/tableGroupes.py | 8 +- src/Tools/Verima/Base/tableGroupesRef.py | 4 +- src/Tools/Verima/Base/tableMachines.py | 6 +- src/Tools/Verima/Base/tableMaillages.py | 18 +-- src/Tools/Verima/Base/tableMailles.py | 6 +- src/Tools/Verima/Base/tableMailleurs.py | 8 +- src/Tools/Verima/Base/tablePerfs.py | 6 +- src/Tools/Verima/Base/tableRatios.py | 4 +- src/Tools/Verima/Base/tableTailles.py | 4 +- src/Tools/Verima/Base/tableVersions.py | 4 +- src/Tools/Verima/Base/versions.py | 7 +- src/Tools/Verima/CreeDocuments/jobHtml.py | 44 +++--- src/Tools/Verima/Gui/desFenetreChoix.py | 140 ++++++++---------- src/Tools/Verima/Gui/maFenetreChoix.py | 2 +- src/Tools/Verima/Gui/monEditor.py | 4 +- src/Tools/Verima/Gui/visualiseDatabase.py | 14 +- src/Tools/Verima/Stats/getCritere.py | 3 +- src/Tools/Verima/Stats/job.py | 2 +- src/Tools/Verima/ajoutEnreg.py | 25 ++-- src/Tools/Verima/compareVersions.py | 28 ++-- src/Tools/Verima/createDatabase.py | 12 +- src/Tools/Verima/lance.py | 2 +- src/Tools/Verima/passeJobs.py | 38 ++--- src/Tools/ZCracksPlug/zcracksLaunch.py | 3 +- .../resources/testdata/buildparticules.py | 8 +- 34 files changed, 259 insertions(+), 288 deletions(-) diff --git a/bin/smesh_setenv.py b/bin/smesh_setenv.py index 443ac5571..a2af9d716 100644 --- a/bin/smesh_setenv.py +++ b/bin/smesh_setenv.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: iso-8859-1 -*- +#!/usr/bin/env python3 # Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or diff --git a/doc/salome/examples/testme.py b/doc/salome/examples/testme.py index 6a502d00d..5deb4c7bc 100755 --- a/doc/salome/examples/testme.py +++ b/doc/salome/examples/testme.py @@ -1,3 +1,4 @@ +#!/usr/bin/env python3 # Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or @@ -17,7 +18,6 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -#!/usr/bin/env python import unittest, sys, os diff --git a/doc/salome/gui/SMESH/collect_mesh_methods.py b/doc/salome/gui/SMESH/collect_mesh_methods.py index da53d4ee6..542c5d7fd 100755 --- a/doc/salome/gui/SMESH/collect_mesh_methods.py +++ b/doc/salome/gui/SMESH/collect_mesh_methods.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: iso-8859-1 -*- +#!/usr/bin/env python3 # Copyright (C) 2012-2016 CEA/DEN, EDF R&D, OPEN CASCADE # # This library is free software; you can redistribute it and/or @@ -53,9 +52,9 @@ def main(plugin_name, dummymeshhelp = True, output_file = "smeshBuilder.py"): plugin_module_name = plugin_name + "Builder" plugin_module = "salome.%s.%s" % (plugin_name, plugin_module_name) try: - exec( "from salome.smesh.smeshBuilder import *") - exec( "import %s" % plugin_module ) - exec( "mod = %s" % plugin_module ) + exec("from salome.smesh.smeshBuilder import *", globals()) + exec("import %s" % plugin_module, globals()) + exec("mod = %s" % plugin_module , globals()) methods = {} for attr in dir( mod ): if attr.startswith( '_' ): continue @@ -99,22 +98,21 @@ def main(plugin_name, dummymeshhelp = True, output_file = "smeshBuilder.py"): if docHelper: break pass if not docHelper: docHelper = "Creates new algorithm." - output.append( " ## %s" % docHelper ) - output.append( " #" ) - output.append( " # This method is dynamically added to %Mesh class by the meshing plug-in(s). " ) - output.append( " #" ) - output.append( " # If the optional @a geom_shape parameter is not set, this algorithm is global (applied to whole mesh)." ) - output.append( " # Otherwise, this algorithm defines a submesh based on @a geom_shape subshape." ) - output.append( " # @param algo_type type of algorithm to be created; allowed values are specified by classes implemented by plug-in (see below)" ) - output.append( " # @param geom_shape if defined, the subshape to be meshed (GEOM_Object)" ) - output.append( " # @return An instance of Mesh_Algorithm sub-class according to the specified @a algo_type, see " ) - output.append( " # %s" % ", ".join( [ "%s.%s" % ( plugin_module_name, algo.__name__ ) for algo in methods[ method ] ] ) ) - output.append( " def %s(algo_type, geom_shape=0):" % method ) - output.append( " pass" ) + output.append( " ## %s" % docHelper ) + output.append( " #" ) + output.append( " # This method is dynamically added to %Mesh class by the meshing plug-in(s). " ) + output.append( " #" ) + output.append( " # If the optional @a geom_shape parameter is not set, this algorithm is global (applied to whole mesh)." ) + output.append( " # Otherwise, this algorithm defines a submesh based on @a geom_shape subshape." ) + output.append( " # @param algo_type type of algorithm to be created; allowed values are specified by classes implemented by plug-in (see below)" ) + output.append( " # @param geom_shape if defined, the subshape to be meshed (GEOM_Object)" ) + output.append( " # @return An instance of Mesh_Algorithm sub-class according to the specified @a algo_type, see " ) + output.append( " # %s" % ", ".join( [ "%s.%s" % ( plugin_module_name, algo.__name__ ) for algo in methods[ method ] ] ) ) + output.append( " def %s(algo_type, geom_shape=0):" % method ) + output.append( " pass" ) pass - f = open(output_file, "w") - for line in output: f.write( line + "\n" ) - f.close() + with open(output_file, "w", encoding='utf8') as f: + f.write('\n'.join(output)) pass pass except Exception as e: @@ -123,20 +121,20 @@ def main(plugin_name, dummymeshhelp = True, output_file = "smeshBuilder.py"): pass if __name__ == "__main__": - import optparse - parser = optparse.OptionParser(usage="%prog [options] plugin") + import argparse + parser = argparse.ArgumentParser() h = "Output file (smesh.py by default)" - parser.add_option("-o", "--output", dest="output", - action="store", default=None, metavar="file", + parser.add_argument("-o", "--output", dest="output", + action="store", default='smesh.py', metavar="file", help=h) h = "If this option is True, dummy help for Mesh class is added. " h += "This option should be False (default) when building documentation for SMESH module " h += "and True when building documentation for meshing plug-ins." - parser.add_option("-d", "--dummy-mesh-help", dest="dummymeshhelp", + parser.add_argument("-d", "--dummy-mesh-help", dest="dummymeshhelp", action="store_true", default=False, help=h) - (options, args) = parser.parse_args() + parser.add_argument("plugin", help='Name of plugin') + args = parser.parse_args() - if len( args ) < 1: sys.exit("Plugin name is not specified") - main( args[0], options.dummymeshhelp, options.output ) + main( args.plugin, args.dummymeshhelp, args.output ) pass diff --git a/src/Tools/Verima/Base/dataBase.py b/src/Tools/Verima/Base/dataBase.py index 11dcee37e..a67caf4b3 100644 --- a/src/Tools/Verima/Base/dataBase.py +++ b/src/Tools/Verima/Base/dataBase.py @@ -1,22 +1,20 @@ -# -*- coding: utf-8 -*- - import os import datetime import sys -from qtsalome import QSqlQuery -from .tableMaillages import TableMaillages -from .tableMailleurs import TableMailleurs -from .tableMachines import TableMachines -from .tableVersions import TableVersions -from .tableGroupesRef import TableGroupesRef -from .tableGroupes import TableGroupes -from .tableMailles import TableMailles -from .tableTailles import TableTailles -from .tableRatios import TableRatios -from .tableGroupeRatios import TableGroupeRatios -from .tableGroupeTailles import TableGroupeTailles -from .tablePerfs import TablePerfs +from qtsalome import QSqlQuery, QSqlDatabase +from Base.tableMaillages import TableMaillages +from Base.tableMailleurs import TableMailleurs +from Base.tableMachines import TableMachines +from Base.tableVersions import TableVersions +from Base.tableGroupesRef import TableGroupesRef +from Base.tableGroupes import TableGroupes +from Base.tableMailles import TableMailles +from Base.tableTailles import TableTailles +from Base.tableRatios import TableRatios +from Base.tableGroupeRatios import TableGroupeRatios +from Base.tableGroupeTailles import TableGroupeTailles +from Base.tablePerfs import TablePerfs from Stats.job import Job from CreeDocuments.jobHtml import Document diff --git a/src/Tools/Verima/Base/exportToCSV.py b/src/Tools/Verima/Base/exportToCSV.py index 7737c5267..b304aeecf 100755 --- a/src/Tools/Verima/Base/exportToCSV.py +++ b/src/Tools/Verima/Base/exportToCSV.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys,os @@ -9,14 +9,14 @@ if os.path.dirname(pathRacine) not in sys.path : from .dataBase import Base if __name__ == "__main__": - from optparse import OptionParser - p=OptionParser() - p.add_option('-p',dest='partiel',action="store_true", default=False,help='export de machine, groupe, ratio Maille et Perf uniquement') - p.add_option('-d',dest='database',default="../myMesh.db",help='nom de la database') - options, args = p.parse_args() + from argparse import ArgumentParser + p=ArgumentParser() + p.add_argument('-p',dest='partiel',action="store_true", default=False,help='export de machine, groupe, ratio Maille et Perf uniquement') + p.add_argument('-d',dest='database',default="../myMesh.db",help='nom de la database') + args = p.parse_args() - maBase=Base(options.database) + maBase=Base(args.database) maBase.initialise() - maBase.exportToCSV(options.partiel) + maBase.exportToCSV(args.partiel) maBase.close() diff --git a/src/Tools/Verima/Base/importFromCSV.py b/src/Tools/Verima/Base/importFromCSV.py index 5c98544aa..099689c8f 100755 --- a/src/Tools/Verima/Base/importFromCSV.py +++ b/src/Tools/Verima/Base/importFromCSV.py @@ -1,30 +1,24 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 -import sys import os -from .dataBase import Base - +from dataBase import Base if __name__ == "__main__": - from optparse import OptionParser - p=OptionParser() - p.add_option('-p',dest='partiel',action="store_true", default=False,help='import de machine, groupe, ratio Maille et Perf uniquement') - p.add_option('-f',dest='force',action="store_true", default=False,help='ecrasement des valeurs dans la base par les valeurs dans les fichiers en cas de meme clef primaire') - p.add_option('-d',dest='database',default="myMesh.db",help='nom de la database') - options, args = p.parse_args() - if len(args) != 1 : - print("entrer SVP le nom de la directory ou sont rangees les fichiers a charger") - exit() - folder=args[0] + from argparse import ArgumentParser + p=ArgumentParser() + p.add_argument('-p',dest='partiel',action="store_true", default=False,help='import de machine, groupe, ratio Maille et Perf uniquement') + p.add_argument('-f',dest='force',action="store_true", default=False,help='ecrasement des valeurs dans la base par les valeurs dans les fichiers en cas de meme clef primaire') + p.add_argument('-d',dest='database',default="myMesh.db",help='nom de la database') + p.add_argument('folder', help='Repertoire ou sont ranges les fichiers a charger') + args = p.parse_args() - if not(os.path.isdir(folder)): - print(folder , " n existe pas") + if not(os.path.isdir(args.folder)): + print(args.folder , " n existe pas") exit() - maBase=Base(options.database) + maBase=Base(args.database) maBase.create() maBase.initialise() - maBase.importFromCSV(folder,options.partiel,options.force) + maBase.importFromCSV(args.folder,args.partiel,args.force) maBase.close() diff --git a/src/Tools/Verima/Base/tableDeBase.py b/src/Tools/Verima/Base/tableDeBase.py index 7bba47cb7..277ac2a40 100644 --- a/src/Tools/Verima/Base/tableDeBase.py +++ b/src/Tools/Verima/Base/tableDeBase.py @@ -45,7 +45,7 @@ class TableDeBase : maQuery=QSqlQuery() maQuery.exec_(texteQuery) nb=0 - while(next(maQuery)): nb=nb+1 + while(maQuery.next()): nb=nb+1 return nb @@ -70,7 +70,7 @@ class TableDeBase : maQuery=QSqlQuery() maQuery.exec_(texteQuery) asauver=0 - while(next(maQuery)): + while(maQuery.next()): asauver=1 for i in range(len(self.FieldStringList)): texteSauve+=str(maQuery.value(i).toString())+";" diff --git a/src/Tools/Verima/Base/tableGroupeRatios.py b/src/Tools/Verima/Base/tableGroupeRatios.py index c435f28ff..17bbefa11 100644 --- a/src/Tools/Verima/Base/tableGroupeRatios.py +++ b/src/Tools/Verima/Base/tableGroupeRatios.py @@ -1,5 +1,5 @@ from qtsalome import QSqlQuery -from .tableDeBase import TableDeBase +from Base.tableDeBase import TableDeBase class TableGroupeRatios (TableDeBase): def __init__(self): @@ -30,7 +30,7 @@ class TableGroupeRatios (TableDeBase): query.exec_(texteQuery) nb=0 val=0 # Valeur si l enregistrement n existe pas - while (next(query)) : + while (query.next()) : val=query.value(0).toFloat()[0] nb=nb+1 if nb > 1 : print("Double valeur de Reference dans la table des mailles") diff --git a/src/Tools/Verima/Base/tableGroupeTailles.py b/src/Tools/Verima/Base/tableGroupeTailles.py index c18dae294..d88bf2558 100644 --- a/src/Tools/Verima/Base/tableGroupeTailles.py +++ b/src/Tools/Verima/Base/tableGroupeTailles.py @@ -1,5 +1,5 @@ from qtsalome import QSqlQuery -from .tableDeBase import TableDeBase +from Base.tableDeBase import TableDeBase class TableGroupeTailles (TableDeBase): def __init__(self): @@ -31,7 +31,7 @@ class TableGroupeTailles (TableDeBase): query.exec_(texteQuery) nb=0 val=0 # Valeur si l enregistrement n existe pas - while (next(query)) : + while (query.next()) : val=query.value(0).toFloat()[0] nb=nb+1 if nb > 1 : print("Double valeur de Reference dans la table des tailles") diff --git a/src/Tools/Verima/Base/tableGroupes.py b/src/Tools/Verima/Base/tableGroupes.py index 7a78dfa05..111a2ed55 100644 --- a/src/Tools/Verima/Base/tableGroupes.py +++ b/src/Tools/Verima/Base/tableGroupes.py @@ -1,5 +1,5 @@ from qtsalome import QSqlQuery -from .tableDeBase import TableDeBase +from Base.tableDeBase import TableDeBase class TableGroupes (TableDeBase): def __init__(self): @@ -29,9 +29,9 @@ class TableGroupes (TableDeBase): texteQuery +=' and idVersion = ' + str(idVersion) texteQuery +=' and Entite ="' + str(typeMaille) + '";' query.exec_(texteQuery) - while (next(query)) : + while (query.next()) : val=query.value(0).toInt()[0] - while (next(query)) : + while (query.next()) : print("plusieurs enregistrements dans groupe pour ", nomGroupe," ",str(idMaillage)," ",str(idVersion),"\n") return val @@ -41,6 +41,6 @@ class TableGroupes (TableDeBase): texteQuery ="select distinct Entite from Groupes;" query.exec_(texteQuery) maListe=[] - while (next(query)) : + while (query.next()) : maListe.append(str(query.value(0).toString())) return maListe diff --git a/src/Tools/Verima/Base/tableGroupesRef.py b/src/Tools/Verima/Base/tableGroupesRef.py index 663f509d1..6c97a8a3b 100644 --- a/src/Tools/Verima/Base/tableGroupesRef.py +++ b/src/Tools/Verima/Base/tableGroupesRef.py @@ -1,5 +1,5 @@ from qtsalome import QSqlQuery -from .tableDeBase import TableDeBase +from Base.tableDeBase import TableDeBase class TableGroupesRef (TableDeBase): def __init__(self): @@ -19,7 +19,7 @@ class TableGroupesRef (TableDeBase): texteQuery ='select NomGroupe from GroupesRef where idMaillage='+str(idMaillage) +";" listeGroupes=[] query.exec_(texteQuery) - while (next(query)) : + while (query.next()) : listeGroupes.append(str(query.value(0).toString())) return listeGroupes diff --git a/src/Tools/Verima/Base/tableMachines.py b/src/Tools/Verima/Base/tableMachines.py index 0b149d95e..45a86a2f1 100644 --- a/src/Tools/Verima/Base/tableMachines.py +++ b/src/Tools/Verima/Base/tableMachines.py @@ -1,6 +1,6 @@ -from qtsalome import QSqlQuery -from .tableDeBase import TableDeBase import os +from qtsalome import QSqlQuery +from Base.tableDeBase import TableDeBase class TableMachines (TableDeBase): def __init__(self): @@ -23,7 +23,7 @@ class TableMachines (TableDeBase): texteQuery ="select nomMachine from Machines where nomMachine ='" + machine +"' ;" query.exec_(texteQuery) nb=0 - while(next(query)): + while(query.next()): nb=nb+1 nom=str(query.value(0).toString()) if nb != 1 : return 0, "" diff --git a/src/Tools/Verima/Base/tableMaillages.py b/src/Tools/Verima/Base/tableMaillages.py index dccad9382..fb0146ea7 100644 --- a/src/Tools/Verima/Base/tableMaillages.py +++ b/src/Tools/Verima/Base/tableMaillages.py @@ -1,5 +1,5 @@ from qtsalome import QSqlQuery -from .tableDeBase import TableDeBase +from Base.tableDeBase import TableDeBase class TableMaillages (TableDeBase): def __init__(self): @@ -21,9 +21,9 @@ class TableMaillages (TableDeBase): valeur=None texteQuery ='select '+ nomChamp + ' from Maillages where id=' + str(idMaillage) + ";" query.exec_(texteQuery) - while (next(query)) : + while (query.next()) : valeur=query.value(0).toInt()[0] - while (next(query)) : + while (query.next()) : print("plusieurs enregistrements dans Maillages pour ",str(idMaillage)) exit() return valeur @@ -33,7 +33,7 @@ class TableMaillages (TableDeBase): maQuery=QSqlQuery() maQuery.exec_(texteQuery) nb=0 - while(next(maQuery)): nb=nb+1 + while(maQuery.next()): nb=nb+1 return nb def remplit(self): @@ -48,7 +48,7 @@ class TableMaillages (TableDeBase): texteQuery="select id, nomScript,medResultat from Maillages;" maQuery.exec_(texteQuery) listeMaillages=[] - while(next(maQuery)): + while(maQuery.next()): listeMaillages.append((maQuery.value(0).toInt()[0], maQuery.value(1).toString(), maQuery.value(2).toString())) return listeMaillages @@ -59,7 +59,7 @@ class TableMaillages (TableDeBase): texteQuery="select id, nomScript,medResultat from Maillages where id = " + str(idM) +';' maQuery.exec_(texteQuery) maSize=0 - while(next(maQuery)): + while(maQuery.next()): maSize+=1 newListeMaillages.append((maQuery.value(0).toInt()[0], maQuery.value(1).toString(), maQuery.value(2).toString())) if maSize != 1 : @@ -70,7 +70,7 @@ class TableMaillages (TableDeBase): texteQuery="select id,nomMaillage,seuilCPU,seuilRatio,seuilTaille,seuilNbMaille from Maillages where id = "+ str(idMaillage) +" ;" maQuery=QSqlQuery() maQuery.exec_(texteQuery) - while(next(maQuery)): + while(maQuery.next()): l1 = maQuery.value(0).toInt()[0] l2 = maQuery.value(1).toString() l3 = maQuery.value(2).toInt()[0] @@ -84,7 +84,7 @@ class TableMaillages (TableDeBase): texteQuery="select id,nomMaillage from Maillages order by id;" maQuery=QSqlQuery() maQuery.exec_(texteQuery) - while(next(maQuery)): + while(maQuery.next()): maillagesIdListe.append( maQuery.value(0).toInt()[0]) maillagesNomListe.append( maQuery.value(1).toString()) return maillagesIdListe, maillagesNomListe @@ -95,6 +95,6 @@ class TableMaillages (TableDeBase): print(texteQuery) print(maQuery.exec_(texteQuery)) maQuery.exec_(texteQuery) - while(next(maQuery)): + while(maQuery.next()): idMailleur = maQuery.value(0).toInt()[0] return idMailleur diff --git a/src/Tools/Verima/Base/tableMailles.py b/src/Tools/Verima/Base/tableMailles.py index cd279e7a5..5576574ca 100644 --- a/src/Tools/Verima/Base/tableMailles.py +++ b/src/Tools/Verima/Base/tableMailles.py @@ -1,5 +1,5 @@ from qtsalome import QSqlQuery -from .tableDeBase import TableDeBase +from Base.tableDeBase import TableDeBase class TableMailles (TableDeBase): def __init__(self): @@ -28,7 +28,7 @@ class TableMailles (TableDeBase): query.exec_(texteQuery) nb=0 val=0 # Valeur si l enregistrement n existe pas - while (next(query)) : + while (query.next()) : val=query.value(0).toInt()[0] nb=nb+1 if nb > 1 : print("Double valeur de Reference dans la table des mailles") @@ -40,6 +40,6 @@ class TableMailles (TableDeBase): texteQuery ="select distinct Entite from Mailles;" query.exec_(texteQuery) maListe=[] - while (next(query)) : + while (query.next()) : maListe.append(str(query.value(0).toString())) return maListe diff --git a/src/Tools/Verima/Base/tableMailleurs.py b/src/Tools/Verima/Base/tableMailleurs.py index 0c727c4dd..a05f6a93e 100644 --- a/src/Tools/Verima/Base/tableMailleurs.py +++ b/src/Tools/Verima/Base/tableMailleurs.py @@ -1,5 +1,5 @@ from qtsalome import QSqlQuery -from .tableDeBase import TableDeBase +from Base.tableDeBase import TableDeBase class TableMailleurs (TableDeBase): def __init__(self): @@ -17,7 +17,7 @@ class TableMailleurs (TableDeBase): maQuery=QSqlQuery() maQuery.exec_(texteQuery) nb=0 - while(next(maQuery)): nb=nb+1 + while(maQuery.next()): nb=nb+1 return nb def remplit(self): @@ -43,7 +43,7 @@ class TableMailleurs (TableDeBase): texteQuery="select * from Mailleurs;" maQuery=QSqlQuery() maQuery.exec_(texteQuery) - while(next(maQuery)): + while(maQuery.next()): l1.append( maQuery.value(0).toInt()[0]) l2.append( maQuery.value(1).toString()) return l1,l2 @@ -52,6 +52,6 @@ class TableMailleurs (TableDeBase): texteQuery="select nomMailleur from Mailleurs where id = " + str(mailleurId) + " ;" maQuery=QSqlQuery() maQuery.exec_(texteQuery) - while(next(maQuery)): + while(maQuery.next()): mailleurName=maQuery.value(0).toString() return mailleurName diff --git a/src/Tools/Verima/Base/tablePerfs.py b/src/Tools/Verima/Base/tablePerfs.py index 15751cfc2..aa0c331d2 100644 --- a/src/Tools/Verima/Base/tablePerfs.py +++ b/src/Tools/Verima/Base/tablePerfs.py @@ -1,5 +1,5 @@ from qtsalome import QSqlQuery -from .tableDeBase import TableDeBase +from Base.tableDeBase import TableDeBase class TablePerfs (TableDeBase): def __init__(self): @@ -24,9 +24,9 @@ class TablePerfs (TableDeBase): texteQuery +=" and Machine ='" + Machine + "';" query.exec_(texteQuery) cpu=None - while (next(query)) : + while (query.next()) : cpu=query.value(0).toInt()[0] - while (next(query)) : + while (query.next()) : print("plusieurs enregistrements dans perf pour ",str(idMaillage)," ",str(idVersion)," ",Machine) if cpu==None : print("pas d enregistrement dans perf pour ",str(idMaillage)," ",str(idVersion)," ",Machine) diff --git a/src/Tools/Verima/Base/tableRatios.py b/src/Tools/Verima/Base/tableRatios.py index 1fdf274e8..c2e87d76a 100644 --- a/src/Tools/Verima/Base/tableRatios.py +++ b/src/Tools/Verima/Base/tableRatios.py @@ -1,5 +1,5 @@ from qtsalome import QSqlQuery -from .tableDeBase import TableDeBase +from Base.tableDeBase import TableDeBase class TableRatios (TableDeBase): def __init__(self): @@ -29,7 +29,7 @@ class TableRatios (TableDeBase): query.exec_(texteQuery) nb=0 val=0 # Valeur si l enregistrement n existe pas - while (next(query)) : + while (query.next()) : val=query.value(0).toFloat()[0] nb=nb+1 if nb > 1 : print("Double valeur de Reference dans la table des mailles") diff --git a/src/Tools/Verima/Base/tableTailles.py b/src/Tools/Verima/Base/tableTailles.py index 43e39fee5..a2e42cb33 100644 --- a/src/Tools/Verima/Base/tableTailles.py +++ b/src/Tools/Verima/Base/tableTailles.py @@ -1,5 +1,5 @@ from qtsalome import QSqlQuery -from .tableDeBase import TableDeBase +from Base.tableDeBase import TableDeBase class TableTailles (TableDeBase): def __init__(self): @@ -29,7 +29,7 @@ class TableTailles (TableDeBase): query.exec_(texteQuery) nb=0 val=0 # Valeur si l enregistrement n existe pas - while (next(query)) : + while (query.next()) : val=query.value(0).toFloat()[0] nb=nb+1 if nb > 1 : print("Double valeur de Reference dans la table des mailles") diff --git a/src/Tools/Verima/Base/tableVersions.py b/src/Tools/Verima/Base/tableVersions.py index afe900e32..797d147ff 100644 --- a/src/Tools/Verima/Base/tableVersions.py +++ b/src/Tools/Verima/Base/tableVersions.py @@ -1,5 +1,5 @@ from qtsalome import QSqlQuery -from .tableDeBase import TableDeBase +from Base.tableDeBase import TableDeBase class TableVersions (TableDeBase): def __init__(self): @@ -33,7 +33,7 @@ class TableVersions (TableDeBase): texteQuery ="select id, nomVersion from Versions where nomVersion ='" + version +"' ;" query.exec_(texteQuery) nb=0 - while(next(query)): + while(query.next()): nb=nb+1 id=query.value(0).toInt()[0] nom=query.value(1).toString() diff --git a/src/Tools/Verima/Base/versions.py b/src/Tools/Verima/Base/versions.py index 55cea45a1..68c748992 100755 --- a/src/Tools/Verima/Base/versions.py +++ b/src/Tools/Verima/Base/versions.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 import sys import os @@ -8,11 +7,11 @@ import subprocess def Chercheversion(salomePath): home=os.environ['HOME'] - commande=os.path.abspath(os.path.join(home,salomePath,'runAppli')) + commande=os.path.abspath(os.path.join(home,salomePath,'salome')) argus="--version" p = subprocess.Popen([commande,argus], stdout=subprocess.PIPE) (output, err) = p.communicate() - version=' '.join(output.split()) + version=' '.join(output.decode().split()) return version diff --git a/src/Tools/Verima/CreeDocuments/jobHtml.py b/src/Tools/Verima/CreeDocuments/jobHtml.py index 634827bf7..b64f63d4d 100755 --- a/src/Tools/Verima/CreeDocuments/jobHtml.py +++ b/src/Tools/Verima/CreeDocuments/jobHtml.py @@ -1,19 +1,18 @@ -#!/usr/bin/env python -# -*- coding: iso-8859-1 -*- +#!/usr/bin/env python3 import string import os -dir=os.path.dirname(os.path.abspath(__file__)) -FichierEntete=os.path.join(dir,'templatesHtml/entete.html') -FichierMaillageEntete=os.path.join(dir,'templatesHtml/maillageEntete.html') -FichierJob=os.path.join(dir,'templatesHtml/job.html') -FichierTableau=os.path.join(dir,'templatesHtml/tableau.html') -FichierLigne=os.path.join(dir,'templatesHtml/ligne.html') -FichierFinTableau=os.path.join(dir,'templatesHtml/tableauFin.html') -FichierSansGroupe=os.path.join(dir,'templatesHtml/sansGroupe.html') -FichierGroupeRatio=os.path.join(dir,'templatesHtml/groupeRatio.html') -FichierGroupeTaille=os.path.join(dir,'templatesHtml/groupeTaille.html') +adir=os.path.dirname(os.path.abspath(__file__)) +FichierEntete=os.path.join(adir,'templatesHtml/entete.html') +FichierMaillageEntete=os.path.join(adir,'templatesHtml/maillageEntete.html') +FichierJob=os.path.join(adir,'templatesHtml/job.html') +FichierTableau=os.path.join(adir,'templatesHtml/tableau.html') +FichierLigne=os.path.join(adir,'templatesHtml/ligne.html') +FichierFinTableau=os.path.join(adir,'templatesHtml/tableauFin.html') +FichierSansGroupe=os.path.join(adir,'templatesHtml/sansGroupe.html') +FichierGroupeRatio=os.path.join(adir,'templatesHtml/groupeRatio.html') +FichierGroupeTaille=os.path.join(adir,'templatesHtml/groupeTaille.html') def compte_all(texte, subString): @@ -26,7 +25,7 @@ def compte_all(texte, subString): start = trouve + len(subString) def FormateTexte(texte,dico): - for clef in list(dico.keys()): + for clef in dico: texteARemplacer="%"+str(clef)+"%" remplacement=dico[clef] if texte.find(texteARemplacer) < 0 : @@ -47,33 +46,33 @@ def FormateLigne(texte,nb): return texte def CreeEntete(dico): - texteIni=open(FichierEntete).read() + texteIni=open(FichierEntete, 'r', encoding='utf8').read() texteRetour=FormateTexte(texteIni,dico) return texteRetour def CreeMaillage(dico): - texteIni=open(FichierMaillageEntete).read() + texteIni=open(FichierMaillageEntete, 'r', encoding='utf8').read() texteRetour=FormateTexte(texteIni,dico) return texteRetour def CreeJob(dico): - texte=open(FichierJob).read() + texte=open(FichierJob, 'r', encoding='utf8').read() texteRetour=FormateTexte(texte,dico) return texteRetour def CreeGroupeTaille(dico): - texte=open(FichierGroupeTaille).read() + texte=open(FichierGroupeTaille, 'r', encoding='utf8').read() texteRetour=FormateTexte(texte,dico) return texteRetour def CreeGroupeRatio(dico): - texte=open(FichierGroupeRatio).read() + texte=open(FichierGroupeRatio, 'r', encoding='utf8').read() texteRetour=FormateTexte(texte,dico) return texteRetour def CreeMailleOuGroupe(dico,nb): - texteIni=open(FichierTableau).read() + texteIni=open(FichierTableau, 'r', encoding='utf8').read() texteLigneIni=open(FichierLigne).read() for i in range (2,nb+1) : texteLigne=FormateLigne(texteLigneIni,i) @@ -81,16 +80,15 @@ def CreeMailleOuGroupe(dico,nb): texteRetour=FormateTexte(texteIni,dico) - finTexte=open(FichierFinTableau).read() + finTexte=open(FichierFinTableau, 'r', encoding='utf8').read() texteFinal=texteRetour+finTexte return texteFinal def EcritFichier(texte,filename): - fp=open(filename,'w') - fp.write(texte) - fp.close() + with open(filename,'w',encoding='utf8') as fp: + fp.write(texte) class Document: diff --git a/src/Tools/Verima/Gui/desFenetreChoix.py b/src/Tools/Verima/Gui/desFenetreChoix.py index af7dc9118..33d4fe204 100644 --- a/src/Tools/Verima/Gui/desFenetreChoix.py +++ b/src/Tools/Verima/Gui/desFenetreChoix.py @@ -2,116 +2,102 @@ # Form implementation generated from reading ui file 'desFenetreChoix.ui' # -# Created: Thu Mar 27 11:25:15 2014 -# by: PyQt4 UI code generator 4.9.6 +# Created by: PyQt5 UI code generator 5.6 # # WARNING! All changes made in this file will be lost! -from PyQt4 import QtCore, QtGui - -try: - _fromUtf8 = QtCore.QString.fromUtf8 -except AttributeError: - def _fromUtf8(s): - return s - -try: - _encoding = QtGui.QApplication.UnicodeUTF8 - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig, _encoding) -except AttributeError: - def _translate(context, text, disambig): - return QtGui.QApplication.translate(context, text, disambig) +from PyQt5 import QtCore, QtGui, QtWidgets class Ui_Choix(object): def setupUi(self, Choix): - Choix.setObjectName(_fromUtf8("Choix")) + Choix.setObjectName("Choix") Choix.resize(440, 708) - self.gridLayout = QtGui.QGridLayout(Choix) - self.gridLayout.setObjectName(_fromUtf8("gridLayout")) - self.buttonBox = QtGui.QDialogButtonBox(Choix) + self.gridLayout = QtWidgets.QGridLayout(Choix) + self.gridLayout.setObjectName("gridLayout") + self.buttonBox = QtWidgets.QDialogButtonBox(Choix) self.buttonBox.setOrientation(QtCore.Qt.Horizontal) - self.buttonBox.setStandardButtons(QtGui.QDialogButtonBox.Cancel|QtGui.QDialogButtonBox.Ok) - self.buttonBox.setObjectName(_fromUtf8("buttonBox")) + self.buttonBox.setStandardButtons(QtWidgets.QDialogButtonBox.Cancel|QtWidgets.QDialogButtonBox.Ok) + self.buttonBox.setObjectName("buttonBox") self.gridLayout.addWidget(self.buttonBox, 2, 0, 1, 1) - self.groupBox = QtGui.QGroupBox(Choix) - self.groupBox.setObjectName(_fromUtf8("groupBox")) - self.layoutWidget = QtGui.QWidget(self.groupBox) + self.groupBox = QtWidgets.QGroupBox(Choix) + self.groupBox.setObjectName("groupBox") + self.layoutWidget = QtWidgets.QWidget(self.groupBox) self.layoutWidget.setGeometry(QtCore.QRect(40, 310, 311, 269)) - self.layoutWidget.setObjectName(_fromUtf8("layoutWidget")) - self.gridLayout_2 = QtGui.QGridLayout(self.layoutWidget) - self.gridLayout_2.setMargin(0) - self.gridLayout_2.setObjectName(_fromUtf8("gridLayout_2")) - self.PBMaille = QtGui.QPushButton(self.layoutWidget) - self.PBMaille.setObjectName(_fromUtf8("PBMaille")) + self.layoutWidget.setObjectName("layoutWidget") + self.gridLayout_2 = QtWidgets.QGridLayout(self.layoutWidget) + self.gridLayout_2.setContentsMargins(0, 0, 0, 0) + self.gridLayout_2.setObjectName("gridLayout_2") + self.PBMaille = QtWidgets.QPushButton(self.layoutWidget) + self.PBMaille.setObjectName("PBMaille") self.gridLayout_2.addWidget(self.PBMaille, 1, 0, 1, 1) - self.PBRatio = QtGui.QPushButton(self.layoutWidget) - self.PBRatio.setObjectName(_fromUtf8("PBRatio")) + self.PBRatio = QtWidgets.QPushButton(self.layoutWidget) + self.PBRatio.setObjectName("PBRatio") self.gridLayout_2.addWidget(self.PBRatio, 3, 0, 1, 1) - self.PBPerf = QtGui.QPushButton(self.layoutWidget) - self.PBPerf.setObjectName(_fromUtf8("PBPerf")) + self.PBPerf = QtWidgets.QPushButton(self.layoutWidget) + self.PBPerf.setObjectName("PBPerf") self.gridLayout_2.addWidget(self.PBPerf, 7, 0, 1, 1) - self.PBGroupeRatio = QtGui.QPushButton(self.layoutWidget) - self.PBGroupeRatio.setObjectName(_fromUtf8("PBGroupeRatio")) + self.PBGroupeRatio = QtWidgets.QPushButton(self.layoutWidget) + self.PBGroupeRatio.setObjectName("PBGroupeRatio") self.gridLayout_2.addWidget(self.PBGroupeRatio, 6, 0, 1, 1) - self.PBGroupe = QtGui.QPushButton(self.layoutWidget) - self.PBGroupe.setObjectName(_fromUtf8("PBGroupe")) + self.PBGroupe = QtWidgets.QPushButton(self.layoutWidget) + self.PBGroupe.setObjectName("PBGroupe") self.gridLayout_2.addWidget(self.PBGroupe, 4, 0, 1, 1) - self.PBTaille = QtGui.QPushButton(self.layoutWidget) - self.PBTaille.setObjectName(_fromUtf8("PBTaille")) + self.PBTaille = QtWidgets.QPushButton(self.layoutWidget) + self.PBTaille.setObjectName("PBTaille") self.gridLayout_2.addWidget(self.PBTaille, 2, 0, 1, 1) - self.PBGroupeTaille = QtGui.QPushButton(self.layoutWidget) - self.PBGroupeTaille.setObjectName(_fromUtf8("PBGroupeTaille")) + self.PBGroupeTaille = QtWidgets.QPushButton(self.layoutWidget) + self.PBGroupeTaille.setObjectName("PBGroupeTaille") self.gridLayout_2.addWidget(self.PBGroupeTaille, 5, 0, 1, 1) - self.layoutWidget1 = QtGui.QWidget(self.groupBox) + self.layoutWidget1 = QtWidgets.QWidget(self.groupBox) self.layoutWidget1.setGeometry(QtCore.QRect(40, 50, 301, 211)) - self.layoutWidget1.setObjectName(_fromUtf8("layoutWidget1")) - self.verticalLayout = QtGui.QVBoxLayout(self.layoutWidget1) - self.verticalLayout.setMargin(0) - self.verticalLayout.setObjectName(_fromUtf8("verticalLayout")) - self.PBMailleur = QtGui.QPushButton(self.layoutWidget1) - self.PBMailleur.setObjectName(_fromUtf8("PBMailleur")) + self.layoutWidget1.setObjectName("layoutWidget1") + self.verticalLayout = QtWidgets.QVBoxLayout(self.layoutWidget1) + self.verticalLayout.setContentsMargins(0, 0, 0, 0) + self.verticalLayout.setObjectName("verticalLayout") + self.PBMailleur = QtWidgets.QPushButton(self.layoutWidget1) + self.PBMailleur.setObjectName("PBMailleur") self.verticalLayout.addWidget(self.PBMailleur) - self.PBMaillage = QtGui.QPushButton(self.layoutWidget1) - self.PBMaillage.setObjectName(_fromUtf8("PBMaillage")) + self.PBMaillage = QtWidgets.QPushButton(self.layoutWidget1) + self.PBMaillage.setObjectName("PBMaillage") self.verticalLayout.addWidget(self.PBMaillage) - self.PBMachine = QtGui.QPushButton(self.layoutWidget1) - self.PBMachine.setObjectName(_fromUtf8("PBMachine")) + self.PBMachine = QtWidgets.QPushButton(self.layoutWidget1) + self.PBMachine.setObjectName("PBMachine") self.verticalLayout.addWidget(self.PBMachine) - self.PBVersion = QtGui.QPushButton(self.layoutWidget1) - self.PBVersion.setObjectName(_fromUtf8("PBVersion")) + self.PBVersion = QtWidgets.QPushButton(self.layoutWidget1) + self.PBVersion.setObjectName("PBVersion") self.verticalLayout.addWidget(self.PBVersion) - self.PBGroupesRef = QtGui.QPushButton(self.layoutWidget1) - self.PBGroupesRef.setObjectName(_fromUtf8("PBGroupesRef")) + self.PBGroupesRef = QtWidgets.QPushButton(self.layoutWidget1) + self.PBGroupesRef.setObjectName("PBGroupesRef") self.verticalLayout.addWidget(self.PBGroupesRef) self.gridLayout.addWidget(self.groupBox, 1, 0, 1, 1) self.retranslateUi(Choix) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("accepted()")), Choix.accept) - QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL(_fromUtf8("rejected()")), Choix.reject) + self.buttonBox.accepted.connect(Choix.accept) + self.buttonBox.rejected.connect(Choix.reject) QtCore.QMetaObject.connectSlotsByName(Choix) def retranslateUi(self, Choix): - Choix.setWindowTitle(_translate("Choix", "Verification de Maillage", None)) - self.groupBox.setTitle(_translate("Choix", "Tables ", None)) - self.PBMaille.setText(_translate("Choix", "Table Mailles", None)) - self.PBRatio.setText(_translate("Choix", "Table Ratios", None)) - self.PBPerf.setText(_translate("Choix", "Table Performances", None)) - self.PBGroupeRatio.setText(_translate("Choix", "Table Groupe Ratios", None)) - self.PBGroupe.setText(_translate("Choix", "Table Groupes", None)) - self.PBTaille.setText(_translate("Choix", "Table Tailles", None)) - self.PBGroupeTaille.setText(_translate("Choix", "Table Groupe Tailles", None)) - self.PBMailleur.setText(_translate("Choix", "Table Mailleurs", None)) - self.PBMaillage.setText(_translate("Choix", "Table Maillages", None)) - self.PBMachine.setText(_translate("Choix", "Table Machines", None)) - self.PBVersion.setText(_translate("Choix", "Table Versions", None)) - self.PBGroupesRef.setText(_translate("Choix", "Table Groupes Référence", None)) + _translate = QtCore.QCoreApplication.translate + Choix.setWindowTitle(_translate("Choix", "Verification de Maillage")) + self.groupBox.setTitle(_translate("Choix", "Tables ")) + self.PBMaille.setText(_translate("Choix", "Table Mailles")) + self.PBRatio.setText(_translate("Choix", "Table Ratios")) + self.PBPerf.setText(_translate("Choix", "Table Performances")) + self.PBGroupeRatio.setText(_translate("Choix", "Table Groupe Ratios")) + self.PBGroupe.setText(_translate("Choix", "Table Groupes")) + self.PBTaille.setText(_translate("Choix", "Table Tailles")) + self.PBGroupeTaille.setText(_translate("Choix", "Table Groupe Tailles")) + self.PBMailleur.setText(_translate("Choix", "Table Mailleurs")) + self.PBMaillage.setText(_translate("Choix", "Table Maillages")) + self.PBMachine.setText(_translate("Choix", "Table Machines")) + self.PBVersion.setText(_translate("Choix", "Table Versions")) + self.PBGroupesRef.setText(_translate("Choix", "Table Groupes Référence")) if __name__ == "__main__": import sys - app = QtGui.QApplication(sys.argv) - Choix = QtGui.QDialog() + app = QtWidgets.QApplication(sys.argv) + Choix = QtWidgets.QDialog() ui = Ui_Choix() ui.setupUi(Choix) Choix.show() diff --git a/src/Tools/Verima/Gui/maFenetreChoix.py b/src/Tools/Verima/Gui/maFenetreChoix.py index a92b14945..27b8e4f24 100644 --- a/src/Tools/Verima/Gui/maFenetreChoix.py +++ b/src/Tools/Verima/Gui/maFenetreChoix.py @@ -1,5 +1,5 @@ -from desFenetreChoix_ui import Ui_Choix from qtsalome import * +from .desFenetreChoix import Ui_Choix from .monEditor import TableEditor # Import des panels diff --git a/src/Tools/Verima/Gui/monEditor.py b/src/Tools/Verima/Gui/monEditor.py index 13b5c9d49..cd4fe96c5 100644 --- a/src/Tools/Verima/Gui/monEditor.py +++ b/src/Tools/Verima/Gui/monEditor.py @@ -17,7 +17,7 @@ class TableEditor(QDialog): quitButton=QPushButton("Quit") buttonBox=QDialogButtonBox(Qt.Vertical) buttonBox.addButton(quitButton, QDialogButtonBox.RejectRole); - quitButton.clicked.connect(self.close()) + quitButton.clicked.connect(self.close) mainLayout = QHBoxLayout(self) mainLayout.addWidget(self.view) @@ -31,7 +31,7 @@ class TableEditor(QDialog): self.view.adjustSize() self.adjustSize() self.view.pressed[QModelIndex].connect(self.donneLigne) - self.view.itemPressed[QTableWidgetItem].conect(self.donneLigne) + self.view.itemPressed[QTableWidgetItem].connect(self.donneLigne) self.view.clicked[QModelIndex].connect(self.donneLigne) self.view.clicked.connect(self.donneLigne) self.view.pressed.connect(self.donneLigne) diff --git a/src/Tools/Verima/Gui/visualiseDatabase.py b/src/Tools/Verima/Gui/visualiseDatabase.py index 1e952520c..cfc0ae36b 100755 --- a/src/Tools/Verima/Gui/visualiseDatabase.py +++ b/src/Tools/Verima/Gui/visualiseDatabase.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys,os rep=os.path.dirname(os.path.abspath(__file__)) @@ -6,19 +6,19 @@ installDir=os.path.join(rep,'..') sys.path.insert(0,installDir) from qtsalome import QApplication -from Gui.maFenetreChoix_ui import MaFenetreChoix +from Gui.maFenetreChoix import MaFenetreChoix from Base.dataBase import Base if __name__ == "__main__": - from optparse import OptionParser - p=OptionParser() - p.add_option('-d',dest='database',default="myMesh.db",help='nom de la database') - options, args = p.parse_args() + from argparse import ArgumentParser + p=ArgumentParser() + p.add_argument('-d',dest='database',default="myMesh.db",help='nom de la database') + args = p.parse_args() app = QApplication(sys.argv) - maBase=Base(options.database) + maBase=Base(args.database) maBase.initialise() window = MaFenetreChoix(maBase) window.show() diff --git a/src/Tools/Verima/Stats/getCritere.py b/src/Tools/Verima/Stats/getCritere.py index 920496506..ab7edff59 100644 --- a/src/Tools/Verima/Stats/getCritere.py +++ b/src/Tools/Verima/Stats/getCritere.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 import sys,os import salome diff --git a/src/Tools/Verima/Stats/job.py b/src/Tools/Verima/Stats/job.py index 6ee955236..68a8153ab 100644 --- a/src/Tools/Verima/Stats/job.py +++ b/src/Tools/Verima/Stats/job.py @@ -18,7 +18,7 @@ class Job: def execute(self): home=os.environ['HOME'] - commande=os.path.abspath(os.path.join(home,self.salomePath,"runAppli")) + commande=os.path.abspath(os.path.join(home,self.salomePath,"salome")) script= os.path.abspath(os.path.join(os.path.abspath(__file__),'../..',self.script)) debut=time.time() diff --git a/src/Tools/Verima/ajoutEnreg.py b/src/Tools/Verima/ajoutEnreg.py index 57d18dcc6..de84fd7ae 100755 --- a/src/Tools/Verima/ajoutEnreg.py +++ b/src/Tools/Verima/ajoutEnreg.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 import sys, os rep=os.path.dirname(os.path.abspath(__file__)) @@ -6,7 +6,7 @@ installDir=os.path.join(rep,'..') sys.path.insert(0,installDir) from qtsalome import * -from .Base.dataBase import Base +from Base.dataBase import Base def completeDatabase(fichier,table,enregistrement): maBase=Base(fichier) @@ -27,17 +27,18 @@ def completeDatabase(fichier,table,enregistrement): if __name__ == "__main__": - from optparse import OptionParser - p=OptionParser() - p.add_option('-d',dest='database',default="myMesh.db",help='nom de la database') - p.add_option('-t',dest='table',help='nom de la table a completer') - options, args = p.parse_args() - if options.table==None : + from argparse import ArgumentParser + p=ArgumentParser() + p.add_argument('-d',dest='database',default="myMesh.db",help='nom de la database') + p.add_argument('table',help='nom de la table a completer') + p.add_argument('enregistrement', nargs="+") + args = p.parse_args() + if args.table is None : print("table obligatoire") exit() - if options.table not in ("TableMaillages","TableMailleurs","TableGroupesRef","TableVersions") : - print("la table doit etre : TableMaillages ou TableMailleurs ou TableGroupesRef ou TableVersions") + good_tables = ("TableMaillages","TableMailleurs","TableGroupesRef","TableVersions") + if args.table not in good_tables: + print("la table doit etre : %s" % ' ou '.join(good_tables)) exit() - enregistrement=tuple(args) - completeDatabase(options.database,options.table,enregistrement) + completeDatabase(args.database,args.table,args.enregistrement) diff --git a/src/Tools/Verima/compareVersions.py b/src/Tools/Verima/compareVersions.py index 9ceb0fc50..29fd6860c 100755 --- a/src/Tools/Verima/compareVersions.py +++ b/src/Tools/Verima/compareVersions.py @@ -3,26 +3,26 @@ import sys import os -from .Base.dataBase import Base -from .Base.versions import Chercheversion +from Base.dataBase import Base +from Base.versions import Chercheversion if __name__ == "__main__": - from optparse import OptionParser - p=OptionParser() - p.add_option('-s',dest='salomePath',help='chemin du runAppli de la version a comparer',default="Appli") - p.add_option('-v',dest='version',help='id de la version a comparer',default=None) - p.add_option('-r',dest='versionRef',help='liste des id des versions de reference',default=None) - p.add_option('-d',dest='database',default="myMesh.db",help='nom de la database') - p.add_option('-f',dest='fileHtml',default="/tmp/toto.htm",help='nom du fichier produit') - options, args = p.parse_args() + from argparse import ArgumentParser + p=ArgumentParser() + p.add_argument('-s',dest='salomePath',help='chemin du lanceur salome de la version a comparer',default="Appli") + p.add_argument('-v',dest='version',help='id de la version a comparer',default=None) + p.add_argument('-r',dest='versionRef',help='liste des id des versions de reference',default=None) + p.add_argument('-d',dest='database',default="myMesh.db",help='nom de la database') + p.add_argument('-f',dest='fileHtml',default="/tmp/toto.htm",help='nom du fichier produit') + args = p.parse_args() - if options.version==None : - options.version=Chercheversion(options.salomePath) + if args.version is None : + args.version=Chercheversion(args.salomePath) exit - maBase=Base(options.database) + maBase=Base(args.database) maBase.initialise() - maBase.compare(options.version,options.versionRef,options.fileHtml) + maBase.compare(args.version,args.versionRef,args.fileHtml) maBase.close() diff --git a/src/Tools/Verima/createDatabase.py b/src/Tools/Verima/createDatabase.py index ce5986111..d108f7372 100755 --- a/src/Tools/Verima/createDatabase.py +++ b/src/Tools/Verima/createDatabase.py @@ -1,7 +1,7 @@ #!/usr/bin/env python import sys -from .Base.dataBase import Base +from Base.dataBase import Base def creeDatabase(fichier): maBase=Base(fichier) @@ -13,9 +13,9 @@ def creeDatabase(fichier): if __name__ == "__main__": - from optparse import OptionParser - p=OptionParser() - p.add_option('-d',dest='database',default="myMesh.db",help='nom de la database') - options, args = p.parse_args() - creeDatabase(options.database ) + from argparse import ArgumentParser + p=ArgumentParser() + p.add_argument('-d',dest='database',default="myMesh.db",help='nom de la database') + args = p.parse_args() + creeDatabase(args.database ) diff --git a/src/Tools/Verima/lance.py b/src/Tools/Verima/lance.py index 9fd326ef8..14321677a 100755 --- a/src/Tools/Verima/lance.py +++ b/src/Tools/Verima/lance.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 from qtsalome import * from .Gui.myMain_ui import Ui_Gestion diff --git a/src/Tools/Verima/passeJobs.py b/src/Tools/Verima/passeJobs.py index 74cb9a078..e437132d6 100755 --- a/src/Tools/Verima/passeJobs.py +++ b/src/Tools/Verima/passeJobs.py @@ -1,31 +1,31 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 import sys import os -from .Base.dataBase import Base -from .Base.versions import Chercheversion +from Base.dataBase import Base +from Base.versions import Chercheversion if __name__ == "__main__": - from optparse import OptionParser - p=OptionParser() - p.add_option('-a',dest='all',action="store_true", default=False,help='passe l ensemble des Tests') - p.add_option('-s',dest='salomePath',help='chemin du runAppli',default="Appli") - p.add_option('-v',dest='version',help='id de la version') - p.add_option('-d',dest='database',default="myMesh.db",help='nom de la database') - p.add_option('-f',dest='force',default=True,help='force la passage des jobs meme si l execution a deja eu lieu sur cette machine pour cette version de salome') - options, args = p.parse_args() - if len(args) == 0 and options.all== False: + from argparse import ArgumentParser + p=ArgumentParser() + p.add_argument('-a',dest='all_tests',action="store_true", default=False,help='passe l ensemble des Tests') + p.add_argument('-s',dest='salomePath',help='chemin du lanceur salome',default="Appli") + p.add_argument('-v',dest='version',help='id de la version') + p.add_argument('-d',dest='database',default="myMesh.db",help='nom de la database') + p.add_argument('-f',dest='force',default=True,help='force la passage des jobs meme si l execution a deja eu lieu sur cette machine pour cette version de salome') + p.add_argument('job', nargs='*') + args = p.parse_args() + if len(args.job) == 0 and args.all_tests == False: print("Enter -a ou un numero de job") print(2) exit() - if options.salomePath==None : - print("chemin du runAppli obligatoire") + if args.salomePath is None : + print("chemin du lanceur salome obligatoire") exit() - if options.version==None : - options.version=Chercheversion(options.salomePath) - maBase=Base(options.database) + if args.version is None : + args.version=Chercheversion(args.salomePath) + maBase=Base(args.database) maBase.initialise() - maBase.passeJobs(options.all,options.salomePath,options.version,options.force,args) + maBase.passeJobs(args.all_tests,args.salomePath,args.version,args.force,args.job) maBase.close() diff --git a/src/Tools/ZCracksPlug/zcracksLaunch.py b/src/Tools/ZCracksPlug/zcracksLaunch.py index fa7acf20e..4d58ce114 100755 --- a/src/Tools/ZCracksPlug/zcracksLaunch.py +++ b/src/Tools/ZCracksPlug/zcracksLaunch.py @@ -1,5 +1,4 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- +#!/usr/bin/env python3 import Zcracks Zcracks.IHM() diff --git a/src/Tools/padder/resources/testdata/buildparticules.py b/src/Tools/padder/resources/testdata/buildparticules.py index b279695da..c2dea7a86 100755 --- a/src/Tools/padder/resources/testdata/buildparticules.py +++ b/src/Tools/padder/resources/testdata/buildparticules.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python +#!/usr/bin/env python3 # Copyright (C) 2011-2016 EDF R&D # # This library is free software; you can redistribute it and/or @@ -18,6 +18,7 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # +import csv import salome salome.salome_init() import GEOM @@ -25,10 +26,9 @@ from salome.geom import geomBuilder geompy = geomBuilder.New(salome.myStudy) filename="/home/gboulant/development/projets/salome/SPADDER/spadder/resources/padderexe/REF_spheres.dat.xyz" -file=open(filename,'rb') -import csv -datalines = csv.reader(file, delimiter=' ') +with open(filename,'rb') as f: + datalines = csv.reader(file, delimiter=' ') i=0 for row in datalines: x=float(row[0]) -- 2.39.2