Salome HOME
nbtry 3 sleep 30 for git clone problems, and purgeEmptyNodes for tests xml
authorChristian Van Wambeke <christian.van-wambeke@cea.fr>
Mon, 17 Dec 2018 11:18:46 +0000 (12:18 +0100)
committerChristian Van Wambeke <christian.van-wambeke@cea.fr>
Mon, 17 Dec 2018 11:18:46 +0000 (12:18 +0100)
commands/config.py
commands/test.py
src/system.py

index d2fc640cec2c92c907c45e4d89a90c84351182f0..841596e4b6d6eabc16fced8a434702b18dc582b9 100644 (file)
@@ -217,7 +217,7 @@ class ConfigManager:
         # =====================================================================
         # create VARS section
         var = self._create_vars(application=application, command=command, datadir=datadir)
-        DBG.write("create_vars", var, DBG.isDeveloper())
+        DBG.write("create_vars", var, DBG.isDeveloper())
 
         # add VARS to config
         cfg.VARS = src.pyconf.Mapping(cfg)
index 06549f5bf39331c088dd028ff5a99016494a3777..2daf44f438ad846ddaff277da55b9c87bbe409b3 100644 (file)
@@ -268,6 +268,30 @@ def findOrCreateNode(parentNode, nameNodeToFind):
     else:
       return found
 
+def purgeEmptyNodes(root):
+    """
+    recursive remove node.text and node.tail if empty node
+    as nothing else than whitespace(s) and RCLF(s)
+
+    | this is comes from
+    | 1) pretty print file xml -> creates indentation(s) in text and tail
+    | 2) and reload parse file xml
+    """
+    # print("root", root.tag, root.text)
+    text = root.text
+    tail = root.tail
+    if text is not None:
+      if text.replace(" ", "").replace("\n", "") == "":
+        # print("purgeEmptyNodes text %s" % root.tag)
+        root.text = None
+    if tail is not None:
+      if tail.replace(" ", "").replace("\n", "") == "":
+        # print("purgeEmptyNodes tail %s" % root.tag)
+        root.tail = None
+    for node in root:
+      purgeEmptyNodes(node)
+    return
+
 ##
 # Creates the XML report for a product.
 def create_test_report(config,
@@ -293,6 +317,7 @@ def create_test_report(config,
     else:
         print("Log file modification %s" % xml_history_path)
         root = etree.parse(xml_history_path).getroot()
+        purgeEmptyNodes(root)
         prod_node = root.find("product")
 
 
@@ -337,7 +362,7 @@ def create_test_report(config,
         for testbase in tt.keys():
             if verbose: print("---- create_test_report %s %s" % (testbase, first_time))
             gn = findOrCreateNode(tests, "testbase")
-            
+
             # initialize all grids and session to "not executed"
             for mn in gn.findall("grid"):
                 mn.attrib["executed_last_time"] = "no"
index 46d7942c3c97cfe331676889b57a90cc665f465e..9d0f28556de2c4b72b98b6f12c3d3cba89d517fd 100644 (file)
@@ -21,8 +21,9 @@ In this file : all functions that do a system call,
 like open a browser or an editor, or call a git command
 '''
 
-import subprocess
 import os
+import subprocess
+import time
 import tarfile
 
 import debug as DBG
@@ -81,7 +82,7 @@ git clone %(remote)s %(where)s
 
     cmd = r"""
 set -x
-rmdir %(where)s && \
+rmdir %(where)s
 git clone %(remote)s %(where)s && \
 git --git-dir=%(where_git)s --work-tree=%(where)s checkout %(tag)s
 """
@@ -95,7 +96,12 @@ git --git-dir=%(where_git)s --work-tree=%(where)s checkout %(tag)s
   logger.logTxtFile.flush()
 
   DBG.write("cmd", cmd)
-  rc = UTS.Popen(cmd, cwd=str(where.dir()), env=environment.environ.environ, logger=logger)
+
+  for nbtry in range(0,3): # retries case of network problem
+    rc = UTS.Popen(cmd, cwd=str(where.dir()), env=environment.environ.environ, logger=logger)
+    if rc.isOk(): break
+    time.sleep(30) # wait a little
+
   return rc.isOk()
 
   """
@@ -143,7 +149,7 @@ def git_extract_sub_dir(from_what, tag, where, sub_dir, logger, environment=None
   cmd = r"""
 set -x
 export tmpDir=%(tmpWhere)s && \
-rm -rf $tmpDir && \
+rm -rf $tmpDir
 git clone %(remote)s $tmpDir && \
 cd $tmpDir && \
 git checkout %(tag)s && \
@@ -152,9 +158,13 @@ git log -1 > %(where)s/README_git_log.txt && \
 rm -rf $tmpDir
 """ % aDict
   DBG.write("cmd", cmd)
-  rc = UTS.Popen(cmd, cwd=parentWhere, env=environment.environ.environ, logger=logger)
-  return rc.isOk()
 
+  for nbtry in range(0,3): # retries case of network problem
+    rc = UTS.Popen(cmd, cwd=parentWhere, env=environment.environ.environ, logger=logger)
+    if rc.isOk(): break
+    time.sleep(30) # wait a little
+
+  return rc.isOk()
 
 def archive_extract(from_what, where, logger):
     '''Extracts sources from an archive.