feat: Add basic struture for tests
This commit is contained in:
2
.dev/Procfile
Executable file
2
.dev/Procfile
Executable file
@@ -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
|
||||
52
.dev/dev.py
Executable file
52
.dev/dev.py
Executable file
@@ -0,0 +1,52 @@
|
||||
# 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'] + '/modules/'
|
||||
MODULES = os.environ['MODULES'].split(':')
|
||||
DB_NAME = os.environ['DB_NAME']
|
||||
|
||||
|
||||
def _main():
|
||||
i = inotify.adapters.Inotify()
|
||||
logging.info("MONITOREANDO ARCHIVOS EN %s", SRC)
|
||||
|
||||
for module in MODULES:
|
||||
logging.info('NOMBRE DEL MODULO A MONITOREAR%s', module)
|
||||
i.add_watch(
|
||||
SRC + module)
|
||||
|
||||
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
|
||||
|
||||
module_name = path.split('/')[-1]
|
||||
logging.info('NOMBRE DEL MODULO %s', module_name)
|
||||
|
||||
if ext in ['.py', '.xml', '.cfg']:
|
||||
for _ in range(0, 10):
|
||||
command = "trytond-admin -d {} -u {} --act -vv".format(
|
||||
DB_NAME, module_name)
|
||||
logging.debug("Ejecutando comando: %s", command)
|
||||
update_module = os.system(command)
|
||||
if update_module != 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()
|
||||
66
.dev/install_module.sh
Normal file
66
.dev/install_module.sh
Normal file
@@ -0,0 +1,66 @@
|
||||
# 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"
|
||||
|
||||
if [ -z "${DEVELOP}" ]; then
|
||||
DEVELOP="False"
|
||||
fi
|
||||
|
||||
if [ ${DEVELOP} = "True" ]; then
|
||||
pip3 install --break-system-packages -r .dev/requirements_dev.txt
|
||||
fi
|
||||
|
||||
# dependencias minimas
|
||||
pip3 install --break-system-packages -r requirements.txt
|
||||
|
||||
pip3 install --break-system-packages trytond==${TRYTOND_VERSION}
|
||||
official_modules=".dev/official_modules.txt"
|
||||
|
||||
while IFS= read -r module; do
|
||||
pip3 index versions "trytond-$module" | grep -oP '\d+\.\d+\.\d+' | grep "^${TRYTOND_VERSION}" | while read version; do
|
||||
pip3 install --break-system-packages "trytond-$module==${version}"
|
||||
echo "Versión instalada: $module==$version"
|
||||
break
|
||||
done
|
||||
|
||||
done <"$official_modules"
|
||||
|
||||
if [ -d "modules" ] && [ "$(ls -A modules)" ]; then
|
||||
|
||||
module_names=()
|
||||
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')
|
||||
|
||||
# Añadir el nombre del módulo al arreglo
|
||||
module_names+=("$module_name")
|
||||
|
||||
[ ! -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
|
||||
|
||||
module_names=$(
|
||||
IFS=:
|
||||
echo "${module_names[*]}"
|
||||
)
|
||||
fi
|
||||
2
.dev/official_modules.txt
Normal file
2
.dev/official_modules.txt
Normal file
@@ -0,0 +1,2 @@
|
||||
country
|
||||
company
|
||||
6
.dev/requirements_dev.txt
Normal file
6
.dev/requirements_dev.txt
Normal file
@@ -0,0 +1,6 @@
|
||||
inotify==0.2.10
|
||||
honcho==2.0.0
|
||||
pudb==2025.1
|
||||
urwid==3.0.2
|
||||
freezegun==1.5.1
|
||||
psycopg2==2.9.10
|
||||
31
.dev/run.sh
Executable file
31
.dev/run.sh
Executable file
@@ -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 MODULES=$module_names
|
||||
export DB_NAME
|
||||
export SRC
|
||||
|
||||
honcho -d ${SCRIPT_DIR} start
|
||||
3
.dev/trytond.cfg
Executable file
3
.dev/trytond.cfg
Executable file
@@ -0,0 +1,3 @@
|
||||
[web]
|
||||
listen = 0.0.0.0:8000
|
||||
root=/var/lib/trytond/www
|
||||
Reference in New Issue
Block a user