Skip to content

Commit

Permalink
V3.3.2 (#1347)
Browse files Browse the repository at this point in the history
## V3.3.2
   - moved "CMX stack error" to -log
   - improved error reporting
  • Loading branch information
gfursin authored Nov 3, 2024
2 parents dfefc2a + 4f740f1 commit 03eb0b2
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 16 deletions.
7 changes: 7 additions & 0 deletions cm/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
## V3.3.3
- fixed CM logger issue

## 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
Expand Down
2 changes: 1 addition & 1 deletion cm/cmind/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#
# Written by Grigori Fursin

__version__ = "3.3.1"
__version__ = "3.3.3"

from cmind.core import access
from cmind.core import x
Expand Down
2 changes: 1 addition & 1 deletion cm/cmind/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 (--)}",

Expand Down
24 changes: 13 additions & 11 deletions cm/cmind/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ def __init__(self, repos_path = '', debug = False):

# Logging
self.logger = None
self.xlogger = None

# Index
self.index = None
Expand Down Expand Up @@ -172,17 +173,18 @@ 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")

sys.stderr.write('^'*60 + '\n')
# 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:
Expand All @@ -195,7 +197,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:]

Expand Down Expand Up @@ -295,7 +297,7 @@ def log(self, s, t = 'info'):
None
"""

logger = self.logger
logger = self.xlogger

if logger != None:
if t == 'debug':
Expand Down Expand Up @@ -903,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":
Expand All @@ -929,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)
Expand All @@ -942,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', '')
Expand All @@ -966,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
Expand Down Expand Up @@ -1341,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)
Expand Down
4 changes: 2 additions & 2 deletions cm/cmind/repo/automation/repo/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmind>=2.0.1
cmind>=3.3.3
pyyaml
requests
setuptools
Expand Down

0 comments on commit 03eb0b2

Please sign in to comment.