ScoDoc-PE/scotests/scointeractive.sh

56 lines
1.3 KiB
Bash
Raw Normal View History

2020-12-26 00:11:55 +01:00
#!/bin/bash
# Lancement d'un python scodoc interactif
# dans l'environnement d'un département
# et avec chargement des scripts indiqués
# via from ... import *
#
# Si -r est utilisé, veiller à créer au préalable
# le département via l'interface web (Zope)
usage() {
echo "Usage: $0 [-r] dept [script...]"
echo "Lance un environnement interactif python/ScoDoc"
echo " -r: supprime et recrée le département (attention: efface la base !)"
exit 1
}
set -euo pipefail
cd /opt/scodoc/Products/ScoDoc || exit 2
source config/utils.sh
if [ $# -lt 1 ]
then
usage
fi
if [ "$1" = "-r" ]
then
shift
recreate_dept=1
else
recreate_dept=0
2020-12-26 00:11:55 +01:00
fi
DEPT="$1"
shift
if [ "$recreate_dept" = 1 ]
then
(cd config || terminate "no config directory"; ./delete_dept.sh -n "$DEPT") || terminate "error deleting dept $DEPT"
(cd config || terminate "no config directory"; ./create_dept.sh -n "$DEPT") || terminate "error creating dept $DEPT"
2020-12-27 13:45:24 +01:00
# systemctl start scodoc
2020-12-26 00:11:55 +01:00
fi
cmd="from __future__ import print_function;from Zope2 import configure;configure('/opt/scodoc/etc/zope.conf');import Zope2; app=Zope2.app();from debug import *;context = go_dept(app, '""$DEPT""');"
for f in "$@"
do
cmd="${cmd}exec(open(\"${f}\").read());"
done
/opt/zope213/bin/python -i -c "$cmd"