]> SALOME platform Git repositories - tools/sat.git/commitdiff
Salome HOME
rename level into verbose, and set verbose 0 to silent option
authorSerge Rehbinder <serge.rehbinder@cea.fr>
Mon, 18 Apr 2016 12:24:46 +0000 (14:24 +0200)
committerSerge Rehbinder <serge.rehbinder@cea.fr>
Mon, 18 Apr 2016 12:24:46 +0000 (14:24 +0200)
commands/config.py
commands/patch.py
salomeTools.py
src/logger.py

index f12e7244522a33b75a4a7af6c6c9df1751c9b590..9d35e542d92ce2c29e2529114d2ba6aade204a35 100644 (file)
@@ -356,8 +356,8 @@ class ConfigManager:
             "This is the user name used to access salome cvs base.\n")
         user_cfg.USER.addMapping('svn_user', config.VARS.user,
             "This is the user name used to access salome svn base.\n")
-        user_cfg.USER.addMapping('output_level', 3,
-            "This is the default output_level you want."
+        user_cfg.USER.addMapping('output_verbose_level', 3,
+            "This is the default output_verbose_level you want."
             " 0=>no output, 5=>debug.\n")
         user_cfg.USER.addMapping('publish_dir', 
                                  os.path.join(os.path.expanduser('~'),
index 90ae305bcb78ca4f6f4fb343a76162efc4066c4c..e118708ee41652d2faa0c59b36935bfdbb6d8737 100644 (file)
@@ -61,14 +61,18 @@ def apply_patch(config, product_info, logger):
         
         # Check the existence and apply the patch
         if os.path.isfile(patch):
-            #patch_exe = "patch" # old patch command (now replace by patch.py)
+            #patch_exe = "patch" # old patch command (now replace by patching.py)
             patch_exe = os.path.join(config.VARS.srcDir, "patching.py")
             patch_cmd = "python %s -p1 -- < %s" % (patch_exe, patch)
 
+            # Write the command in the terminal if verbose level is at 5
             logger.write(("    >%s\n" % patch_cmd),5)
             
+            # Write the command in the log file (can be seen using 'sat log')
             logger.logTxtFile.write("\n    >%s\n" % patch_cmd)
             logger.logTxtFile.flush()
+            
+            # Call the command
             res_cmd = (subprocess.call(patch_cmd, 
                                    shell=True, 
                                    cwd=product_info.source_dir,
@@ -88,7 +92,7 @@ def apply_patch(config, product_info, logger):
             message = src.printcolors.printcWarning(
                                         _("Failed to apply patch %s") % patch)
 
-        if config.USER.output_level >= 3:
+        if config.USER.output_verbose_level >= 3:
             retcode.append("  %s" % message)
         else:
             retcode.append("%s: %s" % (product_info.name, message))
@@ -126,7 +130,7 @@ def run(args, runner, logger):
                                 runner.cfg.APPLICATION.out_dir, 2)
     logger.write("\n", 2, False)
 
-    # Get the products list with products informations reagrding the options
+    # Get the products list with products informations regarding the options
     products_infos = prepare.get_products_list(options, runner.cfg, logger)
     
     # Get the maximum name length in order to format the terminal display
@@ -141,6 +145,7 @@ def run(args, runner, logger):
         logger.write('%s: ' % src.printcolors.printcLabel(product_name), 3)
         logger.write(' ' * (max_product_name_len - len(product_name)), 3, False)
         logger.write("\n", 4, False)
+        # Apply the patch
         return_code, patch_res = apply_patch(runner.cfg, product_info, logger)
         logger.write(patch_res, 1, False)
         if return_code:
index 3f431284e433f3d5c4b24d690ac136ffab67d666..09267ba5c017ae0da6ac7bce1f4751641485768d 100755 (executable)
@@ -75,10 +75,8 @@ parser.add_option('o', 'overwrite', 'list', "overwrite",
                   _("overwrites a configuration parameters."))
 parser.add_option('g', 'debug', 'boolean', 'debug_mode', 
                   _("run salomeTools in debug mode."))
-parser.add_option('l', 'level', 'int', "output_level", 
-                  _("change output level (default is 3)."))
-parser.add_option('s', 'silent', 'boolean', 'silent', 
-                  _("do not write log or show errors."))
+parser.add_option('v', 'verbose', 'int', "output_verbose_level", 
+                  _("change output verbose level (default is 3)."))
 
 class Sat(object):
     '''The main class that stores all the commands of salomeTools
@@ -167,15 +165,16 @@ class Sat(object):
                                                  command=__nameCmd__)
                     
                 # set output level
-                if self.options.output_level:
-                    self.cfg.USER.output_level = self.options.output_level
-                if self.cfg.USER.output_level < 1:
-                    self.cfg.USER.output_level = 1
-
+                if self.options.output_verbose_level is not None:
+                    self.cfg.USER.output_verbose_level = self.options.output_verbose_level
+                if self.cfg.USER.output_verbose_level < 1:
+                    self.cfg.USER.output_verbose_level = 0
+                silent = (self.cfg.USER.output_verbose_level == 0)
+                               
                 # create log file, unless the command is called 
                 # with a logger as parameter
                 logger_command = src.logger.Logger(self.cfg, 
-                                                   silent_sysstd=self.options.silent)
+                                                   silent_sysstd=silent)
                 if logger:
                     logger_command = logger
                 
index ee0ef4050d8802656e34dd398be5a5583ed2b531..eddcd55c4b3289c90cded6e21518c7b73f89e02f 100644 (file)
@@ -114,7 +114,7 @@ class Logger(object):
                                           printcolors.cleancolor(message))
 
         # get user or option output level
-        current_output_level = self.config.USER.output_level
+        current_output_verbose_level = self.config.USER.output_verbose_level
         if not ('isatty' in dir(sys.stdout) and sys.stdout.isatty()):
             # clean the message color if the terminal is redirected by user
             # ex: sat compile appli > log.txt
@@ -122,10 +122,10 @@ class Logger(object):
         
         # Print message regarding the output level value
         if level:
-            if level <= current_output_level and not self.silentSysStd:
+            if level <= current_output_verbose_level and not self.silentSysStd:
                 sys.stdout.write(message)
         else:
-            if self.default_level <= current_output_level and not self.silentSysStd:
+            if self.default_level <= current_output_verbose_level and not self.silentSysStd:
                 sys.stdout.write(message)
 
     def error(self, message):