From: Christian Van Wambeke Date: Wed, 9 May 2018 11:16:14 +0000 (+0200) Subject: fix isatty andtry src/pyconf_0_3_9_1.py TODO to fix 'Circular reference' X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1c27bc50121225d8483a6ab87b39c3208de68c83;p=tools%2Fsat.git fix isatty andtry src/pyconf_0_3_9_1.py TODO to fix 'Circular reference' --- diff --git a/commands/application.py b/commands/application.py index a53b730..d94271b 100644 --- a/commands/application.py +++ b/commands/application.py @@ -26,7 +26,7 @@ import os import getpass import subprocess -import src.ElementTree as ET +import src.ElementTree as ETREE import src.debug as DBG import src.returnCode as RCO import src.utilsSat as UTS @@ -276,7 +276,7 @@ def customize_app(config, appli_dir, logger): def add_simple_node(parent, node_name, text=None): """shortcut method to create a node""" - n = etree.Element(node_name) + n = ETREE.Element(node_name) if text is not None: try: n.text = text.strip("\n\t").decode("UTF-8") @@ -289,7 +289,7 @@ def customize_app(config, appli_dir, logger): # read the app file app_file = os.path.join(appli_dir, "SalomeApp.xml") - tree = etree.parse(app_file) + tree = ETREE.parse(app_file) document = tree.getroot() assert document is not None, "document tag not found" @@ -307,7 +307,7 @@ def customize_app(config, appli_dir, logger): # write the file f = open(app_file, "w") f.write("\n") - f.write(etree.tostring(document, encoding='utf-8')) + f.write(ETREE.tostring(document, encoding='utf-8')) f.close() def generate_application(config, appli_dir, config_file, logger): diff --git a/commands/config.py b/commands/config.py index 2d29ff7..d4e8e12 100644 --- a/commands/config.py +++ b/commands/config.py @@ -108,15 +108,18 @@ If a name is given the new config file takes the given name.""")) if options.value: if options.value == ".": # if argument is ".", print all the config + msg = "" for val in sorted(config.keys()): - CFGMGR.print_value(config, val, logger, not options.no_label) + msg += CFGMGR.getStrConfigValue(config, val, not options.no_label) else: - CFGMGR.print_value(config, options.value, logger, not options.no_label, - level=0, show_full_path=False) + msg = CFGMGR.getStrConfigValue(config, options.value, not options.no_label, + level=0, show_full_path=False) + logger.info(msg) if options.debug: - CFGMGR.print_debug(config, str(options.debug), logger, not options.no_label, - level=0, show_full_path=False) + msg = CFGMGR.getStrConfigDebug(config, str(options.debug), not options.no_label, + level=0, show_full_path=False) + logger.info(msg) # case : edit user pyconf file or application file elif options.edit: diff --git a/commands/find_duplicates.py b/commands/find_duplicates.py index 71d8fa3..cb237a9 100644 --- a/commands/find_duplicates.py +++ b/commands/find_duplicates.py @@ -282,7 +282,7 @@ class Progress_bar: self.length = length self.logger = logger if (self.valMax - self.valMin) <= 0 or length <= 0: - out_err = _('ERROR: Wrong init values for the progress bar\n') + out_err = _('Wrong init values for the progress bar\n') raise Exception(out_err) def display_value_progression(self,val): diff --git a/commands/generate.py b/commands/generate.py index 9a4e855..6a35475 100644 --- a/commands/generate.py +++ b/commands/generate.py @@ -125,7 +125,6 @@ class Command(_BaseCommand): result = str(exc) if result != RCO._OK_STATUS: - result = _("ERROR: %s") % result details.append([product, result]) if len(details) != 0: diff --git a/commands/jobs.py b/commands/jobs.py index 29a09e0..7fdfbc1 100644 --- a/commands/jobs.py +++ b/commands/jobs.py @@ -28,7 +28,7 @@ import re # import paramiko later -import src.ElementTree as etree +import src.ElementTree as ETREE import src.debug as DBG import src.returnCode as RCO import src.utilsSat as UTS @@ -1510,7 +1510,7 @@ class Gui(object): Get all the first information needed for each file and write the first version of the files - :param xml_node_jobs: (etree.Element) + :param xml_node_jobs: (ETREE.Element) the node corresponding to a job :param l_jobs_not_today: (list) the list of jobs that do not run today @@ -1712,7 +1712,7 @@ class Gui(object): oExpr = re.compile(regex) if dirname == "TEST" and oExpr.search(file_name): # find the res of the command - prod_node = etree.parse(file_path).getroot().find("product") + prod_node = ETREE.parse(file_path).getroot().find("product") res_test = prod_node.attrib["global_res"] # find the number of fails testbase_node = prod_node.find("tests").find("testbase") diff --git a/commands/test.py b/commands/test.py index e614f64..e20a8f1 100644 --- a/commands/test.py +++ b/commands/test.py @@ -27,7 +27,7 @@ import src.debug as DBG import src.returnCode as RCO import src.utilsSat as UTS from src.salomeTools import _BaseCommand -import src.ElementTree as etree +import src.ElementTree as ETREE import src.xmlManager as XMLMGR import src.architecture as ARCH import src.test_module as TMOD @@ -437,7 +437,7 @@ def create_test_report(config, Creates the XML report for a product. """ ASNODE = XMLMGR.add_simple_node # shortcut - ETELEM = etree.Element # shortcut + ETELEM = ETREE.Element # shortcut # get the date and hour of the launching of the command, in order to keep # history @@ -454,7 +454,7 @@ def create_test_report(config, prod_node = ETELEM("product", name=application_name, build=xmlname) root.append(prod_node) else: - root = etree.parse(xml_history_path).getroot() + root = ETREE.parse(xml_history_path).getroot() prod_node = root.find("product") prod_node.attrib["history_file"] = os.path.basename(xml_history_path) diff --git a/src/colorama/ansitowin32.py b/src/colorama/ansitowin32.py index b7ff6f2..ca3c0db 100644 --- a/src/colorama/ansitowin32.py +++ b/src/colorama/ansitowin32.py @@ -12,13 +12,15 @@ winterm = None if windll is not None: winterm = WinTerm() - def is_stream_closed(stream): return not hasattr(stream, 'closed') or stream.closed def is_a_tty(stream): - return hasattr(stream, 'isatty') and stream.isatty() + res = hasattr(stream, 'isatty') and stream.isatty() + # import src.debug as DBG # avoid cross import + # DBG.write("is_a_tty %s" % type(stream), res, True) + return res class StreamWrapper(object): diff --git a/src/coloringSat.py b/src/coloringSat.py index 721adc9..5bc87c6 100755 --- a/src/coloringSat.py +++ b/src/coloringSat.py @@ -55,6 +55,8 @@ from colorama import Style as ST #from colorama import AnsiToWin32 from colorama import AnsiToWin32 # debug is os.name == 'nt' ? +verbose = False + CLRM.init(wrap=False) # choose NO wrapping """ @@ -93,30 +95,10 @@ _tags = ( ("", FG.RED + ST.BRIGHT + "KO" + ST.RESET_ALL), ) -# _tagsNone = ((i, "") for i,j in _tags) # to clean tags when log not tty +# _tagsNone = ( (i, "") for i,j in _tags ) # to clean tags when log not tty # reversed order matters for item replaces backward to no color -_tagsNone = reversed( ( - ("", ""), - ("", ""), - ("", ""), - ("", ""), - ("", ""), - ("", ""), - ("", ""), - ("", ""), - ("", ""), - ("", ""), - ("", ""), - ("", ""), - ("
", ""), - ("