Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added core.debug and env CM_CORE_SKIP_FIX_REPO_PATH #1293

Merged
merged 3 commits into from
Sep 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions cm/CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## V2.3.6.1
- added cmind.core.debug to make it easier to debug CM automations
- added env CM_CORE_SKIP_FIX_REPO_PATH to skip fixing non-existent repo paths

## V2.3.6
- fixed "cm init" on Windows (do not check wget and curl - managed via CM scripts)

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__ = "2.3.6"
__version__ = "2.3.6.1"

from cmind.core import access
from cmind.core import error
Expand Down
36 changes: 36 additions & 0 deletions cm/cmind/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -818,3 +818,39 @@ def get_version():
r['version'] = version

return r

##############################################################################
def debug(path_to_cm_automation_module):

import cmind

import os
automation = os.path.basename(os.path.dirname(path_to_cm_automation_module))

import sys
argv = sys.argv[1:]

# If run from VS, length == 1

# else normal argv

if len(argv) == 0:
cmd = 'test ' + automation
elif len(argv) == 1:
cmd = argv[0]

if ' ' not in cmd:
cmd += ' ' + automation
else:
space_index = cmd.find(' ')
cmd = cmd[:space_index] + ' ' + automation + ' ' + cmd[space_index+1:]
else:
cmd = argv
cmd.insert(1, automation)

print ('')
print ('Envoking CM command:')
print (f'{cmd}')

print ('')
return cmind.access(cmd)
19 changes: 11 additions & 8 deletions cm/cmind/repos.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,18 +154,21 @@ def load(self, init = False):
print ('WARNING: repository path {} not found (check file {})'.format(path_to_repo, full_path_to_repo_paths))

# Save with correct paths
if len(checked_self_paths)!=len(self.paths):
import copy
if len(checked_self_paths) != len(self.paths):

self.paths = copy.deepcopy(checked_self_paths)
skip_fix_paths = os.environ.get('CM_CORE_SKIP_FIX_REPO_PATH','').strip().lower()
if skip_fix_paths not in ['1', 'true', 'yes']:
import copy

if self.path_to_internal_repo in checked_self_paths:
checked_self_paths.remove(self.path_to_internal_repo)
self.paths = copy.deepcopy(checked_self_paths)

print ('WARNING: fixed repo list file {}'.format(full_path_to_repo_paths))
if self.path_to_internal_repo in checked_self_paths:
checked_self_paths.remove(self.path_to_internal_repo)

r = utils.save_json(full_path_to_repo_paths, meta = checked_self_paths)
if r['return']>0: return r
print ('WARNING: fixed repo list file {}'.format(full_path_to_repo_paths))

r = utils.save_json(full_path_to_repo_paths, meta = checked_self_paths)
if r['return']>0: return r

return {'return':0}

Expand Down
Loading