Commit 7ffb6bae authored by Nathalie Rousse's avatar Nathalie Rousse
Browse files

- improving error case in vle_run (stderr.txt file management).

- updating docs/vpzpages (adding vle version, deleting pattern case).
- documentation
parent dfc68266
=========================================================== =======================================================
erecord, record platform web development for vle-1.1 models erecord, record platform web development for vle models
=========================================================== =======================================================
The erecord project is dedicated to the Record platform web development for The erecord project is dedicated to the Record platform web development for
vle-1.1 models. vle models of several vle versions (vle-1.1, vle-2...).
Content hierarchy : docs, repositories, erecord (the erecord package), Content hierarchy : docs, repositories, erecord (the erecord package),
databases, factory... databases, factory...
See __init__.py files, docs directory. See __init__.py files, docs directory.
Note : in this vle-x development of erecord, erecord is intended to accept models of several vle versions (vle-1.1, vle-2...).
...@@ -12,7 +12,7 @@ Introduction ...@@ -12,7 +12,7 @@ Introduction
:term:`INRA`. :term:`INRA`.
The :ref:`erecord project <erecord_project>` is dedicated to the Record The :ref:`erecord project <erecord_project>` is dedicated to the Record
platform web development for vle-1.1 models. platform web development for vle models.
The erecord package is part of the erecord project. It contains the production The erecord package is part of the erecord project. It contains the production
(source code, tests...). (source code, tests...).
......
...@@ -12,7 +12,7 @@ Introduction ...@@ -12,7 +12,7 @@ Introduction
:term:`INRA`. :term:`INRA`.
The erecord project is dedicated to the Record platform web development for The erecord project is dedicated to the Record platform web development for
vle-1.1 models. vle models.
To access the erecord source code see : :ref:`erecord_software_project`. To access the erecord source code see : :ref:`erecord_software_project`.
......
...@@ -9,10 +9,9 @@ Domain introduction ...@@ -9,10 +9,9 @@ Domain introduction
multi-modeling and simulation platform. And so the agronomic models of the multi-modeling and simulation platform. And so the agronomic models of the
Record platform are some vle models. Record platform are some vle models.
The erecord project is dedicated to the Record platform web development, The erecord project is dedicated to the Record platform web development, for
concerning more specifically its models developed with the vle-1.1 version of its models developed with Vle. The web services provided by erecord allow to
Vle. The web services provided by erecord allow to edit, modify and simulate edit, modify and simulate some vle models, such as the Record platform ones.
some vle models, such as the Record platform ones.
The objects of the domain described by the erecord project call on concepts The objects of the domain described by the erecord project call on concepts
from Vle *(package, vpz...)*. But they can as well be given other names, from Vle *(package, vpz...)*. But they can as well be given other names,
......
...@@ -7,8 +7,8 @@ FAQs about agronomic models ...@@ -7,8 +7,8 @@ FAQs about agronomic models
Can erecord web services be used for any agronomic model ? Can erecord web services be used for any agronomic model ?
---------------------------------------------------------- ----------------------------------------------------------
- The agronomic model has to be an operational model developed with - The agronomic model has to be an operational model developed with one of
**vle-1.1** version of vle. the supported versions of vle, such as : **vle-1.1.3**, **vle-2.0.0**.
- The agronomic model software will have to be previously installed on the - The agronomic model software will have to be previously installed on the
erecord server (see an erecord server (see an
......
...@@ -9,8 +9,8 @@ Glossary ...@@ -9,8 +9,8 @@ Glossary
erecord project erecord project
The erecord project is dedicated to the :term:`Record` platform web The erecord project is dedicated to the :term:`Record` platform web
development for :term:`vle model` s (vle-1.1 version). See development for :term:`vle model` s of several vle versions (vle-1.1,
:ref:`erecord_project`. vle-2...). See :ref:`erecord_project`.
erecord package erecord package
The erecord package is part of the erecord project. It is a python The erecord package is part of the erecord project. It is a python
......
...@@ -7,10 +7,9 @@ erecord ...@@ -7,10 +7,9 @@ erecord
======= =======
The erecord project is dedicated to the :term:`Record` platform web The erecord project is dedicated to the :term:`Record` platform web
development, concerning more specifically its models developed with the development, for its models developed with :term:`Vle`.
vle-1.1 version of :term:`Vle`. The web services provided by erecord allow The web services provided by erecord allow to edit, modify and simulate
to edit, modify and simulate some vle models, such as the Record platform some vle models, such as the Record platform ones.
ones.
Quick overview Quick overview
============== ==============
......
...@@ -2,12 +2,11 @@ ...@@ -2,12 +2,11 @@
############################################################################### ###############################################################################
# #
# Builds html home and pattern pages for simulators of erecord # Builds html home pages for simulators of erecord
# #
# if folder sys.argv[1] exists then html pages are generated into it, # if folder sys.argv[1] exists then html pages are generated into it,
# else folder gen_vpzpages created and html pages are generated into it : # else folder gen_vpzpages created and html pages are generated into it :
# --> html home pages under gen/homes # html home pages under gen/homes
# --> html pattern pages under gen/patterns
# #
# run : see "cleanvpzpages" and "genvpzpages" rules into ../Makefile # run : see "cleanvpzpages" and "genvpzpages" rules into ../Makefile
############################################################################### ###############################################################################
...@@ -24,7 +23,6 @@ if "erecordroot" in os.environ.keys() : ...@@ -24,7 +23,6 @@ if "erecordroot" in os.environ.keys() :
erecordroot = os.environ["erecordroot"] erecordroot = os.environ["erecordroot"]
apps_home = os.path.normpath(os.path.join(erecordroot, apps_home = os.path.normpath(os.path.join(erecordroot,
"erecord", "erecord", "apps")) "erecord", "erecord", "apps"))
if apps_home not in sys.path : if apps_home not in sys.path :
sys.path.insert(0, apps_home) sys.path.insert(0, apps_home)
...@@ -33,6 +31,9 @@ from erecord_cmn.utils.dir_and_file import create_dir_if_absent ...@@ -33,6 +31,9 @@ from erecord_cmn.utils.dir_and_file import create_dir_if_absent
from erecord_cmn.utils.using.send_get_and_receive import send_get_and_receive from erecord_cmn.utils.using.send_get_and_receive import send_get_and_receive
from erecord_cmn.utils.using.send_post_and_receive import send_post_and_receive from erecord_cmn.utils.using.send_post_and_receive import send_post_and_receive
#base_url = "http://erecord.toulouse.inra.fr:8000/"
base_url = "http://127.0.0.1:8000/"
############################################################################### ###############################################################################
# in relation with db/vpz resource # in relation with db/vpz resource
...@@ -49,6 +50,9 @@ def content_vpz_tree(vlevpz): ...@@ -49,6 +50,9 @@ def content_vpz_tree(vlevpz):
vlerep = vlepkg['vlerep'] vlerep = vlepkg['vlerep']
rep_name = vlerep['name'] rep_name = vlerep['name']
rep_id = vlerep['id'] rep_id = vlerep['id']
vleversion = vlerep['vleversion']
version_name = vleversion['name']
version_id = vleversion['id']
comment= "\n" comment= "\n"
comment=comment+ 'Simulateur : ' + "\n" comment=comment+ 'Simulateur : ' + "\n"
...@@ -60,9 +64,13 @@ def content_vpz_tree(vlevpz): ...@@ -60,9 +64,13 @@ def content_vpz_tree(vlevpz):
comment=comment+ 'Depot de modeles : ' + "\n" comment=comment+ 'Depot de modeles : ' + "\n"
comment=comment+ ' - name : ' + rep_name + "\n" comment=comment+ ' - name : ' + rep_name + "\n"
comment=comment+ ' - verbose_name : ' + vlerep['verbose_name'] + "\n" comment=comment+ ' - verbose_name : ' + vlerep['verbose_name'] + "\n"
comment=comment+ 'Version vle : ' + "\n"
comment=comment+ ' - name : ' + version_name + "\n"
comment=comment+ ' - verbose_name : ' + vleversion['verbose_name'] + "\n"
comment=comment+ "\n" comment=comment+ "\n"
return (rep_name, pkg_name, vpz_name, rep_id, pkg_id, vpz_id, comment) return (version_name, rep_name, pkg_name, vpz_name,
version_id, rep_id, pkg_id, vpz_id, comment)
############################################################################### ###############################################################################
# in relation with vpz/input resource # in relation with vpz/input resource
...@@ -150,15 +158,19 @@ def content_simulation_inputs_tree(vpzinput): ...@@ -150,15 +158,19 @@ def content_simulation_inputs_tree(vpzinput):
############################################################################### ###############################################################################
# misc # misc
def get_home_file_name(homepath, rep_name, pkg_name, vpz_name, to_create=True) : def get_home_file_name(homepath, version_name, rep_name, pkg_name, vpz_name,
to_create=True) :
version_name = version_name.replace("/","__")
rep_name = rep_name.replace("/","__") rep_name = rep_name.replace("/","__")
pkg_name = pkg_name.replace("/","__") pkg_name = pkg_name.replace("/","__")
vpz_name = vpz_name.replace("/","__") vpz_name = vpz_name.replace("/","__")
reppath = os.path.join(homepath, rep_name) versionpath = os.path.join(homepath, version_name)
reppath = os.path.join(versionpath, rep_name)
pkgpath = os.path.join(reppath, pkg_name) pkgpath = os.path.join(reppath, pkg_name)
vpzpath = os.path.join(pkgpath, vpz_name) vpzpath = os.path.join(pkgpath, vpz_name)
if to_create : if to_create :
create_dir_if_absent(versionpath)
create_dir_if_absent(reppath) create_dir_if_absent(reppath)
create_dir_if_absent(pkgpath) create_dir_if_absent(pkgpath)
create_dir_if_absent(vpzpath) create_dir_if_absent(vpzpath)
...@@ -166,22 +178,15 @@ def get_home_file_name(homepath, rep_name, pkg_name, vpz_name, to_create=True) : ...@@ -166,22 +178,15 @@ def get_home_file_name(homepath, rep_name, pkg_name, vpz_name, to_create=True) :
file_name = os.path.join(vpzpath, file_name) file_name = os.path.join(vpzpath, file_name)
return file_name return file_name
def get_pattern_file_name(patternpath, rep_name, pkg_name, vpz_name) :
file_name = rep_name +"___"+ pkg_name +"___"+ vpz_name +"___accueil.html"
file_name = file_name.replace("/","__")
file_name = os.path.join(patternpath, file_name)
return file_name
# returns full (unique) name of a simulator # returns full (unique) name of a simulator
def get_full_name(rep_name, pkg_name, vpz_name) : def get_full_name(version_name, rep_name, pkg_name, vpz_name) :
return (rep_name +' / '+pkg_name+' / '+ vpz_name) return (version_name +' / '+rep_name +' / '+pkg_name+' / '+ vpz_name)
############################################################################### ###############################################################################
# html code text # html code text
def get_txt(mode, csrf_token_value, access, def get_txt(csrf_token_value, access,
vleduration, vlebegin, conds, views, pkg_id) : vleduration, vlebegin, conds, views, pkg_id) :
# mode values : "home", "pattern"
# access values : "public", "limited" # access values : "public", "limited"
txt= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' + "\n" txt= '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">' + "\n"
...@@ -233,32 +238,14 @@ def get_txt(mode, csrf_token_value, access, ...@@ -233,32 +238,14 @@ def get_txt(mode, csrf_token_value, access,
txt=txt+ '<div style="background-color:LightYellow">' + "\n" txt=txt+ '<div style="background-color:LightYellow">' + "\n"
txt=txt+ '' + "\n" txt=txt+ '' + "\n"
if mode == "pattern" : txt=txt+ ' <h1 id="model" align=center>Simulateur ' + vpz_name + ' </h1>' + "\n"
txt=txt+ ' <h1 id="model" align=center>Simulateur ' + vpz_name + ' du modele ' + pkg_name + '</h1>' + "\n" txt=txt+ ' <p align=center><i> - Simulateur ' + vpz_name + ' du modele ' + pkg_name + ' du depot de modeles ' + rep_name + ' de la version vle ' + version_name + ' - </i></p>' + "\n"
txt=txt+ ' <p class="instructions" align=center>Simulateur ' + full_name + '= simulateur ' + vpz_name + ' du modele ' + pkg_name + ' du depot de modeles ' + rep_name + '</p>' + "\n" txt=txt+ '' + "\n"
txt=txt+ '' + "\n"
else : # "home" by default
txt=txt+ ' <h1 id="model" align=center>Simulateur ' + vpz_name + ' </h1>' + "\n"
txt=txt+ ' <p align=center><i> - Simulateur ' + vpz_name + ' du modele ' + pkg_name + ' du depot de modeles ' + rep_name + ' - </i></p>' + "\n"
txt=txt+ '' + "\n"
if mode == "pattern" :
txt=txt+ ' <h2>Presentation du modele</h2>' + "\n"
txt=txt+ '' + "\n"
txt=txt+ ' <p><a href=#model onclick="toggle_visibility(\'more_model\');"><i>open/close</i></a></p>' + "\n"
txt=txt+ '' + "\n"
txt=txt+ ' <div class="block" id="more_model" style="display:None;" style="background-color:green">' + "\n"
txt=txt+ '' + "\n"
txt=txt+ ' <table><tr><td>' + "\n"
txt=txt+ ' <p class="instructions">Texte de presentation du modele...</p>' + "\n"
txt=txt+ ' </td></tr></table>' + "\n"
txt=txt+ '' + "\n"
txt=txt+ ' </div>' + "\n"
txt=txt+ '' + "\n"
txt=txt+ ' <h2>Modification et simulation</h2>' + "\n" txt=txt+ ' <h2>Modification et simulation</h2>' + "\n"
txt=txt+ '' + "\n" txt=txt+ '' + "\n"
txt=txt+ ' <form action="http://erecord.toulouse.inra.fr:8000/vpz/output/" method="post" enctype="multipart/form-data" target=\'_blank\' >' + "\n" #txt=txt+ ' <form action="http://erecord.toulouse.inra.fr:8000/vpz/output/" method="post" enctype="multipart/form-data" target=\'_blank\' >' + "\n"
txt=txt+ ' <form action="'+base_url+'vpz/output/" method="post" enctype="multipart/form-data" target=\'_blank\' >' + "\n"
txt=txt+ '' + "\n" txt=txt+ '' + "\n"
txt=txt+ ' <p class="foruser">Vous pouvez <input type="submit" value="simuler" /> ' + vpz_name + ' apres l\'avoir modifie ci-dessous, si vous le souhaitez.</p>' + "\n" txt=txt+ ' <p class="foruser">Vous pouvez <input type="submit" value="simuler" /> ' + vpz_name + ' apres l\'avoir modifie ci-dessous, si vous le souhaitez.</p>' + "\n"
...@@ -269,11 +256,13 @@ def get_txt(mode, csrf_token_value, access, ...@@ -269,11 +256,13 @@ def get_txt(mode, csrf_token_value, access,
txt=txt+ ' <p class="foruser">Aide :<br>' + "\n" txt=txt+ ' <p class="foruser">Aide :<br>' + "\n"
if access != "public" : if access != "public" :
txt=txt+ ' <a href="http://erecord.toulouse.inra.fr:8000/acs/jwt/obtain/" target="_blank"><span style="color:red;"><b>to get a token</b></span></a><br>' + "\n" #txt=txt+ ' <a href="http://erecord.toulouse.inra.fr:8000/acs/jwt/obtain/" target="_blank"><span style="color:red;"><b>to get a token</b></span></a><br>' + "\n"
txt=txt+ ' <a href="'+base_url+'acs/jwt/obtain/" target="_blank"><span style="color:red;"><b>to get a token</b></span></a><br>' + "\n"
txt=txt+ ' <a href=http://aa.usno.navy.mil/data/docs/JulianDate.php target="_blank">Julian Date Converter</a> (pour dates : valeur de begin...) <br>' + "\n" txt=txt+ ' <a href=http://aa.usno.navy.mil/data/docs/JulianDate.php target="_blank">Julian Date Converter</a> (pour dates : valeur de begin...) <br>' + "\n"
url_datalist = "http://erecord.toulouse.inra.fr:8000/db/pkg/" +str(pkg_id)+ "/datalist" #url_datalist = "http://erecord.toulouse.inra.fr:8000/db/pkg/" +str(pkg_id)+ "/datalist"
url_datalist = base_url + "db/pkg/" +str(pkg_id)+ "/datalist"
url_datalist_json = url_datalist + "/?format=json" url_datalist_json = url_datalist + "/?format=json"
url_datalist_yaml = url_datalist + "/?format=yaml" url_datalist_yaml = url_datalist + "/?format=yaml"
txt=txt+ ' <a href=' + url_datalist + ' target="_blank">Fichiers de donnees disponibles par defaut pour le simulateur</a> (<a href=' + url_datalist_json + ' target="_blank">json</a> , <a href=' + url_datalist_yaml + ' target="_blank">yaml</a>)' + "\n" txt=txt+ ' <a href=' + url_datalist + ' target="_blank">Fichiers de donnees disponibles par defaut pour le simulateur</a> (<a href=' + url_datalist_json + ' target="_blank">json</a> , <a href=' + url_datalist_yaml + ' target="_blank">yaml</a>)' + "\n"
...@@ -369,8 +358,6 @@ def get_txt(mode, csrf_token_value, access, ...@@ -369,8 +358,6 @@ def get_txt(mode, csrf_token_value, access,
txt=txt+ ' <tr>' + "\n" txt=txt+ ' <tr>' + "\n"
txt=txt+ ' <td height="20" align="left" bgcolor="#CCFFCC"><i>nom du parametre</i></td>' + "\n" txt=txt+ ' <td height="20" align="left" bgcolor="#CCFFCC"><i>nom du parametre</i></td>' + "\n"
txt=txt+ ' <td align="left" bgcolor="#CCFFCC"><i>type</i></td>' + "\n" txt=txt+ ' <td align="left" bgcolor="#CCFFCC"><i>type</i></td>' + "\n"
if mode == "pattern" :
txt=txt+ ' <td align="left" bgcolor="#CCFFCC"><i>autre</i><div class="instructions">(precisions : unite, valeurs min et max...)</div></td>' + "\n"
txt=txt+ ' <td align="left" bgcolor="#CCFFCC"><i>valeur</i></td>' + "\n" txt=txt+ ' <td align="left" bgcolor="#CCFFCC"><i>valeur</i></td>' + "\n"
txt=txt+ ' </tr>' + "\n" txt=txt+ ' </tr>' + "\n"
...@@ -386,8 +373,6 @@ def get_txt(mode, csrf_token_value, access, ...@@ -386,8 +373,6 @@ def get_txt(mode, csrf_token_value, access,
txt=txt+ ' <tr>' + "\n" txt=txt+ ' <tr>' + "\n"
txt=txt+ ' <td height="20" align="left" bgcolor="#ECFFF1"><b>'+par_pname+ '</b></td>' + "\n" txt=txt+ ' <td height="20" align="left" bgcolor="#ECFFF1"><b>'+par_pname+ '</b></td>' + "\n"
txt=txt+ ' <td align="left" bgcolor="#ECFFF1">' +par_type+ '</td>' + "\n" txt=txt+ ' <td align="left" bgcolor="#ECFFF1">' +par_type+ '</td>' + "\n"
if mode == "pattern" :
txt=txt+ ' <td align="left" bgcolor="#ECFFF1"></td>' + "\n"
txt=txt+ ' <td align="left" bgcolor="#ECFFF1"><textarea name="'+ par_name + '" rows="2" cols="80">'+str(par_value)+'</textarea></td>' + "\n" txt=txt+ ' <td align="left" bgcolor="#ECFFF1"><textarea name="'+ par_name + '" rows="2" cols="80">'+str(par_value)+'</textarea></td>' + "\n"
txt=txt+ ' </tr>' + "\n" txt=txt+ ' </tr>' + "\n"
txt=txt+ ' </table>' + "\n" txt=txt+ ' </table>' + "\n"
...@@ -429,20 +414,7 @@ def get_txt(mode, csrf_token_value, access, ...@@ -429,20 +414,7 @@ def get_txt(mode, csrf_token_value, access,
txt=txt+ ' </form>' + "\n" txt=txt+ ' </form>' + "\n"
txt=txt+ '' + "\n" txt=txt+ '' + "\n"
if mode == "pattern" : small_txt = full_name
txt=txt+ ' <h2>Plus d\'informations</h2>' + "\n"
url = "http://147.100.164.34/docs/models/"+pkg_name
txt=txt+ ' <p class="instructions">Espace doc sous erecord pour le modele ' + full_name + ', propose lors de sa livraison :</p>' + "\n"
txt=txt+ ' <p><a href="'+url+'">Plus d\'informations sur le modele ' +pkg_name+ '</a>' + "\n"
txt=txt+ ' <p class="instructions">Help contruction : <a href="https://www.w3schools.com/html/html_form_input_types.asp">HTML Input Types</a> (the different input types for the \'input\' element) permettant de controler les valeurs saisies (definition de bornes de saisie, rendre readonly, etc).</p>' + "\n"
txt=txt+ ' <br>' + "\n"
txt=txt+ '' + "\n"
if mode == "pattern" :
small_txt = 'modele ' + pkg_name
else : # "home" by default
small_txt = full_name
txt=txt+ '</div>' + "\n" txt=txt+ '</div>' + "\n"
txt=txt+ '' + "\n" txt=txt+ '' + "\n"
txt=txt+ '<hr size="1"/><address style="text-align: right;"><small>' + small_txt + '</small></address>' + "\n" txt=txt+ '<hr size="1"/><address style="text-align: right;"><small>' + small_txt + '</small></address>' + "\n"
...@@ -471,23 +443,17 @@ if len(sys.argv) >= 2 : ...@@ -471,23 +443,17 @@ if len(sys.argv) >= 2 :
rootpath = path rootpath = path
genpath = os.path.join(rootpath, "gen") genpath = os.path.join(rootpath, "gen")
homepath = os.path.join(genpath, "homes") homepath = os.path.join(genpath, "homes")
patternpath = os.path.join(genpath, "patterns")
create_dir_if_absent(rootpath) create_dir_if_absent(rootpath)
clean_dir(genpath) clean_dir(genpath)
clean_dir(homepath) clean_dir(homepath)
clean_dir(patternpath) print "html home pages generated into ", homepath
print "html home pages generated into ", homepath
print "html pattern pages generated into ", patternpath
# limited access case # limited access case
privatepath = os.path.join(rootpath, "private") privatepath = os.path.join(rootpath, "private")
privatehomepath = os.path.join(privatepath, "homes") privatehomepath = os.path.join(privatepath, "homes")
privatepatternpath = os.path.join(privatepath, "patterns")
clean_dir(privatepath) clean_dir(privatepath)
clean_dir(privatehomepath) clean_dir(privatehomepath)
clean_dir(privatepatternpath) print "limited access case / html home pages generated into ", privatehomepath
print "limited access case / html home pages generated into ", privatehomepath
print "limited access case / html pattern pages generated into ", privatepatternpath
# token value # token value
fichier=open("token_value", 'r') fichier=open("token_value", 'r')
...@@ -499,94 +465,80 @@ print "token_value : ", token_value ...@@ -499,94 +465,80 @@ print "token_value : ", token_value
print "" print ""
# db/vpz # db/vpz
url = "http://erecord.toulouse.inra.fr:8000/db/vpz/" #url = "http://erecord.toulouse.inra.fr:8000/db/vpz/"
url = base_url + "db/vpz/"
options = {'mode':'tree', 'format':'json'} options = {'mode':'tree', 'format':'json'}
vlevpz_list = send_get_and_receive(url=url,options=options) vlevpz_list = send_get_and_receive(url=url,options=options)
for vlevpz in vlevpz_list : for vlevpz in vlevpz_list :
(rep_name, pkg_name, vpz_name, rep_id, pkg_id, vpz_id, comment) = content_vpz_tree(vlevpz) (version_name, rep_name, pkg_name, vpz_name,
version_id, rep_id, pkg_id, vpz_id, comment) = content_vpz_tree(vlevpz)
txtcomment = comment txtcomment = comment
full_name = get_full_name(rep_name=rep_name, pkg_name=pkg_name, full_name = get_full_name(version_name= version_name, rep_name=rep_name,
vpz_name=vpz_name) pkg_name=pkg_name, vpz_name=vpz_name)
txtcomment=txtcomment + "Nom complet (unique) du simulateur : " + full_name + "\n" + "\n" txtcomment=txtcomment + "Nom complet (unique) du simulateur : " + full_name + "\n" + "\n"
print "building html (home and pattern) pages of simulator ", full_name, " (Id", vpz_id , ")" print "building html home pages of simulator ", full_name, " (Id", vpz_id , ")"
# vpz/input # vpz/input
inputdata = {"vpz":vpz_id, "jwt":token_value, inputdata = {"vpz":vpz_id, "jwt":token_value,
"mode":"tree", "format":"json", "outselect":"all"} "mode":"tree", "format":"json", "outselect":"all"}
responsedata = send_post_and_receive( responsedata = send_post_and_receive(
url="http://erecord.toulouse.inra.fr:8000/vpz/input/", #url="http://erecord.toulouse.inra.fr:8000/vpz/input/",
url=base_url+"vpz/input/",
inputdata=inputdata) inputdata=inputdata)
(vleduration, vlebegin, conds, views) = content_simulation_inputs_tree( (vleduration, vlebegin, conds, views) = content_simulation_inputs_tree(
vpzinput=responsedata) vpzinput=responsedata)
# db/vpz/access # db/vpz/access
url="http://erecord.toulouse.inra.fr:8000/acs/vpz/"+str(vpz_id)+"/access/" #url="http://erecord.toulouse.inra.fr:8000/acs/vpz/"+str(vpz_id)+"/access/"
url = base_url+"acs/vpz/"+str(vpz_id)+"/access/"
responsedata = send_get_and_receive( url=url, options={'format':'json'}) responsedata = send_get_and_receive( url=url, options={'format':'json'})
access = responsedata["access"] access = responsedata["access"]
for mode in ("home", "pattern") : if access == "public" :
# html code into home file
if access == "public" : file_name = get_home_file_name(homepath=homepath,
if mode == "pattern" : version_name=version_name, rep_name=rep_name,
# html code into pattern file pkg_name=pkg_name, vpz_name=vpz_name)
file_name = get_pattern_file_name(patternpath=patternpath, else : # "limited"
rep_name=rep_name, pkg_name=pkg_name, # html code into home file
vpz_name=vpz_name) file_name = get_home_file_name(homepath=privatehomepath,
else : # "home" by default version_name=version_name, rep_name=rep_name,
# html code into home file pkg_name=pkg_name, vpz_name=vpz_name)
file_name = get_home_file_name(homepath=homepath,
rep_name=rep_name, pkg_name=pkg_name, file = open(file_name, "w")
vpz_name=vpz_name)
else : # "limited"
if mode == "pattern" :
# html code into pattern file
file_name = get_pattern_file_name(
patternpath=privatepatternpath,
rep_name=rep_name, pkg_name=pkg_name,
vpz_name=vpz_name)
else : # "home" by default
# html code into home file
file_name = get_home_file_name( homepath=privatehomepath,
rep_name=rep_name, pkg_name=pkg_name,
vpz_name=vpz_name)
file = open(file_name, "w")
id_v = str(rep_id)+"_"+str(pkg_id)+"_"+str(vpz_id) id_v = str(rep_id)+"_"+str(pkg_id)+"_"+str(vpz_id)
uuid_v = str(uuid.uuid4()) uuid_v = str(uuid.uuid4())
csrf_token_value = id_v + "_" + uuid_v csrf_token_value = id_v + "_" + uuid_v
txt = get_txt(mode, csrf_token_value, access, txt = get_txt(csrf_token_value, access,
vleduration, vlebegin, conds, views, pkg_id) vleduration, vlebegin, conds, views, pkg_id)
file.write(txt) file.write(txt)
file.close() file.close()
if mode == "pattern" : # html code into home file ("public" or "limited" access)
pass relative_file_name = get_home_file_name(homepath="..",
else : # "home" by default version_name=version_name, rep_name=rep_name,
pkg_name=pkg_name, vpz_name=vpz_name,
# html code into home file ("public" or "limited" access) to_create=False)
relative_file_name = get_home_file_name(homepath="..",
rep_name=rep_name, pkg_name=pkg_name, # links into byids folder
vpz_name=vpz_name, to_create=False)
if access == "public" :
# links into byids folder linkpath = os.path.join(homepath, ".by_ids")
else : # "limited"
if access == "public" : linkpath = os.path.join(privatehomepath, ".by_ids")
linkpath = os.path.join(homepath, ".by_ids")
else : # "limited" create_dir_if_absent(linkpath)
linkpath = os.path.join(privatehomepath, ".by_ids") dest_file_name = str(rep_id)+"__"+str(pkg_id)+"__"+str(vpz_id)+"___home.html"
dest = os.path.join(linkpath, dest_file_name)