Skip to content

Commit

Permalink
Merge pull request #20 from code-reef/master
Browse files Browse the repository at this point in the history
several fixes for v0.7.22
  • Loading branch information
gfursin authored Mar 11, 2020
2 parents e4bccbf + a36a3ca commit af9218e
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 28 deletions.
6 changes: 4 additions & 2 deletions CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion codereef/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
# Developer(s): Grigori Fursin, https://fursin.net
#

__version__ = "0.7.21.1"
__version__ = "0.7.22"
27 changes: 17 additions & 10 deletions codereef/comm.py
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand All @@ -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})
Expand All @@ -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({})
Expand All @@ -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
8 changes: 6 additions & 2 deletions codereef/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
29 changes: 16 additions & 13 deletions codereef/obj.py
Original file line number Diff line number Diff line change
Expand Up @@ -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={}
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit af9218e

Please sign in to comment.