Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
record
recordweb
Commits
e592537d
Commit
e592537d
authored
Jul 17, 2018
by
Nathalie Rousse
Browse files
Updating vle-x/trunk according to local version (ERECORD2) using erecord package instead of pyvle
parent
65560023
Changes
40
Hide whitespace changes
Inline
Side-by-side
vle-x/trunk/erecord/README.txt
View file @
e592537d
...
...
@@ -10,3 +10,6 @@ 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...).
vle-x/trunk/erecord/databases/__init__.py
View file @
e592537d
...
...
@@ -3,7 +3,7 @@
*This package is part of erecord - Record platform web development*
:copyright: Copyright (C) 201
4
-20
15
INRA http://www.inra.fr.
:copyright: Copyright (C) 201
8
-20
22
INRA http://www.inra.fr.
:license: GPLv3, see LICENSE for more details.
:authors: see AUTHORS.
...
...
vle-x/trunk/erecord/docs/__init__.py
View file @
e592537d
...
...
@@ -3,7 +3,7 @@
*This package is part of erecord - Record platform web development*
:copyright: Copyright (C) 201
4
-20
15
INRA http://www.inra.fr.
:copyright: Copyright (C) 201
8
-20
22
INRA http://www.inra.fr.
:license: GPLv3, see LICENSE for more details.
:authors: see AUTHORS.
...
...
vle-x/trunk/erecord/docs/source/devel/deployment/development_environment_install.rst
View file @
e592537d
...
...
@@ -66,6 +66,10 @@ Installation of the vle environment
It consists in (i) installing vle-1.1, (ii) installing pyvle-1.1 (into the
erecordenv virtualenv).
!!! todo enlever "installing pyvle"
!!! todo gerer plusieurs versions vle
See http://www.vle-project.org/wiki/VLE-1.1
*Some more notes* : :ref:`cmd_install_vle_pyvle`
...
...
vle-x/trunk/erecord/docs/source/devel/deployment/include/cmd_activate_erecordenv_virtualenv.rst
View file @
e592537d
...
...
@@ -2,10 +2,10 @@ erecordenv virtualenv activation
================================
* in bash or sh case :
source /opt/erecord/factory/erecordenv/bin/activate
source /opt/erecord/factory/
install/
erecordenv/bin/activate
* in csh or tcsh case :
source /opt/erecord/factory/erecordenv/bin/activate.csh
source /opt/erecord/factory/
install/
erecordenv/bin/activate.csh
* just to control the activation on the erecordenv virtualenv :
which python
...
...
vle-x/trunk/erecord/docs/source/devel/deployment/include/cmd_create_erecordenv_virtualenv.rst
View file @
e592537d
* erecordenv creation :
virtualenv /opt/erecord/factory/erecordenv -p /usr/bin/python2.7 --no-site-packages
virtualenv /opt/erecord/factory/
install/
erecordenv -p /usr/bin/python2.7 --no-site-packages
vle-x/trunk/erecord/docs/source/devel/deployment/include/cmd_install_vle_pyvle.rst
View file @
e592537d
...
...
@@ -2,6 +2,10 @@
vle-1.1 and pyvle-1.1 installation
==================================
!!!todo enlever installation pyvle
!!!todo gerer plusieurs versions vle
vle-1.1.3 and pyvle-1.1.3
Installation on Debian Jessie (production server).
...
...
@@ -48,7 +52,7 @@ git checkout -b v1.1.3 v1.1.3
* build and install into erecordenv virtualenv :
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/erecord/factory/erecordenv -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
cmake -DCMAKE_INSTALL_PREFIX=/opt/erecord/factory/
install/
erecordenv -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
make
sudo make install
...
...
@@ -124,7 +128,7 @@ git checkout -b v1.1 origin/master1.1
* build and install into erecordenv virtualenv :
mkdir build
cd build
cmake -DCMAKE_INSTALL_PREFIX=/opt/erecord/factory/erecordenv -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
cmake -DCMAKE_INSTALL_PREFIX=/opt/erecord/factory/
install/
erecordenv -DCMAKE_BUILD_TYPE=RelWithDebInfo ..
make
sudo make install
vle-x/trunk/erecord/docs/source/devel/deployment/include/cmd_modify_apache2conf.rst
View file @
e592537d
...
...
@@ -9,6 +9,9 @@ KeepAlive Off
* /etc/apache2/mods-available/mpm_prefork.conf modifications :
ServerLimit 150
(same value as MaxRequestWorkers)
MaxConnectionsPerChild 1
(not MaxConnectionsPerChild 0)
vle-x/trunk/erecord/docs/source/devel/deployment/include/cmd_modify_wsgipy.rst
View file @
e592537d
...
...
@@ -2,5 +2,5 @@
* /opt/erecord/erecord/projects/ws/ws/wsgi.py file modifications :
Put the appropriate path for activate_this.py :
activate_this = os.path.expanduser("/opt/erecord/factory/erecordenv/bin/activate_this.py")
activate_this = os.path.expanduser("/opt/erecord/factory/
install/
erecordenv/bin/activate_this.py")
vle-x/trunk/erecord/docs/source/devel/deployment/include/pathnames.rst
View file @
e592537d
...
...
@@ -35,8 +35,8 @@ erecordenv_path
Let's name **erecordenv_path** the directory where the erecordenv virtualenv is
installed.
In the deployment example, erecordenv_path is 'factory' under
:ref:`deploy_erecord_path`, ie '/opt/erecord/factory'.
In the deployment example, erecordenv_path is
'install' under
'factory' under
:ref:`deploy_erecord_path`, ie '/opt/erecord/factory
/install
'.
.. _deploy_erecord_docs_path:
...
...
vle-x/trunk/erecord/docs/vpzpages/from_anywhere/README.txt
View file @
e592537d
...
...
@@ -20,7 +20,7 @@ export erecordroot="/home/nrousse/workspace_svn/DEVELOPPEMENT_WEB/ERECORD/trunk"
echo ${erecordroot}
# environnement
source ${erecordroot}/erecord/factory/erecordenv/bin/activate
source ${erecordroot}/erecord/factory/
install/
erecordenv/bin/activate
cp -f ${erecordroot}/erecord/docs/vpzpages/get_token.py .
cp -f ${erecordroot}/erecord/docs/vpzpages/build_vpzpages.py .
...
...
vle-x/trunk/erecord/erecord/AUTHORS
View file @
e592537d
Copyright (C) 201
4
-20
16
INRA http://www.inra.fr
Copyright (C) 201
8
-20
22
INRA http://www.inra.fr
Authors :
- Nathalie Rousse, RECORD platform team member, INRA
...
...
vle-x/trunk/erecord/erecord/README.txt
View file @
e592537d
...
...
@@ -8,3 +8,5 @@ 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...).
vle-x/trunk/erecord/erecord/__init__.py
View file @
e592537d
...
...
@@ -3,7 +3,7 @@
*This package is part of erecord - Record platform web development*
:copyright: Copyright (C) 201
4
-20
15
INRA http://www.inra.fr.
:copyright: Copyright (C) 201
8
-20
22
INRA http://www.inra.fr.
:license: GPLv3, see :ref:`LICENSE` for more details.
:authors: see :ref:`AUTHORS`.
...
...
@@ -18,5 +18,7 @@ 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...).
"""
vle-x/trunk/erecord/erecord/apps/__apps__.py
View file @
e592537d
...
...
@@ -3,7 +3,7 @@
*This package is part of erecord - Record platform web development*
:copyright: Copyright (C) 201
4
-20
15
INRA http://www.inra.fr.
:copyright: Copyright (C) 201
8
-20
22
INRA http://www.inra.fr.
:license: GPLv3, see :ref:`LICENSE` for more details.
:authors: see :ref:`AUTHORS`.
...
...
vle-x/trunk/erecord/erecord/apps/erecord_cmn/utils/coding.py
View file @
e592537d
...
...
@@ -5,6 +5,8 @@ Coding methods
"""
import
json
def
byteify
(
input
):
"""unicode to utf-8
...
...
@@ -22,3 +24,8 @@ def byteify(input):
else
:
return
input
def
get_val
(
value
):
"""JSON object to utf-8 """
return
byteify
(
json
.
loads
(
value
))
vle-x/trunk/erecord/erecord/apps/erecord_cmn/utils/erecord_package.py
0 → 100644
View file @
e592537d
# -*- erecord_package: utf-8 -*-
"""erecord_cmn.utils.erecord_package
Methods about erecord package
"""
import
os
import
json
import
shutil
from
erecord_cmn.utils.vle
import
get_rep_pkg_data_path
from
erecord_cmn.utils.vle
import
get_rep_pkg_path
from
erecord_cmn.utils.vle
import
get_rep_pkg_exp_path
from
erecord_cmn.utils.process
import
call_subprocess
from
erecord_cmn.utils.coding
import
byteify
###############################################################################
stderr_filename
=
"stderr.txt"
stdout_filename
=
"stdout.txt"
ok_filename
=
"OK"
def
control_in
(
vlehome_path
,
pkgname
,
vpzname
)
:
"""Makes controls and returns a message about errors met
Controls :
- path about pkgname is a directory
- path about vpzname is a file
Note : the returned message is "" if no error met.
"""
pkgname_path
=
get_rep_pkg_path
(
rep_path
=
vlehome_path
,
pkgname
=
pkgname
)
pkg_exp_path
=
get_rep_pkg_exp_path
(
rep_path
=
vlehome_path
,
pkgname
=
pkgname
)
vpzname_path
=
os
.
path
.
join
(
pkg_exp_path
,
vpzname
)
errormsg
=
""
if
not
os
.
path
.
isdir
(
pkgname_path
)
:
msg
=
pkgname
+
" is not a directory"
if
errormsg
!=
""
:
errormsg
=
errormsg
+
" -- "
errormsg
=
errormsg
+
msg
if
not
os
.
path
.
isfile
(
vpzname_path
)
:
msg
=
vpzname
+
" is not a file"
if
errormsg
!=
""
:
errormsg
=
errormsg
+
" -- "
errormsg
=
errormsg
+
msg
return
errormsg
def
copy_erecord_data_file
(
vlehome_path
,
src_folder
,
file_name
):
"""Copies file_name file from src_folder to data folder of erecord pkg"""
erecord_data_path
=
get_rep_pkg_data_path
(
rep_path
=
vlehome_path
,
pkgname
=
"erecord"
)
shutil
.
copyfile
(
src
=
os
.
path
.
join
(
src_folder
,
file_name
),
dst
=
os
.
path
.
join
(
erecord_data_path
,
file_name
))
def
create_and_fill_jsonfile
(
content
,
folder_path
,
file_name
)
:
jsonfile_tmp_path
=
os
.
path
.
join
(
folder_path
,
file_name
)
f
=
open
(
jsonfile_tmp_path
,
'w'
)
f
.
write
(
json
.
dumps
(
content
))
###f.write(json.dumps(byteify(content)))
f
.
close
()
def
run_simulation
(
runvle_path
,
vlehome_path
,
pkgname
,
vpzname
)
:
cmd
=
"cd "
+
runvle_path
+
";"
cmd
=
cmd
+
"export VLE_HOME="
+
vlehome_path
+
";"
cmd
=
cmd
+
"vle -P "
+
pkgname
+
" "
+
vpzname
+
";"
#envir = os.environ
stderr_path
=
os
.
path
.
join
(
runvle_path
,
stderr_filename
)
stdout_path
=
os
.
path
.
join
(
runvle_path
,
stdout_filename
)
retcode
=
call_subprocess
(
cmd
,
runvle_path
,
stderr_path
,
stdout_path
)
#call_subprocess(cmd, runvle_path, stderr_path, stdout_path, env=envir)
(
OK_found
,
msg_stdout
,
msg_stderr
)
=
control_out
(
runvle_path
)
cr_ok
=
OK_found
if
msg_stderr
!=
""
:
cr_ok
=
False
# msg_stdout is not studied
errormsg
=
""
if
not
OK_found
:
errormsg
=
errormsg
+
" -- OK signal absent -- "
errormsg
=
errormsg
+
msg_stderr
return
(
cr_ok
,
errormsg
)
def
get_file_jsoncontent
(
folder_path
,
file_name
)
:
output_file
=
os
.
path
.
join
(
folder_path
,
file_name
)
f
=
open
(
output_file
,
"r"
)
res
=
f
.
read
()
f
.
close
()
r
=
json
.
loads
(
res
)
return
r
def
control_out
(
runvle_path
)
:
"""Makes controls and returns reports
Controls :
- stderr_filename under runvle_path
- stdout_filename under runvle_path
- ok_filename under runvle_path
"""
stderr_path
=
os
.
path
.
join
(
runvle_path
,
stderr_filename
)
stdout_path
=
os
.
path
.
join
(
runvle_path
,
stdout_filename
)
ok_path
=
os
.
path
.
join
(
runvle_path
,
ok_filename
)
msg_stderr
=
""
msg_stdout
=
""
OK_found
=
False
stderr_file
=
open
(
stderr_path
)
msg_stderr
=
stderr_file
.
read
()
stderr_file
.
close
()
stdout_file
=
open
(
stdout_path
)
msg_stdout
=
stdout_file
.
read
()
stdout_file
.
close
()
if
os
.
path
.
exists
(
ok_path
)
:
if
os
.
path
.
isfile
(
ok_path
)
:
OK_found
=
True
return
(
OK_found
,
msg_stdout
,
msg_stderr
)
###############################################################################
def
vle_modify_vpz
(
runvle_path
,
vlehome_path
,
pkgname
,
vpzname
,
storaged_list
,
conditions
,
begin
,
duration
):
"""Prepares and runs modify_vpz.vpz simulation of erecord pkg
As a result : the vpzname file simulator of the pkgname package (under
vlehome_path) has been modified and is ready to be simulated or read.
Attention : give a pkgname, vpzname that is not a link but a copy
"""
def
update
(
modify_parameters
,
storaged_list
,
conditions
,
begin
,
duration
)
:
"""Updates according to storaged_list, conditions, begin, duration
The value of a parameter of a condition is supposed to always be
given as multiple, if its type is 'list'. The case where a parameter
value of 'list' type would be given as a singleton is not treated.
"""
if
begin
is
not
None
:
modify_parameters
[
"begin"
]
=
begin
if
duration
is
not
None
:
modify_parameters
[
"duration"
]
=
duration
modify_parameters
[
"conditions"
]
=
conditions
views
=
dict
()
at_least_one
=
False
if
storaged_list
is
not
None
:
if
(
len
(
storaged_list
)
>
0
)
:
at_least_one
=
True
views
[
"storaged_list"
]
=
list
()
for
v
in
storaged_list
:
views
[
"storaged_list"
].
append
(
v
)
if
at_least_one
:
modify_parameters
[
"views"
]
=
views
def
control_in
(
vlehome_path
,
pkgname
,
vpzname
)
:
"""Makes controls and returns a message about errors met
Controls :
- path about pkgname is a directory, is not a link
- path about vpzname is a file, is not a link
Note : the returned message is "" if no error met.
"""
pkgname_path
=
get_rep_pkg_path
(
rep_path
=
vlehome_path
,
pkgname
=
pkgname
)
pkg_exp_path
=
get_rep_pkg_exp_path
(
rep_path
=
vlehome_path
,
pkgname
=
pkgname
)
vpzname_path
=
os
.
path
.
join
(
pkg_exp_path
,
vpzname
)
errormsg
=
""
if
os
.
path
.
isdir
(
pkgname_path
)
:
if
os
.
path
.
islink
(
pkgname_path
)
:
msg
=
"directory dedicated to "
+
pkgname
+
" package"
msg
=
msg
+
" is of link type (links refused)"
if
errormsg
!=
""
:
errormsg
=
errormsg
+
" -- "
errormsg
=
errormsg
+
msg
else
:
msg
=
pkgname
+
" is not a directory"
if
errormsg
!=
""
:
errormsg
=
errormsg
+
" -- "
errormsg
=
errormsg
+
msg
if
os
.
path
.
isfile
(
vpzname_path
)
:
if
os
.
path
.
islink
(
vpzname_path
)
:
msg
=
vpzname
+
" file is of link type (links refused)"
if
errormsg
!=
""
:
errormsg
=
errormsg
+
" -- "
errormsg
=
errormsg
+
msg
else
:
msg
=
vpzname
+
" is not a file"
if
errormsg
!=
""
:
errormsg
=
errormsg
+
" -- "
errormsg
=
errormsg
+
msg
return
errormsg
errormsg
=
control_in
(
vlehome_path
,
pkgname
,
vpzname
)
if
errormsg
!=
""
:
raise
Exception
(
errormsg
)
# Build modify_input.json input file
modify_parameters
=
dict
()
modify_parameters
[
"pkgname"
]
=
pkgname
modify_parameters
[
"vpzname"
]
=
vpzname
update
(
modify_parameters
,
storaged_list
,
conditions
,
begin
,
duration
)
create_and_fill_jsonfile
(
content
=
modify_parameters
,
folder_path
=
runvle_path
,
file_name
=
"modify_input.json"
)
# Install/copy modify_input.json into erecord/data
copy_erecord_data_file
(
vlehome_path
=
vlehome_path
,
src_folder
=
runvle_path
,
file_name
=
"modify_input.json"
)
# Run modify_vpz.vpz simulation
(
cr_ok
,
errormsg
)
=
run_simulation
(
runvle_path
=
runvle_path
,
vlehome_path
=
vlehome_path
,
pkgname
=
"erecord"
,
vpzname
=
"modify_vpz.vpz"
)
if
not
cr_ok
:
raise
Exception
(
" vle run_simulation -- "
+
errormsg
)
###############################################################################
def
vle_read_vpz
(
runvle_path
,
vlehome_path
,
pkgname
,
vpzname
):
"""Prepares and runs read_vpz.vpz simulation of erecord pkg
This simulation produces (under runvle_path) the read_output.json json file
that contains the input information of vpzname simulator.
Returns the input information of vpzname as json data
"""
errormsg
=
control_in
(
vlehome_path
,
pkgname
,
vpzname
)
if
errormsg
!=
""
:
raise
Exception
(
errormsg
)
# Build read_input.json input file
read_parameters
=
dict
()
read_parameters
[
"pkgname"
]
=
pkgname
read_parameters
[
"vpzname"
]
=
vpzname
create_and_fill_jsonfile
(
content
=
read_parameters
,
folder_path
=
runvle_path
,
file_name
=
"read_input.json"
)
# Install/copy read_input.json into erecord/data
copy_erecord_data_file
(
vlehome_path
=
vlehome_path
,
src_folder
=
runvle_path
,
file_name
=
"read_input.json"
)
# Run read_vpz.vpz simulation
(
cr_ok
,
errormsg
)
=
run_simulation
(
runvle_path
=
runvle_path
,
vlehome_path
=
vlehome_path
,
pkgname
=
"erecord"
,
vpzname
=
"read_vpz.vpz"
)
if
not
cr_ok
:
raise
Exception
(
" vle run_simulation -- "
+
errormsg
)
# Exploitation of read_output.json file result
r
=
get_file_jsoncontent
(
folder_path
=
runvle_path
,
file_name
=
"read_output.json"
)
return
r
###############################################################################
def
vle_run_vpz
(
runvle_path
,
vlehome_path
,
pkgname
,
vpzname
,
plan
,
restype
):
"""Prepares and runs run_vpz.vpz simulation of erecord pkg
This simulation produces (under runvle_path) the run_output.json json file
that contains the results of vpzname simulation.
Returns results of vpzname simulation as json data
"""
errormsg
=
control_in
(
vlehome_path
,
pkgname
,
vpzname
)
if
errormsg
!=
""
:
raise
Exception
(
errormsg
)
# Build run_input.json input file
run_parameters
=
dict
()
run_parameters
[
"pkgname"
]
=
pkgname
run_parameters
[
"vpzname"
]
=
vpzname
run_parameters
[
"plan"
]
=
plan
run_parameters
[
"restype"
]
=
restype
create_and_fill_jsonfile
(
content
=
run_parameters
,
folder_path
=
runvle_path
,
file_name
=
"run_input.json"
)
# Install/copy run_input.json into erecord/data
copy_erecord_data_file
(
vlehome_path
=
vlehome_path
,
src_folder
=
runvle_path
,
file_name
=
"run_input.json"
)
# Run run_vpz.vpz simulation
(
cr_ok
,
errormsg
)
=
run_simulation
(
runvle_path
=
runvle_path
,
vlehome_path
=
vlehome_path
,
pkgname
=
"erecord"
,
vpzname
=
"run_vpz.vpz"
)
if
not
cr_ok
:
raise
Exception
(
" vle run_simulation -- "
+
errormsg
)
# Exploitation of run_output.json file result
r
=
get_file_jsoncontent
(
folder_path
=
runvle_path
,
file_name
=
"run_output.json"
)
return
r
###############################################################################
#
# prints
#
def
print_vle_read_vpz_result
(
res
):
expected_keys
=
[
"experiment_name"
,
"begin"
,
"duration"
,
"cond_list"
,
"view_list"
,
"names"
]
keys
=
res
.
keys
()
for
key
in
keys
:
if
key
not
in
expected_keys
:
print
"unexpected key : "
,
key
print
" (content : "
,
res
[
key
],
")"
key
=
"experiment_name"
if
key
in
keys
:
print
key
,
" : "
,
res
[
key
]
key
=
"begin"
if
key
in
keys
:
print
key
,
": "
,
res
[
key
]
begin
=
res
[
key
]
print
" begin value : "
,
begin
[
"value"
]
print
" begin value type: "
,
type
(
begin
[
"value"
])
key
=
"duration"
if
key
in
keys
:
print
key
,
": "
,
res
[
key
]
duration
=
res
[
key
]
print
" duration value : "
,
duration
[
"value"
]
print
" duration value type: "
,
type
(
duration
[
"value"
])
key
=
"cond_list"
if
key
in
keys
:
#print key, " : ", res[key]
conditions
=
res
[
key
]
print
"Conditions"
for
cname
in
conditions
.
keys
()
:
cond
=
conditions
[
cname
]
par_list
=
cond
[
"par_list"
]
print
" - "
,
cname
,
" : "
for
pname
in
par_list
.
keys
()
:
par
=
par_list
[
pname
]
print
" - "
,
pname
,
" : "
,
par
key
=
"view_list"
if
key
in
keys
:
print
key
,
" : "
,
res
[
key
]
views
=
res
[
key
]
print
"Views"
for
vname
in
views
.
keys
()
:
view
=
views
[
vname
]
out_list
=
view
[
"out_list"
]
print
" - "
,
vname
,
" : "
for
oname
in
out_list
:
print
" - "
,
oname
key
=
"names"
if
key
in
keys
:
names
=
res
[
key
]
print
"Names :"
if
"cond_names"
in
names
.
keys
()
:
print
" - cond names :"
for
name
in
names
[
"cond_names"
]
:
print
" - "
,
name
if
"par_names"
in
names
.
keys
()
:
print
" - par names :"
for
name
in
names
[
"par_names"
]
:
print
" - "
,
name
if
"view_names"
in
names
.
keys
()
:
print
" - view names :"
for
name
in
names
[
"view_names"
]
:
print
" - "
,
name
if
"out_names"
in
names
.
keys
()
:
print
" - out names :"
for
name
in
names
[
"out_names"
]
:
print
" - "
,
name