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
vle-1.1 models.
vle models of several vle versions (vle-1.1, vle-2...).
Content hierarchy : docs, repositories, erecord (the erecord package),
databases, factory...
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
:term:`INRA`.
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
(source code, tests...).
......
......@@ -12,7 +12,7 @@ Introduction
:term:`INRA`.
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`.
......
......@@ -9,10 +9,9 @@ Domain introduction
multi-modeling and simulation platform. And so the agronomic models of the
Record platform are some vle models.
The erecord project is dedicated to the Record platform web development,
concerning more specifically its models developed with the vle-1.1 version of
Vle. The web services provided by erecord allow to edit, modify and simulate
some vle models, such as the Record platform ones.
The erecord project is dedicated to the Record platform web development, for
its models developed with Vle. The web services provided by erecord allow to
edit, modify and simulate some vle models, such as the Record platform ones.
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,
......
......@@ -7,8 +7,8 @@ FAQs about agronomic models
Can erecord web services be used for any agronomic model ?
----------------------------------------------------------
- The agronomic model has to be an operational model developed with
**vle-1.1** version of vle.
- The agronomic model has to be an operational model developed with one of
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
erecord server (see an
......
......@@ -9,8 +9,8 @@ Glossary
erecord project
The erecord project is dedicated to the :term:`Record` platform web
development for :term:`vle model` s (vle-1.1 version). See
:ref:`erecord_project`.
development for :term:`vle model` s of several vle versions (vle-1.1,
vle-2...). See :ref:`erecord_project`.
erecord package
The erecord package is part of the erecord project. It is a python
......
......@@ -7,10 +7,9 @@ erecord
=======
The erecord project is dedicated to the :term:`Record` platform web
development, concerning more specifically its models developed with the
vle-1.1 version of :term:`Vle`. The web services provided by erecord allow
to edit, modify and simulate some vle models, such as the Record platform
ones.
development, for its models developed with :term:`Vle`.
The web services provided by erecord allow to edit, modify and simulate
some vle models, such as the Record platform ones.
Quick overview
==============
......
......@@ -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,
# else folder gen_vpzpages created and html pages are generated into it :
# --> html home pages under gen/homes
# --> html pattern pages under gen/patterns
# html home pages under gen/homes
#
# run : see "cleanvpzpages" and "genvpzpages" rules into ../Makefile
###############################################################################
......@@ -24,7 +23,6 @@ if "erecordroot" in os.environ.keys() :
erecordroot = os.environ["erecordroot"]
apps_home = os.path.normpath(os.path.join(erecordroot,
"erecord", "erecord", "apps"))
if apps_home not in sys.path :
sys.path.insert(0, apps_home)
......@@ -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_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
......@@ -49,6 +50,9 @@ def content_vpz_tree(vlevpz):
vlerep = vlepkg['vlerep']
rep_name = vlerep['name']
rep_id = vlerep['id']
vleversion = vlerep['vleversion']
version_name = vleversion['name']
version_id = vleversion['id']
comment= "\n"
comment=comment+ 'Simulateur : ' + "\n"
......@@ -60,9 +64,13 @@ def content_vpz_tree(vlevpz):
comment=comment+ 'Depot de modeles : ' + "\n"
comment=comment+ ' - name : ' + rep_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"
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
......@@ -150,15 +158,19 @@ def content_simulation_inputs_tree(vpzinput):
###############################################################################
# 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("/","__")
pkg_name = pkg_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)
vpzpath = os.path.join(pkgpath, vpz_name)
if to_create :
create_dir_if_absent(versionpath)
create_dir_if_absent(reppath)
create_dir_if_absent(pkgpath)
create_dir_if_absent(vpzpath)
......@@ -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)
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
def get_full_name(rep_name, pkg_name, vpz_name) :
return (rep_name +' / '+pkg_name+' / '+ vpz_name)
def get_full_name(version_name, rep_name, pkg_name, vpz_name) :
return (version_name +' / '+rep_name +' / '+pkg_name+' / '+ vpz_name)
###############################################################################
# html code text
def get_txt(mode, csrf_token_value, access,
def get_txt(csrf_token_value, access,
vleduration, vlebegin, conds, views, pkg_id) :
# mode values : "home", "pattern"
# 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"
......@@ -233,32 +238,14 @@ def get_txt(mode, csrf_token_value, access,
txt=txt+ '<div style="background-color:LightYellow">' + "\n"
txt=txt+ '' + "\n"
if mode == "pattern" :
txt=txt+ ' <h1 id="model" align=center>Simulateur ' + vpz_name + ' du modele ' + pkg_name + '</h1>' + "\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"
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+ ' <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 + ' de la version vle ' + version_name + ' - </i></p>' + "\n"
txt=txt+ '' + "\n"
txt=txt+ ' <h2>Modification et simulation</h2>' + "\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+ ' <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,
txt=txt+ ' <p class="foruser">Aide :<br>' + "\n"
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"
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_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"
......@@ -369,8 +358,6 @@ def get_txt(mode, csrf_token_value, access,
txt=txt+ ' <tr>' + "\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"
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+ ' </tr>' + "\n"
......@@ -386,8 +373,6 @@ def get_txt(mode, csrf_token_value, access,
txt=txt+ ' <tr>' + "\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"
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+ ' </tr>' + "\n"
txt=txt+ ' </table>' + "\n"
......@@ -429,20 +414,7 @@ def get_txt(mode, csrf_token_value, access,
txt=txt+ ' </form>' + "\n"
txt=txt+ '' + "\n"
if mode == "pattern" :
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
small_txt = full_name
txt=txt+ '</div>' + "\n"
txt=txt+ '' + "\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 :
rootpath = path
genpath = os.path.join(rootpath, "gen")
homepath = os.path.join(genpath, "homes")
patternpath = os.path.join(genpath, "patterns")
create_dir_if_absent(rootpath)
clean_dir(genpath)
clean_dir(homepath)
clean_dir(patternpath)
print "html home pages generated into ", homepath
print "html pattern pages generated into ", patternpath
print "html home pages generated into ", homepath
# limited access case
privatepath = os.path.join(rootpath, "private")
privatehomepath = os.path.join(privatepath, "homes")
privatepatternpath = os.path.join(privatepath, "patterns")
clean_dir(privatepath)
clean_dir(privatehomepath)
clean_dir(privatepatternpath)
print "limited access case / html home pages generated into ", privatehomepath
print "limited access case / html pattern pages generated into ", privatepatternpath
print "limited access case / html home pages generated into ", privatehomepath
# token value
fichier=open("token_value", 'r')
......@@ -499,94 +465,80 @@ print "token_value : ", token_value
print ""
# 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'}
vlevpz_list = send_get_and_receive(url=url,options=options)
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
full_name = get_full_name(rep_name=rep_name, pkg_name=pkg_name,
vpz_name=vpz_name)
full_name = get_full_name(version_name= version_name, rep_name=rep_name,
pkg_name=pkg_name, vpz_name=vpz_name)
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
inputdata = {"vpz":vpz_id, "jwt":token_value,
"mode":"tree", "format":"json", "outselect":"all"}
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)
(vleduration, vlebegin, conds, views) = content_simulation_inputs_tree(
vpzinput=responsedata)
# 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'})
access = responsedata["access"]
for mode in ("home", "pattern") :
if access == "public" :
if mode == "pattern" :
# html code into pattern file
file_name = get_pattern_file_name(patternpath=patternpath,
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=homepath,
rep_name=rep_name, pkg_name=pkg_name,
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")
if access == "public" :
# html code into home file
file_name = get_home_file_name(homepath=homepath,
version_name=version_name, rep_name=rep_name,
pkg_name=pkg_name, vpz_name=vpz_name)
else : # "limited"
# html code into home file
file_name = get_home_file_name(homepath=privatehomepath,
version_name=version_name, 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)
uuid_v = str(uuid.uuid4())
csrf_token_value = id_v + "_" + uuid_v
txt = get_txt(mode, csrf_token_value, access,
vleduration, vlebegin, conds, views, pkg_id)
file.write(txt)
file.close()
if mode == "pattern" :
pass
else : # "home" by default
# html code into home file ("public" or "limited" access)
relative_file_name = get_home_file_name(homepath="..",
rep_name=rep_name, pkg_name=pkg_name,
vpz_name=vpz_name, to_create=False)
# links into byids folder
if access == "public" :
linkpath = os.path.join(homepath, ".by_ids")
else : # "limited"
linkpath = os.path.join(privatehomepath, ".by_ids")
create_dir_if_absent(linkpath)
dest_file_name = str(rep_id)+"__"+str(pkg_id)+"__"+str(vpz_id)+"___home.html"
dest = os.path.join(linkpath, dest_file_name)
if not os.path.exists(dest):
src = relative_file_name
os.symlink(src, dest)
id_v = str(rep_id)+"_"+str(pkg_id)+"_"+str(vpz_id)
uuid_v = str(uuid.uuid4())
csrf_token_value = id_v + "_" + uuid_v
txt = get_txt(csrf_token_value, access,
vleduration, vlebegin, conds, views, pkg_id)
file.write(txt)
file.close()
# html code into home file ("public" or "limited" access)
relative_file_name = get_home_file_name(homepath="..",
version_name=version_name, rep_name=rep_name,
pkg_name=pkg_name, vpz_name=vpz_name,
to_create=False)
# links into byids folder
if access == "public" :
linkpath = os.path.join(homepath, ".by_ids")
else : # "limited"
linkpath = os.path.join(privatehomepath, ".by_ids")
create_dir_if_absent(linkpath)
dest_file_name = str(rep_id)+"__"+str(pkg_id)+"__"+str(vpz_id)+"___home.html"
dest = os.path.join(linkpath, dest_file_name)
if not os.path.exists(dest):
src = relative_file_name
os.symlink(src, dest)
###############################################################################
......@@ -8,7 +8,8 @@
:authors: see :ref:`AUTHORS`.
The erecord package is part of the erecord project dedicated to the Record
platform web development for vle-1.1 models.
platform web development for vle models of several vle versions (vle-1.1,
vle-2...).
The erecord package contains the production (source code, tests, etc).
......@@ -18,7 +19,5 @@ Content hierarchy : docs, install, projects, apps...
See :ref:`index`
Note : in this vle-x development of erecord, erecord is intended to accept models of several vle versions (vle-1.1, vle-2...).
"""
......@@ -166,7 +166,7 @@ TEMPLATE_APP_SLM = os.path.join(PACKAGE_HOME,
# some software behavior options
ACTIVITY_PERSISTENCE = False # True or False
ACTIVITY_PERSISTENCE = True # True or False
"""ACTIVITY_PERSISTENCE value False or True \n
ACTIVITY_PERSISTENCE=True : the activities are kept into the database. \n
ACTIVITY_PERSISTENCE=False : the activities are deleted after restitution. \n
......
......@@ -122,10 +122,22 @@ def run_simulation(runvle_path, vlehome_path, vle_usr_path, pkgname, vpzname) :
cr_ok = OK_found
# !!! a revoir !!!
# controle "enleve" car stderr non vide in case vle-2.0.0
#if msg_stderr != "" :
# cr_ok = False
# Careful : stderr is not empty when OK in case vle-2.0.0
if msg_stderr != "" :
filtered_stderr = ""
msg = msg_stderr.split("\n")
for line in msg :
if line is '' :
pass
elif "debug:" in line :
pass
#elif "warning" in line or "Warning" in line or "WARNING" in line :
# pass
else :
filtered_stderr = filtered_stderr + line
msg_stderr = filtered_stderr
if msg_stderr != "" :
cr_ok = False
# msg_stdout is not studied
......
......@@ -59,7 +59,7 @@ class VleVersionList(StyleViewMixin, FormatViewMixin, ListViewMixin,
p = VleOptionSerializer(data=self.request.query_params)
p.is_valid()
vle = p.data['vle']
if rep is not None :
if vle is not None :
q = VleVersion.objects.filter(id=vle)
else :
q = VleVersion.objects.all()
......
......@@ -5,7 +5,6 @@
"RENAME" : ln -s /home/nrousse/workspace_git/DEVELOPPEMENT_WEB/recordweb/vle-x/trunk/erecord /opt/erecord
vle-2.0.0
=========
......@@ -264,3 +263,5 @@ INSTALL repositories (vle-1.1.3 version)
vle -P wheatpest_V8 configure build
vle -P 2CVdt configure build
* recordschool : see /opt/erecord/factory/install/REPOSITORIES_deliveries/vle-1.1.3/recordschool/README
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment