From 675140c045072331380fb7372888b1c7c7e418bc Mon Sep 17 00:00:00 2001 From: Grigori Fursin Date: Sun, 3 Nov 2024 10:58:28 +0100 Subject: [PATCH 1/3] V3.3.2: - moved "CMX stack error" to -log - improved error reporting --- cm/CHANGES.md | 4 ++++ cm/cmind/__init__.py | 2 +- cm/cmind/config.py | 2 +- cm/cmind/core.py | 12 +++++++----- 4 files changed, 13 insertions(+), 7 deletions(-) diff --git a/cm/CHANGES.md b/cm/CHANGES.md index 1c97cbdde..ba8408293 100644 --- a/cm/CHANGES.md +++ b/cm/CHANGES.md @@ -1,3 +1,7 @@ +## V3.3.2 + - moved "CMX stack error" to -log + - improved error reporting + ## V3.3.1 - allow "cm/cmx pull repo {URL}" along with "cm/cmx pull repo --url={URL}" - CMX: added "automation_full_path" to -log diff --git a/cm/cmind/__init__.py b/cm/cmind/__init__.py index 9c7cd38d3..f73f15bf2 100644 --- a/cm/cmind/__init__.py +++ b/cm/cmind/__init__.py @@ -2,7 +2,7 @@ # # Written by Grigori Fursin -__version__ = "3.3.1" +__version__ = "3.3.2" from cmind.core import access from cmind.core import x diff --git a/cm/cmind/config.py b/cm/cmind/config.py index 7b5644224..407160190 100644 --- a/cm/cmind/config.py +++ b/cm/cmind/config.py @@ -37,7 +37,7 @@ def __init__(self, config_file = None): "flag_help2": "help", "error_prefix": "CM error:", - "error_prefix2": "CMX detected an issue", + "error_prefix2": "CMX detected a problem", "info_cli": "cm {action} {automation} {artifact(s)} {flags} @input.yaml @input.json", "info_clix": "cmx {action} {automation} {artifact(s)} {CMX control flags (-)} {CMX automation flags (--)}", diff --git a/cm/cmind/core.py b/cm/cmind/core.py index 3e5611394..44621f116 100644 --- a/cm/cmind/core.py +++ b/cm/cmind/core.py @@ -180,7 +180,8 @@ def errorx(self, r): self.log(f"x error call stack: {call_stack}", "debug") self.log(f"x error: {r}", "debug") - sys.stderr.write('^'*60 + '\n') +# sys.stderr.write('^'*60 + '\n') + sys.stderr.write('\n') if not self.logger == None: sys.stderr.write('CMX call stack:\n') @@ -195,7 +196,7 @@ def errorx(self, r): message += self.cfg['error_prefix2'] if module_path != '' and lineno !='': - message += f' in {module_path} ({lineno}):\n\n' + message += f' while running automation {module_path} ({lineno}):\n\n' text = r['error'] text = text[0].upper() + text[1:] @@ -352,9 +353,10 @@ def access(self, i, out = None): if self.cfg['flag_debug'] in i: self.debug = True - # Check if log - if self.logger is None: - self.logger = logging.getLogger("cm") +# Not used in CM but used in CMX +# # Check if log +# if self.logger is None: +# self.logger = logging.getLogger("cm") # Parse as command line if string or list if type(i) == str or type(i) == list: From 1ed4c442ecbab12f265bc934eca3e09ae9ce3551 Mon Sep 17 00:00:00 2001 From: Grigori Fursin Date: Sun, 3 Nov 2024 11:20:22 +0100 Subject: [PATCH 2/3] fixed CM logger issue --- cm/CHANGES.md | 3 +++ cm/cmind/__init__.py | 2 +- cm/cmind/core.py | 26 ++++++++++++------------- cm/cmind/repo/automation/repo/module.py | 4 ++-- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/cm/CHANGES.md b/cm/CHANGES.md index ba8408293..b7132c6c1 100644 --- a/cm/CHANGES.md +++ b/cm/CHANGES.md @@ -1,3 +1,6 @@ +## V3.3.3 + - fixed CM logger issue + ## V3.3.2 - moved "CMX stack error" to -log - improved error reporting diff --git a/cm/cmind/__init__.py b/cm/cmind/__init__.py index f73f15bf2..441a1eaf1 100644 --- a/cm/cmind/__init__.py +++ b/cm/cmind/__init__.py @@ -2,7 +2,7 @@ # # Written by Grigori Fursin -__version__ = "3.3.2" +__version__ = "3.3.3" from cmind.core import access from cmind.core import x diff --git a/cm/cmind/core.py b/cm/cmind/core.py index 44621f116..6c6327b09 100644 --- a/cm/cmind/core.py +++ b/cm/cmind/core.py @@ -103,6 +103,7 @@ def __init__(self, repos_path = '', debug = False): # Logging self.logger = None + self.xlogger = None # Index self.index = None @@ -172,10 +173,10 @@ def errorx(self, r): message = '' - if not self.logger == None or (module_path != '' and lineno != ''): + if not self.xlogger == None or (module_path != '' and lineno != ''): call_stack = self.state.get('call_stack', []) - if not self.logger == None: + if not self.xlogger == None: self.log(f"x error call stack: {call_stack}", "debug") self.log(f"x error: {r}", "debug") @@ -183,7 +184,7 @@ def errorx(self, r): # sys.stderr.write('^'*60 + '\n') sys.stderr.write('\n') - if not self.logger == None: + if not self.xlogger == None: sys.stderr.write('CMX call stack:\n') for cs in call_stack: @@ -296,7 +297,7 @@ def log(self, s, t = 'info'): None """ - logger = self.logger + logger = self.xlogger if logger != None: if t == 'debug': @@ -353,10 +354,9 @@ def access(self, i, out = None): if self.cfg['flag_debug'] in i: self.debug = True -# Not used in CM but used in CMX -# # Check if log -# if self.logger is None: -# self.logger = logging.getLogger("cm") + # Check if log + if self.logger is None: + self.logger = logging.getLogger("cm") # Parse as command line if string or list if type(i) == str or type(i) == list: @@ -905,7 +905,7 @@ def x(self, i, out = None): meta = ii) # Check logging - if self.logger is None: + if self.xlogger is None: log_level = None if use_log == "false": @@ -931,7 +931,7 @@ def x(self, i, out = None): log_level = logging.INFO # Configure - self.logger = logging.getLogger("cmx") + self.xlogger = logging.getLogger("cmx") logging.basicConfig(filename = log_file, filemode = 'w', level = log_level) # Check if force out programmatically (such as from CLI) @@ -944,7 +944,7 @@ def x(self, i, out = None): recursion = self.state.get('recursion', 0) self.state['recursion'] = recursion + 1 - if not self.logger == None: + if not self.xlogger == None: log_action = i.get('action', '') log_automation = i.get('automation', '') log_artifact = i.get('artifact', '') @@ -968,7 +968,7 @@ def x(self, i, out = None): r['return'] = 1 r['error'] = delayed_error - if not self.logger == None: + if not self.xlogger == None: self.log(f"x output: {r}", "debug") self.state['recursion'] = recursion @@ -1343,7 +1343,7 @@ def _x(self, i, control): loaded_common_automation = True # Finalize automation class initialization - if not self.logger == None: + if not self.xlogger == None: self.log(f"x automation_full_path: {automation_full_path}", "info") initialized_automation = loaded_automation_class(self, automation_full_path) diff --git a/cm/cmind/repo/automation/repo/module.py b/cm/cmind/repo/automation/repo/module.py index 3e2711f51..eae2345a9 100644 --- a/cm/cmind/repo/automation/repo/module.py +++ b/cm/cmind/repo/automation/repo/module.py @@ -162,8 +162,8 @@ def pull(self, i): warnings = [] - if not self.cmind.logger == None: - self.cmind.log(f"x repo log: {pull_repos}", "debug") +# if not self.cmind.xlogger == None: +# self.cmind.log(f"x repo log: {pull_repos}", "debug") for repo in pull_repos: alias = repo['alias'] From 4f740f18403ba19b7b83809445111698196ed2dd Mon Sep 17 00:00:00 2001 From: Grigori Fursin Date: Sun, 3 Nov 2024 11:25:55 +0100 Subject: [PATCH 3/3] clean up --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index 4752077a6..f0e34ec5e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -cmind>=2.0.1 +cmind>=3.3.3 pyyaml requests setuptools