From 700aa156726d450fc457807ef7752a1f31bc57f3 Mon Sep 17 00:00:00 2001 From: Christian Van Wambeke Date: Mon, 17 Dec 2018 12:18:46 +0100 Subject: [PATCH] nbtry 3 sleep 30 for git clone problems, and purgeEmptyNodes for tests xml --- commands/config.py | 2 +- commands/test.py | 27 ++++++++++++++++++++++++++- src/system.py | 22 ++++++++++++++++------ 3 files changed, 43 insertions(+), 8 deletions(-) diff --git a/commands/config.py b/commands/config.py index d2fc640..841596e 100644 --- a/commands/config.py +++ b/commands/config.py @@ -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) diff --git a/commands/test.py b/commands/test.py index 06549f5..2daf44f 100644 --- a/commands/test.py +++ b/commands/test.py @@ -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" diff --git a/src/system.py b/src/system.py index 46d7942..9d0f285 100644 --- a/src/system.py +++ b/src/system.py @@ -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. -- 2.30.2