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

refactor: replace print wih logging #89

Closed
wants to merge 4 commits into from
Closed
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
20 changes: 10 additions & 10 deletions automation/cache/module.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os

import logging
from cmind.automation import Automation
from cmind import utils

Expand Down Expand Up @@ -47,7 +47,7 @@ def test(self, i):
"""

import json
print (json.dumps(i, indent=2))
logging.info(json.dumps(i, indent=2))

return {'return':0}

Expand Down Expand Up @@ -121,12 +121,12 @@ def show(self, i):
version = meta.get('version','')

if console:
print ('')
logging.info ('')
# print ('* UID: {}'.format(uid))
print ('* Tags: {}'.format(','.join(tags)))
print (' Path: {}'.format(path))
logging.info ('* Tags: {}'.format(','.join(tags)))
logging.info (' Path: {}'.format(path))
if version!='':
print (' Version: {}'.format(version))
logging.info (' Version: {}'.format(version))

if show_env and console:
path_to_cached_state_file = os.path.join(path, 'cm-cached-state.json')
Expand All @@ -140,13 +140,13 @@ def show(self, i):

new_env = cached_state.get('new_env', {})
if len(new_env)>0:
print (' New env:')
print (json.dumps(new_env, indent=6, sort_keys=True).replace('{','').replace('}',''))
logging.info (' New env:')
logging.info (json.dumps(new_env, indent=6, sort_keys=True).replace('{','').replace('}',''))

new_state = cached_state.get('new_state', {})
if len(new_state)>0:
print (' New state:')
print (json.dumps(new_env, indent=6, sort_keys=True))
logging.info (' New state:')
logging.info (json.dumps(new_env, indent=6, sort_keys=True))

return {'return':0, 'list': lst}

Expand Down
9 changes: 5 additions & 4 deletions automation/cache/module_misc.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import logging
from cmind import utils


Expand Down Expand Up @@ -54,9 +55,9 @@ def copy_to_remote(i):
if len(r['list']) == 0:
pass #fixme
elif len(r['list']) > 1:
print("Multiple cache entries found: ")
logging.warning("Multiple cache entries found: ")
for k in sorted(r['list'], key = lambda x: x.meta.get('alias','')):
print(k.path)
logging.info(k.path)
x = input("Would you like to copy them all? Y/n: ")
if x.lower() == 'n':
return {'return': 0}
Expand All @@ -68,7 +69,7 @@ def copy_to_remote(i):
cacheid = os.path.basename(path)

copy_cmd = f"rsync -avz --exclude cm-cached-state.json -e 'ssh -p {remote_port}' {path} {remote_user}@{remote_host}:{remote_cm_cache_location}"
print(copy_cmd)
logging.info(copy_cmd)
os.system(copy_cmd)

cm_cached_state_json_file = os.path.join(path, "cm-cached-state.json")
Expand All @@ -92,7 +93,7 @@ def copy_to_remote(i):

remote_cached_state_file_location = os.path.join(remote_cm_cache_location, cacheid, "cm-cached-state.json")
copy_cmd = f"rsync -avz -e 'ssh -p {remote_port}' tmp_remote_cached_state.json {remote_user}@{remote_host}:{remote_cached_state_file_location}"
print(copy_cmd)
logging.info(copy_cmd)
os.system(copy_cmd)

return {'return':0}
10 changes: 5 additions & 5 deletions automation/cfg/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
# Written by Grigori Fursin

import os

import logging
from cmind.automation import Automation
from cmind import utils

Expand Down Expand Up @@ -51,7 +51,7 @@ def test(self, i):
"""

import json
print (json.dumps(i, indent=2))
logging.info (json.dumps(i, indent=2))

return {'return':0}

Expand Down Expand Up @@ -124,9 +124,9 @@ def check_to_delete(d):
if r['return']>0: return r

# Print config
print ('Config:')
print ('')
print (json.dumps(config, indent=2))
logging.info ('Config:')
logging.info ('')
logging.info (json.dumps(config, indent=2))

return {'return':0}

Expand Down
4 changes: 2 additions & 2 deletions automation/challenge/module.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os

import logging
from cmind.automation import Automation
from cmind import utils

Expand Down Expand Up @@ -47,6 +47,6 @@ def test(self, i):
"""

import json
print (json.dumps(i, indent=2))
logging.info (json.dumps(i, indent=2))

return {'return':0}
24 changes: 12 additions & 12 deletions automation/contributor/module.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os

import logging
from cmind.automation import Automation
from cmind import utils

Expand Down Expand Up @@ -47,7 +47,7 @@ def test(self, i):
"""

import json
print (json.dumps(i, indent=2))
logging.info (json.dumps(i, indent=2))

return {'return':0}

Expand Down Expand Up @@ -131,7 +131,7 @@ def add(self, i):

i['meta'] = meta

print ('')
logging.info ('')

r = self.cmind.access(i)
if r['return']>0: return r
Expand All @@ -140,14 +140,14 @@ def add(self, i):

path2 = os.path.dirname(path)

print ('')
print ('Please go to {}, add your directory to Git, commit and create PR:'.format(path2))
print ('')
print ('cd {}'.format(path2))
print ('git add "{}"'.format(name))
print ('git commit "{}"'.format(name))
print ('')
print ('Please join https://discord.gg/JjWNWXKxwT to discuss challenges!')
print ('Looking forward to your contributions!')
logging.info ('')
logging.info ('Please go to {}, add your directory to Git, commit and create PR:'.format(path2))
logging.info ('')
logging.info ('cd {}'.format(path2))
logging.info ('git add "{}"'.format(name))
logging.info ('git commit "{}"'.format(name))
logging.info ('')
logging.info ('Please join https://discord.gg/JjWNWXKxwT to discuss challenges!')
logging.info ('Looking forward to your contributions!')

return r
4 changes: 2 additions & 2 deletions automation/data/module.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os

import logging
from cmind.automation import Automation
from cmind import utils

Expand Down Expand Up @@ -47,6 +47,6 @@ def test(self, i):
"""

import json
print (json.dumps(i, indent=2))
logging.info (json.dumps(i, indent=2))

return {'return':0}
4 changes: 2 additions & 2 deletions automation/docker/module.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os

import logging
from cmind.automation import Automation
from cmind import utils

Expand Down Expand Up @@ -46,6 +46,6 @@ def test(self, i):
"""

import json
print (json.dumps(i, indent=2))
logging.info (json.dumps(i, indent=2))

return {'return':0}
4 changes: 2 additions & 2 deletions automation/docs/module.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import os

import logging
from cmind.automation import Automation
from cmind import utils

Expand Down Expand Up @@ -47,6 +47,6 @@ def test(self, i):
"""

import json
print (json.dumps(i, indent=2))
logging.info (json.dumps(i, indent=2))

return {'return':0}
Loading
Loading