# # Collective Knowledge (preparing experiment reports) # # See CK LICENSE.txt for licensing details # See CK COPYRIGHT.txt for copyright details # # Developer: Grigori Fursin, Grigori.Fursin@cTuning.org, http://fursin.net # cfg={} # Will be updated by CK (meta description of this module) work={} # Will be updated by CK (temporal data) ck=None # Will be updated by CK (initialized CK kernel) # Local settings var_post_autorefresh='report_autorefresh' var_post_autorefresh_time='report_autorefresh_time' ############################################################################## # Initialize module def init(i): """ Input: {} Output: { return - return code = 0, if successful > 0, if error (error) - error text if return > 0 } """ return {'return':0} ############################################################################## # viewing entry as html def html_viewer(i): """ Input: { data_uoa url_base url_pull url_pull_tmp tmp_data_uoa url_wiki html_share form_name - current form name (all_params) } Output: { return - return code = 0, if successful > 0, if error (error) - error text if return > 0 } """ import os h='' st='' raw='no' top='yes' duoa=i['data_uoa'] burl=i['url_base'] purl=i['url_pull'] wurl=i.get('url_wiki','') tpurl=i['url_pull_tmp'] tpuoa=i['tmp_data_uoa'] ap=i.get('all_params',{}) ruoa=ap.get('ck_top_repo','') muoa=ap.get('ck_top_module','') cparams=ap.get('graph_params','') # current graph params hshare=i.get('html_share','') form_name=i['form_name'] form_submit='document.'+form_name+'.submit();' if duoa!='': # Load entry rx=ck.access({'action':'load', 'module_uoa':work['self_module_uid'], 'data_uoa':duoa}) if rx['return']>0: return rx pp=rx['path'] dd=rx['dict'] duid=rx['data_uid'] # Check what to do with top header if dd.get('top','')!='': top=dd['top'] # Check auto-refresh dar=dd.get('auto_refresh','') if dar=='yes': ar=ap.get(var_post_autorefresh,'') art=ap.get(var_post_autorefresh_time,'') iart=4 if art=='': art=dd.get('auto_refresh_time','') if art!='': try: iart=int(art) except ValueError: iart=4 ap[var_post_autorefresh_time]=iart if ar=='': ar='on' ap[var_post_autorefresh]=ar if ar=='on': h+='\n' h+='\n' h+='\n' if dd.get('live','')!='yes': raw='yes' else: title=dd.get('title','') sub_title=dd.get('sub_title','') authors=dd.get('authors',[]) affs=dd.get('affiliations',{}) cauthor=dd.get('cor_author_email','') mwc=dd.get('media_wiki_commands','') h+='
'
th+=l
# if not l.endswith('>'):
# th+='
'
th+='\n'
# Check CK access functions
h+=th
j=0
while j!=-1:
j=h.find('$#ck_access_start#$',j)
if j>=0:
j1=h.find('$#ck_access_stop#$',j)
if j1>=0:
json=h[j+19:j1].strip()
ha=''
# Convert json to python dict
rx=ck.convert_json_str_to_dict({'str':json, 'skip_quote_replacement':'yes'})
if rx['return']==0:
nii=rx['dict']
if nii.get('action','')!='':
# Here we process active CK plugin (if there is an "action") to generate content (even possibly from remote repo)
nii['base_url']=burl
rx=ck.access(nii)
if rx['return']==0:
ha=rx.get('html','')
if nii.get('remove_script_src','')=='yes':
k1=ha.find('', k1)
if k2>0:
ha=ha[:k1]+ha[k2+9:]
st+=rx.get('style','')
else:
ha+='\n
\nInternal error: '+rx['error']+'\n
\n'
h=h[:j]+ha+h[j1+18:]
j+=1
h+='