]> SALOME platform Git repositories - tools/pvdeliv.git/commitdiff
Salome HOME
add verbose mode
authorCédric Aguerre <cedric.aguerre@edf.fr>
Thu, 20 Oct 2016 12:44:23 +0000 (14:44 +0200)
committerCédric Aguerre <cedric.aguerre@edf.fr>
Thu, 20 Oct 2016 12:44:23 +0000 (14:44 +0200)
scripts/BuildSalomeMini.py
scripts/salome_compile.py

index bc75460c7cc90b677b7e90268a60c059b556ea33..42660f77fdc158a8e779c2ff729193498d4f909a 100755 (executable)
@@ -13,7 +13,7 @@ from salome_environ import accumulateEnv, generateFileEnv
 
 current_directory=os.path.dirname(os.path.abspath(__file__))
 
-def __init(envAcc={}, paraview_version=None, use_pleiade_mirrors=False, nb_jobs=None):
+def __init(envAcc={}, paraview_version=None, use_pleiade_mirrors=False, nb_jobs=None, verbose_mode=False):
   # Read configuration
   filename=os.path.join(current_directory, "SalomeMiniConfig.cfg")
   config=read_config_file(filename)
@@ -29,6 +29,7 @@ def __init(envAcc={}, paraview_version=None, use_pleiade_mirrors=False, nb_jobs=
   if nb_jobs:
     config["make_nb_jobs"] = nb_jobs
     pass
+  config["verbose_mode"] = verbose_mode
   # Check system prerequisites
   check_gcc_version(config["gcc_version_min"], envAcc)
   # Download archives
@@ -75,9 +76,9 @@ ENDIF()
   return os.path.abspath(destReal)
 ####################
 
-def __let_us_go(paraview_version=None, use_pleiade_mirrors=False, nb_jobs=None):
+def __let_us_go(paraview_version=None, use_pleiade_mirrors=False, nb_jobs=None, verbose_mode=False):
   envAcc={}
-  config=__init(paraview_version=paraview_version, use_pleiade_mirrors=use_pleiade_mirrors, nb_jobs=nb_jobs)
+  config=__init(paraview_version=paraview_version, use_pleiade_mirrors=use_pleiade_mirrors, nb_jobs=nb_jobs,verbose_mode=verbose_mode)
 
   # Prepare build
   rootDir="SalomeMini"
@@ -170,6 +171,9 @@ def __parse_options():
   parser.add_option("--pleiade",
                     action="store_true", dest="pleiade", default=False,
                     help="Use PLEIADE mirrors (for EDF).")
+  parser.add_option("--verbose",
+                    action="store_true", dest="verbose_mode", default=False,
+                    help="Log to stdout/stderr and files. If false only log to files.")
   (options, args) = parser.parse_args()
   return options, args
 
@@ -193,4 +197,4 @@ if __name__ == "__main__":
       print "Syntax error in paraview version"
       sys.exit(1)
 
-  __let_us_go(paraview_version=paraview_version, use_pleiade_mirrors=options.pleiade, nb_jobs=nb_jobs)
+  __let_us_go(paraview_version=paraview_version, use_pleiade_mirrors=options.pleiade, nb_jobs=nb_jobs, verbose_mode=options.verbose_mode)
index eae2da64b9c5f3cede29d6375edfa238fb6b108f..d718ba12ed86048659ff81f54607c306053b512f 100644 (file)
@@ -71,7 +71,7 @@ def __compilePart0(topSrcDir,pattern,config,envAcc,srcDir,topBuildDir,topInstall
   config["softwareChanged"][pattern] = True
   return myBuildDir,myInstallDir,True
 
-def __runCommandAndLogToFileAndStdOut(myCmd,myBuildDir,envAcc,filename_out,filename_err):
+def __runCommandAndLogToFileAndStdOut(myCmd,myBuildDir,envAcc,filename_out,filename_err,verbose_mode):
   file_out=file(os.path.join(myBuildDir,filename_out),"w")
   file_err=file(os.path.join(myBuildDir,filename_err),"w")
   p=subprocess.Popen(myCmd,cwd=myBuildDir,env=computeEnv(envAcc),stdout=subprocess.PIPE,stderr=subprocess.PIPE)
@@ -81,8 +81,14 @@ def __runCommandAndLogToFileAndStdOut(myCmd,myBuildDir,envAcc,filename_out,filen
       f2.write(line)
       pass
     pass
-  t1 = threading.Thread(target=tee_pipe, args=(p.stdout, file_out, sys.stdout))
-  t2 = threading.Thread(target=tee_pipe, args=(p.stderr, file_err, sys.stderr))
+  if verbose_mode:
+    stdout=sys.stdout
+    stderr=sys.stderr
+  else:
+    stdout=open(os.devnull, 'w')
+    stderr=open(os.devnull, 'w')
+  t1 = threading.Thread(target=tee_pipe, args=(p.stdout, file_out, stdout))
+  t2 = threading.Thread(target=tee_pipe, args=(p.stderr, file_err, stderr))
   t3 = threading.Thread(target=p.wait)
   t1.start(); t2.start(); t3.start()
   t1.join(); t2.join(); t3.join()
@@ -90,8 +96,8 @@ def __runCommandAndLogToFileAndStdOut(myCmd,myBuildDir,envAcc,filename_out,filen
   file_err.flush()
   return p.returncode
 
-def __compilePart1(myCmd,envAcc,buildDir):
-  returncode = __runCommandAndLogToFileAndStdOut(myCmd,buildDir,envAcc,cfgOut,cfgErr)
+def __compilePart1(myCmd,envAcc,buildDir,verbose_mode):
+  returncode = __runCommandAndLogToFileAndStdOut(myCmd,buildDir,envAcc,cfgOut,cfgErr,verbose_mode)
   if returncode != 0:
     msg = "Error in build step. See details in %s and %s\n"%(os.path.join(buildDir,cfgOut), os.path.join(buildDir,cfgErr))
     raise Exception(msg)
@@ -99,17 +105,18 @@ def __compilePart1(myCmd,envAcc,buildDir):
 def __compilePart2(topSrcDir,pattern,config,envAcc,buildDir,splitInstall):
     print("make in %s"%(buildDir))
     paraCompFlag = config["paraCompFlag"]
+    verbose_mode = config["verbose_mode"]
     if not splitInstall:
-      returncode = __runCommandAndLogToFileAndStdOut(["make",paraCompFlag,"install"],buildDir,envAcc,compOut,compErr)
+      returncode = __runCommandAndLogToFileAndStdOut(["make",paraCompFlag,"install"],buildDir,envAcc,compOut,compErr,verbose_mode)
       if returncode != 0:
         msg = "Error in build step. See details in %s and %s\n"%(os.path.join(buildDir,compOut), os.path.join(buildDir,compErr))
         raise Exception(msg)
     else:
-      returncode = __runCommandAndLogToFileAndStdOut(["make",paraCompFlag],buildDir,envAcc,compOut,compErr)
+      returncode = __runCommandAndLogToFileAndStdOut(["make",paraCompFlag],buildDir,envAcc,compOut,compErr,verbose_mode)
       if returncode != 0:
         msg = "Error in build step. See details in %s and %s\n"%(os.path.join(buildDir,compOut), os.path.join(buildDir,compErr))
         raise Exception(msg)
-      returncode = __runCommandAndLogToFileAndStdOut(["make",paraCompFlag,"install"],buildDir,envAcc,compOut,compErr)
+      returncode = __runCommandAndLogToFileAndStdOut(["make",paraCompFlag,"install"],buildDir,envAcc,compOut,compErr,verbose_mode)
       if returncode != 0:
         msg = "Error in build step. See details in %s and %s\n"%(os.path.join(buildDir,compOut), os.path.join(buildDir,compErr))
         raise Exception(msg)
@@ -127,7 +134,7 @@ def __compileOldCommon(topSrcDir,pattern,config,envAcc,srcDir,topBuildDir,topIns
       return myInstallDir
     myCmd=[os.path.join(srcDir,"configure"),"--prefix=%s"%(myInstallDir)]+addCfgParam
     print "Command: ", " ".join(myCmd)
-    __compilePart1(myCmd,envAcc,myBuildDir)
+    __compilePart1(myCmd,envAcc,myBuildDir,config["verbose_mode"])
     __compilePart2(topSrcDir,pattern,config,envAcc,myBuildDir,splitInstall)
     return myInstallDir
 
@@ -143,6 +150,6 @@ def compileNew(topSrcDir,pattern,config,envAcc,srcDir,topBuildDir,topInstallDir,
       return myInstallDir
     myCmd=["cmake","-DCMAKE_INSTALL_PREFIX=%s"%(myInstallDir)]+addCfgParam+[srcDir]
     print(" ".join(myCmd))
-    __compilePart1(myCmd,envAcc,myBuildDir)
+    __compilePart1(myCmd,envAcc,myBuildDir,config["verbose_mode"])
     __compilePart2(topSrcDir,pattern,config,envAcc,myBuildDir,False)
     return myInstallDir