diff --git a/.dev/Procfile b/.dev/Procfile new file mode 100755 index 0000000..4fdb8f4 --- /dev/null +++ b/.dev/Procfile @@ -0,0 +1,2 @@ +trytond: while true; do trytond -d ${DB_NAME} --dev -v -c $SCRIPT_DIR/trytond.cfg; done +monitor: python3 $SCRIPT_DIR/dev.py \ No newline at end of file diff --git a/.dev/dev.py b/.dev/dev.py new file mode 100755 index 0000000..5585171 --- /dev/null +++ b/.dev/dev.py @@ -0,0 +1,38 @@ +# script para refrescar cambios de xml del modulo de tryton +import sys +import os +import logging +import time + +import inotify.adapters + +logging.basicConfig(level=logging.INFO, stream=sys.stderr) + +SRC = os.environ['SRC'] +MODULE_NAME = os.environ['MODULE_NAME'] +DB_NAME = os.environ['DB_NAME'] + +def _main(): + i = inotify.adapters.Inotify() + + i.add_watch(SRC) + logging.info("MONITOREANDO ARCHIVOS EN %s", SRC) + + for event in i.event_gen(yield_nones=False): + (_, type_names, path, filename) = event + (_, ext) = os.path.splitext(filename) + if 'IN_CLOSE_WRITE' not in type_names: + continue + + if ext in ['.py', '.xml', '.cfg']: + for _ in range(0, 10): + if os.system("trytond-admin -d {} -u {}".format(DB_NAME, MODULE_NAME)) != 0: + time.sleep(2) + logging.error("fallo trytond-admin") + else: + logging.info("ACTUALIZADO TRYTOND POR CAMBIO DE ARCHIVO %s", filename) + break + + +if __name__ == '__main__': + _main() diff --git a/.dev/install_module.sh b/.dev/install_module.sh new file mode 100644 index 0000000..e4a98e8 --- /dev/null +++ b/.dev/install_module.sh @@ -0,0 +1,38 @@ +# este script fuerza que los cambios se vean reflejados +# directamente en trytond. +# +# variables exportadas: +# - module_name + +[ ! -d "$SRC" ] && die "no se ubica ruta en SRC" + +# dependencias minimas +pip3 install psycopg2 proteus==7.0.0 inotify honcho qrcode==6.1 pyshp==2.3.1 shapely==2.0.2 +pip3 install trytond-party trytond-company trytond-product trytond-product_image trytond-currency trytond-notification_email + +for module in modules/*/; do + + pushd "$module" + + # instalar dependencias de tryton desde paquete + python3 setup.py install + + # usamos enlace al paquete + python3 setup.py develop + + # instalar modulo + trytond_modules_path=`pip3 show trytond | grep Location | sed -nr 's/Location: +//gp'`/trytond/modules + module_name=`cat "setup.py" | fgrep -A 1 [trytond.modules] | sed 1d | cut -d '=' -f 1 | tr -d ' \n'` + [ ! -d "$trytond_modules_path" ] && die "fallo al ubicar ruta de modulos de trytond" + ln -sf "$SRC/$module" "$trytond_modules_path/$module_name" + rm -rf "$SRC/$module/$module_name" + + popd + +done + +trytond_path=`pip3 show trytond | grep Location | sed -nr 's/Location: +//gp'`/trytond + +if [ -d "locale_custom" ]; then + cp -f "locale_custom/ir/pt.po" "$trytond_path/ir/locale/" +fi diff --git a/.dev/install_module.sh~ b/.dev/install_module.sh~ new file mode 100644 index 0000000..e4a98e8 --- /dev/null +++ b/.dev/install_module.sh~ @@ -0,0 +1,38 @@ +# este script fuerza que los cambios se vean reflejados +# directamente en trytond. +# +# variables exportadas: +# - module_name + +[ ! -d "$SRC" ] && die "no se ubica ruta en SRC" + +# dependencias minimas +pip3 install psycopg2 proteus==7.0.0 inotify honcho qrcode==6.1 pyshp==2.3.1 shapely==2.0.2 +pip3 install trytond-party trytond-company trytond-product trytond-product_image trytond-currency trytond-notification_email + +for module in modules/*/; do + + pushd "$module" + + # instalar dependencias de tryton desde paquete + python3 setup.py install + + # usamos enlace al paquete + python3 setup.py develop + + # instalar modulo + trytond_modules_path=`pip3 show trytond | grep Location | sed -nr 's/Location: +//gp'`/trytond/modules + module_name=`cat "setup.py" | fgrep -A 1 [trytond.modules] | sed 1d | cut -d '=' -f 1 | tr -d ' \n'` + [ ! -d "$trytond_modules_path" ] && die "fallo al ubicar ruta de modulos de trytond" + ln -sf "$SRC/$module" "$trytond_modules_path/$module_name" + rm -rf "$SRC/$module/$module_name" + + popd + +done + +trytond_path=`pip3 show trytond | grep Location | sed -nr 's/Location: +//gp'`/trytond + +if [ -d "locale_custom" ]; then + cp -f "locale_custom/ir/pt.po" "$trytond_path/ir/locale/" +fi diff --git a/.dev/run.sh b/.dev/run.sh new file mode 100755 index 0000000..e8faebe --- /dev/null +++ b/.dev/run.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# script para iniciar entorno vivo + + +SCRIPT_DIR=$(dirname `realpath $0`) + +die() { + echo $1 + exit 1 +} + +[ ! -d "$SRC" ] && die "no se ubica ruta en SRC" +[ -z "$DB_NAME" ] && die "se requiere variable DB_NAME" + +set -e + +# instalar modulo +source ${SCRIPT_DIR}/install_module.sh + +# inicializar base de datos +# https://docs.tryton.org/projects/server/en/latest/tutorial/module/setup_database.html +yes admin | trytond-admin -d ${DB_NAME} --all --act + + +# ejecutar servidor +export SCRIPT_DIR +export MODULE_NAME=$module_name +export DB_NAME +export SRC + +honcho -d ${SCRIPT_DIR} start diff --git a/.dev/trytond.cfg b/.dev/trytond.cfg new file mode 100755 index 0000000..c30c741 --- /dev/null +++ b/.dev/trytond.cfg @@ -0,0 +1,3 @@ +[web] +listen = 0.0.0.0:8000 +root=/var/lib/trytond/www \ No newline at end of file