#
"""Lancement des cas-tests de blocFissure"""
-import traceback
-
import logging
+import os
+import tempfile
+import traceback
from blocFissure.gmu import initLog
from blocFissure.gmu.casStandard import casStandard
# -----------------------------------------------------------------------------------------------
-#initLog.setDebug()
-#initLog.setVerbose()
-#initLog.setRelease()
-#initLog.setPerfTests()
+LOGFILE = os.path.join(tempfile.gettempdir(),"blocFissure.log")
+#initLog.setDebug(LOGFILE) # debug = 10
+initLog.setVerbose(LOGFILE) # info = 20
+#initLog.setRelease(LOGFILE) # warning = 30
+#initLog.setPerfTests(LOGFILE) # critical = 50
+#initLog.setAlways(LOGFILE) # critical = 50
# ---tous les cas en séquence, ou les cas sélectionnés ...
TORUNOK = [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0] # OK
nom = cas.nomProbleme
texte_a = "\n=== Exécution du cas n° {}, '{}'".format(n_cas,nom)
logging.critical(ligne+texte_a)
+
try:
ok_maillage = cas.executeProbleme()
except:
if not ok_maillage:
texte = "Problème avec le cas n° {}, '{}'\n".format(n_cas,nom)
print(ligne)
+
return ok_maillage, texte
#=============================================================
def calcul_tout (l_problemes, d_aux):
for n_edges, edges in enumerate(listEdges):
- idf = idFacesDebouchantes[n_edges] # indice de face débouchante (facesPipePeau)
+ # idf = indice de face débouchante (facesPipePeau) ; idf vaut 0 ou 1
+ idf = idFacesDebouchantes[n_edges]
logging.info("idf: %d", idf)
- if idf >= 0:
+ if ( idf >= 0 ):
gptdsk = list()
- if idf > 0: # idf vaut 0 ou 1
- idf = -1 # si idf vaut 1, on prend le dernier élément de la liste (1 ou 2 extrémités débouchent sur la face)
+ # si idf vaut 1, on prend le dernier élément de la liste (1 ou 2 extrémités débouchent sur la face)
+ if ( idf > 0 ):
+ idf = -1
centre = ptEdgeFond[idFillingFromBout[n_edges]][idf]
name = "centre_{}".format(idf)
geomPublish(initLog.debug, centre, name)
edgesCirc = list()
for grpEdgesCirc in grpsEdgesCirc:
edgesCirc += geompy.ExtractShapes(grpEdgesCirc, geompy.ShapeType["EDGE"], False)
- logging.info("edgesCirc: %s", edgesCirc)
+ logging.debug("edgesCirc: %s", edgesCirc)
for i_aux, edge in enumerate(edges):
extrems = geompy.ExtractShapes(edge, geompy.ShapeType["VERTEX"], True)
critical = 50
always = 100
-filelog = os.path.join(tempfile.gettempdir(),"blocFissure.log")
+LOGFILE = os.path.join(tempfile.gettempdir(),"blocFissure.log")
-loglevel = warning
+LOG_LEVEL = warning
logging.basicConfig(format='%(funcName)s[%(lineno)d] %(message)s', \
level=logging.WARNING, \
- filename=filelog, filemode='w')
+ filename=LOGFILE, filemode='w')
ch = None
fh = None
def setDebug(logfile=None):
"""setDebug"""
- global loglevel
- loglevel = debug
+ global LOG_LEVEL
+ LOG_LEVEL = debug
level = logging.DEBUG
formatter = logging.Formatter('%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s')
setLogger(logfile, level, formatter)
- logging.info('start Debug %s', loglevel)
+ logging.info('start Debug %s', LOG_LEVEL)
def setVerbose(logfile=None):
"""setVerbose"""
- global loglevel
- loglevel = info
+ global LOG_LEVEL
+ LOG_LEVEL = info
level = logging.INFO
formatter = logging.Formatter('%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s')
setLogger(logfile, level, formatter)
- logging.info('start Verbose %s', loglevel)
+ logging.info('start Verbose %s', LOG_LEVEL)
def setRelease(logfile=None):
"""setRelease"""
- global loglevel
- loglevel = warning
+ global LOG_LEVEL
+ LOG_LEVEL = warning
level = logging.WARNING
formatter = logging.Formatter('%(funcName)s[%(lineno)d] %(message)s')
setLogger(logfile, level, formatter)
- logging.warning('start Release %s', loglevel)
+ logging.warning('start Release %s', LOG_LEVEL)
def setUnitTests(logfile=None):
"""setUnitTests"""
- global loglevel
- loglevel = critical
+ global LOG_LEVEL
+ LOG_LEVEL = critical
level = logging.CRITICAL
formatter = logging.Formatter('%(funcName)s[%(lineno)d] %(message)s')
setLogger(logfile, level, formatter)
- logging.critical('start UnitTests %s', loglevel)
+ logging.critical('start UnitTests %s', LOG_LEVEL)
def setPerfTests(logfile=None):
"""setPerfTests"""
- global loglevel
- loglevel = critical
+ global LOG_LEVEL
+ LOG_LEVEL = critical
level = logging.CRITICAL
formatter = logging.Formatter('%(funcName)s[%(lineno)d] %(message)s')
setLogger(logfile, level, formatter)
- logging.info('start PerfTests %s', loglevel)
+ logging.info('start PerfTests %s', LOG_LEVEL)
+
+def setAlways(logfile=None):
+ """setAlways"""
+ global LOG_LEVEL
+ LOG_LEVEL = always
+ level = logging.CRITICAL
+ formatter = logging.Formatter('%(relativeCreated)d %(funcName)s[%(lineno)d] %(message)s')
+ setLogger(logfile, level, formatter)
+ logging.info('start Always %s', LOG_LEVEL)
def getLogLevel():
"""getLogLevel"""
- return loglevel
+ return LOG_LEVEL