Salome HOME
get caller info in debug write
authorcrouzet <nicolas.crouzet@cea.fr>
Thu, 12 Sep 2019 14:13:12 +0000 (16:13 +0200)
committercrouzet <nicolas.crouzet@cea.fr>
Thu, 12 Sep 2019 14:13:12 +0000 (16:13 +0200)
sat
src/debug.py
src/product.py
src/salomeTools.py

diff --git a/sat b/sat
index 921aab8b0bdad908548167eef085b0cb5ad42020..e4c65502be57fc1c81d8c64162969695008ceae8 100755 (executable)
--- a/sat
+++ b/sat
@@ -52,9 +52,9 @@ DBG.write("Python version", sys.version, DBG.isDeveloper())
 #################################
 if __name__ == "__main__":
     if platform.python_version()[0]=="3":
-        msg_py3="sat is used with python 3!! It is not designed for!\n"\
+        msg_py3="sat is used with python 3!! It is not yet completely validated for!\n"\
                 "Please check you environment.\n"\
-                "sat should be used with a (native) python 2 version."
+                "sat should be used preferentially with a (native) python 2 version."
         logger.warning(msg_py3)
     from src.salomeTools import Sat # it is time to do import
 
index 50e24d883c26594c6a0f71d56cfd49d4a1d103d6..a7c50e85aade084bc5165d88399d67446349cb95 100755 (executable)
@@ -55,6 +55,7 @@ import os
 import sys
 import traceback
 import pprint as PP
+import inspect
 
 # Compatibility python 2/3 for unicode
 try:
@@ -95,9 +96,13 @@ def isTypeConfig(var):
     # print "NOT isTypeConfig %s" % typ
     return False
     
-def write(title, var="", force=None, fmt="\n#### DEBUG: %s:\n%s\n"):
+def write(title, var="", force=None, fmt="  %s:\n%s\n####\n"):
     """write sys.stderr a message if _debug[-1]==True or optionaly force=True"""
     if _debug[-1] or force:
+      callerframerecord = inspect.stack()[1] # get info of the caller
+      frame = callerframerecord[0]
+      info = inspect.getframeinfo(frame)
+      sys.stderr.write("\n#### DEBUG - %s:%s (%s) ####\n" % (info.filename, info.lineno, info.function))
       tvar = type(var)
       typ = str(tvar)
       if isTypeConfig(var):
@@ -119,7 +124,11 @@ def tofix(title, var="", force=None):
     use this only if no logger accessible for classic logger.warning(message)
     """
     if _debug[-1] or isDeveloper():
-        fmt = "\n#### TOFIX: %s:\n%s\n"
+        callerframerecord = inspect.stack()[1] # get info of the caller
+        frame = callerframerecord[0]
+        info = inspect.getframeinfo(frame)
+        fmt = "#### TOFIX - " + str(info.filename) + ":" + str(info.lineno) +\
+              " (" + str(info.function) + ") ####\n   %s:\n%s\n"
         write(title, var, force, fmt)
 
 def push_debug(aBool):
index 48baea2c9506c2e18085e61f1c41cfc78f7a6e57..6ca42810daee9fa34c7a69bfa65eec82dfd6940a 100644 (file)
@@ -274,9 +274,6 @@ Please add a section in it.""") % {"1" : vv, "2" : prod_pyconf_path}
         if not arch_path:
             # arch_path is not found. It may generate an error in sat source,
             #                         unless the archive is found in ftp serveur
-            msg = _("Archive %(1)s for %(2)s not found in config.PATHS.ARCHIVEPATH") % \
-                   {"1" : arch_name, "2" : prod_info.name}
-            DBG.tofix(msg, config.PATHS.ARCHIVEPATH)
             prod_info.archive_info.archive_name = arch_name #without path
         else:
             prod_info.archive_info.archive_name = arch_path
@@ -395,16 +392,12 @@ def get_product_section(config, product_name, version, section=None):
     else:
         # in this (historic) mode the definition of the product is given by a full unique section
         is_incr=False
-    if is_incr:
-        DBG.write("Incremental definition mode activated for", product_name)
 
     # decode version number
     try:
       versionMMP = VMMP.MinorMajorPatch(version)
     except: # example setuptools raise "minor in major_minor_patch is not integer: '0_6c11'"
       versionMMP = None
-    DBG.write("get_product_section for product %s '%s' as version '%s'" % (product_name, version, versionMMP),
-              (section, aProd.keys()))
 
     # if a section is explicitely specified we select it
     if section:
@@ -418,7 +411,6 @@ def get_product_section(config, product_name, version, section=None):
     # If it exists, get the information of the product_version
     # ex: 'version_V6_6_0' as salome version classical syntax
     elif "version_" + version in aProd:
-        DBG.write("found section for version_" + version)
         # returns specific information for the given version
         pi = aProd["version_" + version]
         pi.section = "version_" + version
@@ -430,10 +422,8 @@ def get_product_section(config, product_name, version, section=None):
         l_section_ranges = []
         tagged = []
         for name in l_section_names:
-          # DBG.write("name", name,True)
           aRange = VMMP.getRange_majorMinorPatch(name)
           if aRange is not None:
-            DBG.write("found version range for section '%s'" % name, aRange)
             l_section_ranges.append((name, aRange))
 
         if versionMMP is not None and len(l_section_ranges) > 0:
@@ -446,8 +436,6 @@ def get_product_section(config, product_name, version, section=None):
                          PP.pformat(tagged))
           pi=None
         elif len(tagged) == 1: # ok
-          DBG.write("one version range tagged for '%s'" % version,
-                       PP.pformat(tagged))
           name, (vmin, vmax) = tagged[0]
           pi = aProd[name]
           pi.section = name
@@ -457,7 +445,6 @@ def get_product_section(config, product_name, version, section=None):
         elif "default" in aProd:
             # returns the generic information (given version not found)
             pi = aProd.default
-            DBG.write("default tagged for '%s'" % version, pi)
             pi.section = "default"
             pi.from_file = aProd.from_file
         else:
@@ -483,10 +470,11 @@ def get_product_section(config, product_name, version, section=None):
             if src.architecture.is_windows() and win_section in aProd:
                 for key in aProd[win_section]:
                     prod_info[key]=aProd[win_section][key]
-        DBG.write("Incremental definition, return product info :", prod_info)
     else:
         prod_info=pi
 
+    #DBG.write("product info returned for product %s with version %s and section %s" %\
+    #          (product_name, version, section), prod_info)
     return prod_info
     
 def get_install_dir(config, base, version, prod_info):
@@ -853,7 +841,6 @@ def check_source(product_info):
     :return: True if it is well installed
     :rtype: boolean
     """
-    DBG.write("check_source product_info", product_info)
     source_dir = product_info.source_dir
     if not os.path.exists(source_dir):
         return False
@@ -1050,8 +1037,6 @@ def product_has_patches(product_info):
     :rtype: boolean
     """   
     res = ( "patches" in product_info and len(product_info.patches) > 0 )
-    DBG.write('product_has_patches %s' % product_info.name, res)
-    # if product_info.name == "XDATA": return True #test #10569
     return res
 
 def product_has_logo(product_info):
index 3d4774e7b84dc5f9536b846ce6f8dbcd965664d3..9c5da619dc8f31e2c089220d5097cd756592c7b1 100755 (executable)
@@ -348,7 +348,6 @@ class Sat(object):
         '''
         # loop on the commands name
         for nameCmd in lCommand:
-            DBG.write("load module command '%s.py'" % nameCmd, "")
             # Exception for the jobs command that requires the paramiko module
             if nameCmd == "jobs":
                 try: