diff --git a/CHANGELOG.txt b/CHANGELOG.txt index c92bc34..a6c18c6 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -1,5 +1,7 @@ -* 0.7.21.1 - - started new development version +* 0.7.22 + - when publish components, take "license" and "copyright" from meta + - add 0755 to .sh files in archives (for program workflow) + - added possibility to push "dict" directly to CodeReef API * 0.7.21 - fixed problem with downloading CK components diff --git a/codereef/__init__.py b/codereef/__init__.py index 3e193d4..797958e 100644 --- a/codereef/__init__.py +++ b/codereef/__init__.py @@ -5,4 +5,4 @@ # Developer(s): Grigori Fursin, https://fursin.net # -__version__ = "0.7.21.1" +__version__ = "0.7.22" diff --git a/codereef/comm.py b/codereef/comm.py index ca60550..280eafd 100644 --- a/codereef/comm.py +++ b/codereef/comm.py @@ -161,7 +161,10 @@ def access(i): """ Input: { (filename) [str] - load JSON from this file + or (json) [str] - parse JSON string from command line (use ' instead of ") + or + (dict) [dict] - dictionary to send to the CodeReef API } Output: { @@ -170,14 +173,17 @@ def access(i): } """ + import json + filename=i.get('filename','') json_string=i.get('json','') - if filename=='' and json_string=='': - return {'return':1, 'error':'either "filename" or "json" should define results to be pushed'} + display=i.get('display','') + + data=i.get('dict',{}) - # Prepare data - data={} + if filename=='' and json_string=='' and len(data)==0: + return {'return':1, 'error':'either "filename" or "json" or "dict" should define data to be pushed to CodeReef API'} if filename!='': r=ck.load_json_file({'json_file':filename}) @@ -187,13 +193,13 @@ def access(i): data.update(data2) if json_string!='': - import json - json_string=json_string.replace("'", '"') data2=json.loads(json_string) data.update(data2) + if display=='': + display=False # Get current configuration r=config.load({}) @@ -207,10 +213,11 @@ def access(i): # Sending request to download r=send(ii) if r['return']>0: return r + + if display is True: + ck.out('Output:') + ck.out('') - ck.out('Output:') - ck.out('') - - ck.out(json.dumps(r, indent=2)) + ck.out(json.dumps(r, indent=2)) return r diff --git a/codereef/main.py b/codereef/main.py index 997a460..22df2a2 100644 --- a/codereef/main.py +++ b/codereef/main.py @@ -276,15 +276,19 @@ def push_result(uid, @click.option('-f', '--filename', 'filename', required=False, default='') @click.option('-j', '--json', 'json_string', required=False, default='') +@click.option('-m', '--mute', 'display', is_flag=True, default=True) + def access(filename, - json_string): + json_string, + display): ''' Access CodeReef Portal via JSON API. ''' from . import comm r=comm.access({'filename':filename, - 'json':json_string}) + 'json':json_string, + 'display': display}) if r['return']>0: process_error(r) return 0 diff --git a/codereef/obj.py b/codereef/obj.py index 3fbc3e1..0ab0e63 100644 --- a/codereef/obj.py +++ b/codereef/obj.py @@ -157,6 +157,12 @@ def publish(i): source2=data_meta.get('source','') if source2=='': source2=source + license2=data_meta.get('license','') + if license2=='': license2=license + + copyright2=data_meta.get('copyright','') + if copyright2=='': copyright2=copyright + # Specialize per specific modules not_digital_component=False extra_dict={} @@ -364,8 +370,8 @@ def publish(i): 'version':version, 'author':author, 'author_codereef_id':author_codereef_id, - 'copyright':copyright, - 'license':license, + 'copyright':copyright2, + 'license':license2, 'source':source2, 'not_digital_component':not_digital_component, 'extra_dict':extra_dict, @@ -598,20 +604,11 @@ def download(i): 'common_func':'yes', 'repo_uoa':repo_uoa, 'module_uoa':muid, - 'data_uoa':duid}) + 'data_uoa':duoa}) if r['return']==0: - path=r['path'] - if not force: return {'return':8, 'error':'local entry for "'+xcid+'" already exists'} - - # Find/create entry (as a placeholder for pack.zip) - r=ck.access({'action':'find', - 'common_func':'yes', - 'repo_uoa':repo_uoa, - 'module_uoa':muid, - 'data_uoa':duid}) - if r['return']>0: + else: if r['return']!=16: return r r=ck.access({'action':'add', @@ -667,6 +664,12 @@ def download(i): fo=open(pp, 'wb') fo.write(z.read(d)) fo.close() + + if pp.endswith('.sh') or pp.endswith('.bash'): + import os + st=os.stat(pp) + os.chmod('somefile', st.st_mode | stat.S_IEXEC) + f.close() # Remove pack file