[FIX] script python: missing color log error

This commit is contained in:
Mathieu Benoit 2024-02-23 13:01:10 -05:00
parent 6d0c03dc25
commit ea9be9b2ca
36 changed files with 194 additions and 89 deletions

View file

@ -1,19 +1,21 @@
#!/usr/bin/env bash #!/usr/bin/env bash
source ./.venv/bin/activate source ./.venv/bin/activate
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
CONFIG_PATH="./config.conf" CONFIG_PATH="./config.conf"
ORIGIN_CONFIG_PATH=CONFIG_PATH ORIGIN_CONFIG_PATH=CONFIG_PATH
if [ ! -f "${CONFIG_PATH}" ]; then if [ ! -f "${CONFIG_PATH}" ]; then
CONFIG_PATH="/etc/odoo/odoo.conf" CONFIG_PATH="/etc/odoo/odoo.conf"
if [ ! -f "${CONFIG_PATH}" ]; then if [ ! -f "${CONFIG_PATH}" ]; then
echo "Cannot find ERPLibre configuration ${ORIGIN_CONFIG_PATH}, did you install ERPLibre? > make install" echo "${Red}Cannot find${Color_Off} ERPLibre configuration ${ORIGIN_CONFIG_PATH}, did you install ERPLibre? > make install"
exit 1 exit 1
fi fi
fi fi
coverage run -p ./odoo/odoo-bin -c ${CONFIG_PATH} --limit-time-real 99999 --limit-time-cpu 99999 $@ coverage run -p ./odoo/odoo-bin -c "${CONFIG_PATH}" --limit-time-real 99999 --limit-time-cpu 99999 "$@"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error coverage_run.sh" echo "${Red}Error${Color_Off} run.sh"
exit 1 exit 1
fi fi

8
run.sh
View file

@ -1,22 +1,24 @@
#!/usr/bin/env bash #!/usr/bin/env bash
source ./.venv/bin/activate source ./.venv/bin/activate
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
CONFIG_PATH="./config.conf" CONFIG_PATH="./config.conf"
ORIGIN_CONFIG_PATH=CONFIG_PATH ORIGIN_CONFIG_PATH=CONFIG_PATH
if [ ! -f "${CONFIG_PATH}" ]; then if [ ! -f "${CONFIG_PATH}" ]; then
CONFIG_PATH="/etc/odoo/odoo.conf" CONFIG_PATH="/etc/odoo/odoo.conf"
if [ ! -f "${CONFIG_PATH}" ]; then if [ ! -f "${CONFIG_PATH}" ]; then
echo "Cannot find ERPLibre configuration ${ORIGIN_CONFIG_PATH}, did you install ERPLibre? > make install" echo "${Red}Cannot find${Color_Off} ERPLibre configuration ${ORIGIN_CONFIG_PATH}, did you install ERPLibre? > make install"
exit 1 exit 1
fi fi
fi fi
python3 ./odoo/odoo-bin -c ${CONFIG_PATH} --limit-time-real 99999 --limit-time-cpu 99999 --limit-memory-hard=0 "$@" python3 ./odoo/odoo-bin -c "${CONFIG_PATH}" --limit-time-real 99999 --limit-time-cpu 99999 --limit-memory-hard=0 "$@"
# When need more memory RAM for instance by force # When need more memory RAM for instance by force
#python3 ./odoo/odoo-bin -c ${CONFIG_PATH} --limit-time-real 99999 --limit-time-cpu 99999 --limit-memory-soft=8589934592 --limit-memory-hard=10737418240 $@ #python3 ./odoo/odoo-bin -c ${CONFIG_PATH} --limit-time-real 99999 --limit-time-cpu 99999 --limit-memory-soft=8589934592 --limit-memory-hard=10737418240 $@
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error run.sh" echo "${Red}Error${Color_Off} run.sh"
exit 1 exit 1
fi fi

View file

@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# Argument 3 is config # Argument 3 is config
if [[ $# -eq 3 ]]; then if [[ $# -eq 3 ]]; then
./script/addons/check_addons_exist.py -m "$2" -c "$3" ./script/addons/check_addons_exist.py -m "$2" -c "$3"
@ -7,7 +10,7 @@ else
fi fi
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error check_addons_exist.py into coverage_install_addons.sh" echo -e "${Red}Error${Color_Off} check_addons_exist.py into coverage_install_addons.sh"
exit 1 exit 1
fi fi
@ -21,6 +24,6 @@ fi
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error coverage_run.sh into coverage_install_addons.sh" echo -e "${Red}Error${Color_Off} coverage_run.sh into coverage_install_addons.sh"
exit 1 exit 1
fi fi

View file

@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# Argument 3 is config # Argument 3 is config
if [[ $# -eq 3 ]]; then if [[ $# -eq 3 ]]; then
./script/addons/check_addons_exist.py -m "$2" -c "$3" ./script/addons/check_addons_exist.py -m "$2" -c "$3"
@ -7,7 +10,7 @@ else
fi fi
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error check_addons_exist.py into coverage_install_addons_dev.sh" echo -e "${Red}Error${Color_Off} check_addons_exist.py into coverage_install_addons_dev.sh"
exit 1 exit 1
fi fi
@ -21,6 +24,6 @@ fi
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error coverage_run.sh into coverage_install_addons_dev.sh" echo -e "${Red}Error${Color_Off} coverage_run.sh into coverage_install_addons_dev.sh"
exit 1 exit 1
fi fi

View file

@ -1,15 +1,18 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# "$1" code_generator_name # "$1" code_generator_name
./script/database/db_restore.py --database "$1" ./script/database/db_restore.py --database "$1"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/database/db_restore.py into coverage_install_addons_restore_dev.sh" echo -e "${Red}Error${Color_Off} ./script/database/db_restore.py into coverage_install_addons_restore_dev.sh"
exit 1 exit 1
fi fi
./script/addons/coverage_install_addons_dev.sh "$1" "$1" ./script/addons/coverage_install_addons_dev.sh "$1" "$1"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/addons/coverage_install_addons_dev.sh into coverage_install_addons_restore_dev.sh" echo -e "${Red}Error${Color_Off} ./script/addons/coverage_install_addons_dev.sh into coverage_install_addons_restore_dev.sh"
exit 1 exit 1
fi fi

View file

@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# Argument 3 is config # Argument 3 is config
if [[ $# -eq 3 ]]; then if [[ $# -eq 3 ]]; then
./script/addons/check_addons_exist.py -m "$2" -c "$3" ./script/addons/check_addons_exist.py -m "$2" -c "$3"
@ -7,7 +10,7 @@ else
fi fi
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error check_addons_exist.py into install_addons.sh" echo -e "${Red}Error${Color_Off} check_addons_exist.py into install_addons.sh"
exit 1 exit 1
fi fi
@ -21,6 +24,6 @@ fi
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error run.sh into install_addons.sh" echo -e "${Red}Error${Color_Off} run.sh into install_addons.sh"
exit 1 exit 1
fi fi

View file

@ -1,21 +1,24 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# "$1" module_name # "$1" module_name
# "$1" code_generator_template_name # "$1" code_generator_template_name
./script/database/db_restore.py --database "$2" ./script/database/db_restore.py --database "$2"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/database/db_restore.py into install_addons_cg_template_restore_dev.sh" echo -e "${Red}Error${Color_Off} ./script/database/db_restore.py into install_addons_cg_template_restore_dev.sh"
exit 1 exit 1
fi fi
./script/addons/install_addons_dev.sh "$2" "$1" ./script/addons/install_addons_dev.sh "$2" "$1"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/addons/install_addons_dev.sh install module into install_addons_cg_template_restore_dev.sh" echo -e "${Red}Error${Color_Off} ./script/addons/install_addons_dev.sh install module into install_addons_cg_template_restore_dev.sh"
exit 1 exit 1
fi fi
./script/addons/install_addons_dev.sh "$2" "$2" ./script/addons/install_addons_dev.sh "$2" "$2"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/addons/install_addons_dev.sh install template into install_addons_cg_template_restore_dev.sh" echo -e "${Red}Error${Color_Off} ./script/addons/install_addons_dev.sh install template into install_addons_cg_template_restore_dev.sh"
exit 1 exit 1
fi fi

View file

@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# Argument 3 is config # Argument 3 is config
if [[ $# -eq 3 ]]; then if [[ $# -eq 3 ]]; then
./script/addons/check_addons_exist.py -m "$2" -c "$3" ./script/addons/check_addons_exist.py -m "$2" -c "$3"
@ -7,7 +10,7 @@ else
fi fi
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error check_addons_exist.py into install_addons_dev.sh" echo -e "${Red}Error${Color_Off} check_addons_exist.py into install_addons_dev.sh"
exit 1 exit 1
fi fi
@ -22,6 +25,6 @@ fi
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error run.sh into install_addons_dev.sh" echo -e "${Red}Error${Color_Off} run.sh into install_addons_dev.sh"
exit 1 exit 1
fi fi

View file

@ -1,9 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# $1 BD NAME # $1 BD NAME
# $2 file_path # $2 file_path
./script/addons/install_addons.sh "$1" "$(<$2)" ./script/addons/install_addons.sh "$1" "$(<$2)"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/addons/install_addons.sh into install_addons_from_file.sh" echo -e "${Red}Error${Color_Off} ./script/addons/install_addons.sh into install_addons_from_file.sh"
exit 1 exit 1
fi fi

View file

@ -1,15 +1,18 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# "$1" code_generator_name # "$1" code_generator_name
./script/database/db_restore.py --database "$1" ./script/database/db_restore.py --database "$1"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/database/db_restore.py into install_addons_restore_dev.sh" echo -e "${Red}Error${Color_Off} ./script/database/db_restore.py into install_addons_restore_dev.sh"
exit 1 exit 1
fi fi
./script/addons/install_addons_dev.sh "$1" "$1" ./script/addons/install_addons_dev.sh "$1" "$1"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/addons/install_addons_dev.sh into install_addons_restore_dev.sh" echo -e "${Red}Error${Color_Off} ./script/addons/install_addons_dev.sh into install_addons_restore_dev.sh"
exit 1 exit 1
fi fi

View file

@ -1,5 +1,8 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# TODO addons website need to be install before to install the theme # TODO addons website need to be install before to install the theme
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# Argument 3 is config # Argument 3 is config
if [[ $# -eq 3 ]]; then if [[ $# -eq 3 ]]; then
./script/addons/check_addons_exist.py -m "$2" -c "$3" ./script/addons/check_addons_exist.py -m "$2" -c "$3"
@ -8,7 +11,7 @@ else
fi fi
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error check_addons_exist.py into install_addons.sh" echo -e "${Red}Error${Color_Off} check_addons_exist.py into install_addons.sh"
exit 1 exit 1
fi fi
@ -22,6 +25,6 @@ fi
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error run.sh into install_addons_theme.sh" echo -e "${Red}Error${Color_Off} run.sh into install_addons_theme.sh"
exit 1 exit 1
fi fi

View file

@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# Argument 3 is config # Argument 3 is config
if [[ $# -eq 3 ]]; then if [[ $# -eq 3 ]]; then
./script/addons/check_addons_exist.py -m "$2" -c "$3" ./script/addons/check_addons_exist.py -m "$2" -c "$3"
@ -7,7 +10,7 @@ else
fi fi
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error check_addons_exist.py into reinstall_addons_dev.sh" echo -e "${Red}Error${Color_Off} check_addons_exist.py into reinstall_addons_dev.sh"
exit 1 exit 1
fi fi
@ -28,6 +31,6 @@ else
fi fi
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error install_addons_dev.sh into reinstall_addons.sh" echo -e "${Red}Error${Color_Off} install_addons_dev.sh into reinstall_addons.sh"
exit 1 exit 1
fi fi

View file

@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# Argument 3 is config # Argument 3 is config
if [[ $# -eq 3 ]]; then if [[ $# -eq 3 ]]; then
./script/addons/check_addons_exist.py -m "$2" -c "$3" ./script/addons/check_addons_exist.py -m "$2" -c "$3"
@ -7,7 +10,7 @@ else
fi fi
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error check_addons_exist.py into uninstall_addons.sh" echo -e "${Red}Error${Color_Off} check_addons_exist.py into uninstall_addons.sh"
exit 1 exit 1
fi fi

View file

@ -1,4 +1,6 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
echo "Update all on BD '$1'" echo "Update all on BD '$1'"
@ -6,6 +8,6 @@ echo "Update all on BD '$1'"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error run.sh into update_addons_all.sh" echo -e "${Red}Error${Color_Off} run.sh into update_addons_all.sh"
exit 1 exit 1
fi fi

View file

@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# This script will remove mail configuration, remove backup configuration, and force admin user to test/test # This script will remove mail configuration, remove backup configuration, and force admin user to test/test
echo "Update prod to dev on BD '$1'" echo "Update prod to dev on BD '$1'"
@ -6,6 +9,6 @@ echo "Update prod to dev on BD '$1'"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error install_addons.sh into update_prod_to_dev.sh" echo -e "${Red}Error${Color_Off} install_addons.sh into update_prod_to_dev.sh"
exit 1 exit 1
fi fi

View file

@ -84,15 +84,15 @@ check_git() {
fi fi
if [ -z "$output" ]; then if [ -z "$output" ]; then
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then
echo "PASS - ${REP}/${2}" echo -e "${Green}PASS${Color_Off} - ${REP}/${2}"
else else
echo "PASS - ${REP}" echo -e "${Green}PASS${Color_Off} - ${REP}"
fi fi
else else
if [ $# -gt 1 ]; then if [ $# -gt 1 ]; then
echo -e "${Red}FAIL - ${REP}${2}${Color_Off}" echo -e "${Red}FAIL${Color_Off} - ${REP}${2}"
else else
echo -e "${Red}FAIL - ${REP}${Color_Off}" echo -e "${Red}FAIL${Color_Off} - ${REP}"
fi fi
echo -e "${BRed}${output}${Color_Off}" echo -e "${BRed}${output}${Color_Off}"
cd - >/dev/null || exit cd - >/dev/null || exit

View file

@ -4,9 +4,11 @@
# $3 is directory path to check # $3 is directory path to check
# $4 is generated module name separate by , # $4 is generated module name separate by ,
# $5 optional, the config path # $5 optional, the config path
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
if [[ $# -lt 4 ]]; then if [[ $# -lt 4 ]]; then
echo "ERROR, need 4 arguments: 1-database name, 2-list of module to install, 3-directory to check difference, 4-list of generated module" echo -e "${Red}Error${Color_Off}, need 4 arguments: 1-database name, 2-list of module to install, 3-directory to check difference, 4-list of generated module"
exit 1 exit 1
fi fi
@ -16,14 +18,14 @@ if [[ $# -eq 5 ]]; then
./script/addons/coverage_install_addons_dev.sh "$1" "$2" "$5" ./script/addons/coverage_install_addons_dev.sh "$1" "$2" "$5"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/addons/coverage_install_addons_dev.sh ${1} ${2} ${5}" echo -e "${Red}Error${Color_Off} ./script/addons/coverage_install_addons_dev.sh ${1} ${2} ${5}"
exit 1 exit 1
fi fi
else else
./script/addons/coverage_install_addons_dev.sh "$1" "$2" ./script/addons/coverage_install_addons_dev.sh "$1" "$2"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/addons/coverage_install_addons_dev.sh ${1} ${2}" echo -e "${Red}Error${Color_Off} ./script/addons/coverage_install_addons_dev.sh ${1} ${2}"
exit 1 exit 1
fi fi
fi fi
@ -32,7 +34,7 @@ fi
./script/code_generator/test_code_generator_update_module.py -m "$4" -d "$3" --datetime "${INIT_DATETIME}" ./script/code_generator/test_code_generator_update_module.py -m "$4" -d "$3" --datetime "${INIT_DATETIME}"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/code_generator/test_code_generator_update_module.py ${4} ${3}" echo -e "${Red}Error${Color_Off} ./script/code_generator/test_code_generator_update_module.py ${4} ${3}"
exit 1 exit 1
fi fi
@ -54,6 +56,6 @@ echo "TEST ${2}"
./script/code_generator/check_git_change_code_generator.sh "$3" ./script/code_generator/check_git_change_code_generator.sh "$3"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/code_generator/check_git_change_code_generator.sh" echo -e "${Red}Error${Color_Off} ./script/code_generator/check_git_change_code_generator.sh"
exit 1 exit 1
fi fi

View file

@ -4,9 +4,11 @@
# $3 is directory path to check # $3 is directory path to check
# $4 is generated module name separate by , # $4 is generated module name separate by ,
# $5 optional, the config path # $5 optional, the config path
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
if [[ $# -lt 4 ]]; then if [[ $# -lt 4 ]]; then
echo "ERROR, need 4 arguments: 1-database name, 2-list of module to install, 3-directory to check difference, 4-list of generated module" echo -e "${Red}Error${Color_Off}, need 4 arguments: 1-database name, 2-list of module to install, 3-directory to check difference, 4-list of generated module"
exit 1 exit 1
fi fi
@ -16,14 +18,14 @@ if [[ $# -eq 5 ]]; then
./script/addons/install_addons_dev.sh "$1" "$2" "$5" ./script/addons/install_addons_dev.sh "$1" "$2" "$5"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/addons/install_addons_dev.sh ${1} ${2} ${5}" echo -e "${Red}Error${Color_Off} ./script/addons/install_addons_dev.sh ${1} ${2} ${5}"
exit 1 exit 1
fi fi
else else
./script/addons/install_addons_dev.sh "$1" "$2" ./script/addons/install_addons_dev.sh "$1" "$2"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/addons/install_addons_dev.sh ${1} ${2}" echo -e "${Red}Error${Color_Off} ./script/addons/install_addons_dev.sh ${1} ${2}"
exit 1 exit 1
fi fi
fi fi
@ -32,7 +34,7 @@ fi
./script/code_generator/test_code_generator_update_module.py -m "$4" -d "$3" --datetime "${INIT_DATETIME}" ./script/code_generator/test_code_generator_update_module.py -m "$4" -d "$3" --datetime "${INIT_DATETIME}"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/code_generator/test_code_generator_update_module.py ${4} ${3}" echo -e "${Red}Error${Color_Off} ./script/code_generator/test_code_generator_update_module.py ${4} ${3}"
exit 1 exit 1
fi fi
@ -64,6 +66,6 @@ echo "TEST ${2}"
./script/code_generator/check_git_change_code_generator.sh "$3" ./script/code_generator/check_git_change_code_generator.sh "$3"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/code_generator/check_git_change_code_generator.sh" echo -e "${Red}Error${Color_Off} ./script/code_generator/check_git_change_code_generator.sh"
exit 1 exit 1
fi fi

View file

@ -3,6 +3,7 @@ import argparse
import logging import logging
import os import os
import sys import sys
from colorama import Fore, Style
logging.basicConfig(level=logging.DEBUG) logging.basicConfig(level=logging.DEBUG)
_logger = logging.getLogger(__name__) _logger = logging.getLogger(__name__)
@ -75,12 +76,12 @@ def main():
if lst_result_wrong: if lst_result_wrong:
_logger.error( _logger.error(
"FAIL - Some modules wasn't updated, did you execute the code" f"{Fore.RED}FAIL{Style.RESET_ALL} - Some modules wasn't updated,"
f" generator? {lst_result_wrong}" f" did you execute the code generator? {lst_result_wrong}"
) )
return -1 return -1
elif lst_result_good: elif lst_result_good:
_logger.info("SUCCESS - All modules are updated.") _logger.info(f"{Fore.GREEN}SUCCESS{Style.RESET_ALL} - All modules are updated.")
return 0 return 0

View file

@ -4,6 +4,7 @@ import logging
import os import os
import sys import sys
from xml.dom import Node, minidom from xml.dom import Node, minidom
from colorama import Fore, Style
from code_writer import CodeWriter from code_writer import CodeWriter
@ -109,7 +110,7 @@ def main():
mydoc = minidom.parse(config.file) mydoc = minidom.parse(config.file)
if not mydoc: if not mydoc:
print(f"Error, cannot parse {config.file}") print(f"{Fore.RED}Error{Style.RESET_ALL}, cannot parse {config.file}")
sys.exit(1) sys.exit(1)
cw.emit("from lxml.builder import E") cw.emit("from lxml.builder import E")

View file

@ -1,5 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
. ./env_var.sh . ./env_var.sh
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
ARGS="" ARGS=""
IS_RELEASE=false IS_RELEASE=false
@ -50,7 +52,7 @@ echo "Create docker ${ERPLIBRE_DOCKER_PROD_VERSION}"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/docker/docker_build.sh when execute docker_update_version.py" echo -e "${Red}Error${Color_Off} ./script/docker/docker_build.sh when execute docker_update_version.py"
exit 1 exit 1
fi fi

View file

@ -3,6 +3,7 @@ from __future__ import print_function
import argparse import argparse
import os.path import os.path
import shutil import shutil
from colorama import Fore, Style
import yaml # pip install PyYAML import yaml # pip install PyYAML
from agithub.GitHub import GitHub # pip install agithub from agithub.GitHub import GitHub # pip install agithub
@ -169,7 +170,10 @@ def fork_and_clone_repo(
parsed_url.repo parsed_url.repo
].forks.post(**args) ].forks.post(**args)
if status == 404: if status == 404:
print("Error when forking repo %s" % forked_repo) print(
f"{Fore.RED}FAIL{Style.RESET_ALL} when forking repo"
f" {forked_repo}"
)
exit(1) exit(1)
else: else:
print("Forked %s to %s" % (upstream_url, forked_repo["html_url"])) print("Forked %s to %s" % (upstream_url, forked_repo["html_url"]))

View file

@ -3,6 +3,7 @@ import argparse
import logging import logging
import os import os
import sys import sys
from colorama import Fore, Style
from git import Repo from git import Repo
@ -91,8 +92,8 @@ def main():
path2 = value2.get("@path") path2 = value2.get("@path")
if path1 != path2: if path1 != path2:
print( print(
f"WARNING id {i}, path of git are different. " f"{Fore.YELLOW}WARNING{Style.RESET_ALL} id {i}, path of git"
f"Input1 {path1}, input2 {path2}" f" are different. Input1 {path1}, input2 {path2}"
) )
continue continue

View file

@ -5,6 +5,7 @@ import os
import webbrowser import webbrowser
from collections import OrderedDict from collections import OrderedDict
from typing import List from typing import List
from colorama import Fore, Style
import git import git
import xmltodict import xmltodict
@ -307,9 +308,10 @@ class GitTool:
url = repo_root.git.remote("get-url", "origin") url = repo_root.git.remote("get-url", "origin")
except Exception as e: except Exception as e:
print( print(
"WARNING: Missing origin remote, use default url " f"{Fore.YELLOW}WARNING{Style.RESET_ALL}: Missing origin"
f"{DEFAULT_REMOTE_URL}. Suggest to add a remote origin: \n" f" remote, use default url {DEFAULT_REMOTE_URL}. Suggest"
f"> git remote add origin {DEFAULT_REMOTE_URL}" " to add a remote origin: \n> git remote add origin"
f" {DEFAULT_REMOTE_URL}"
) )
url = DEFAULT_REMOTE_URL url = DEFAULT_REMOTE_URL
url, url_https, url_git = self.get_url(url) url, url_https, url_git = self.get_url(url)
@ -694,7 +696,10 @@ class GitTool:
continue continue
line_split = line.split(",") line_split = line.split(",")
if len(line_split) != 4: if len(line_split) != 4:
print(f"Error with line {line}, suppose to have only 4 ','.") print(
f"{Fore.RED}Error{Style.RESET_ALL} with line {line},"
" suppose to have only 4 ','."
)
exit(1) exit(1)
url, path, revision, clone_depth = line_split url, path, revision, clone_depth = line_split
# Validate url # Validate url
@ -962,7 +967,10 @@ class GitTool:
parsed_url.repo parsed_url.repo
].forks.post(**args) ].forks.post(**args)
if status == 404: if status == 404:
print("Error when forking repo %s" % forked_repo) print(
f"{Fore.RED}Error{Style.RESET_ALL} when forking repo"
f" {forked_repo}"
)
exit(1) exit(1)
else: else:
try: try:

View file

@ -13,6 +13,9 @@ EL_HOME_ODOO="${EL_HOME}/odoo"
#EL_MINIMAL_ADDONS="False" #EL_MINIMAL_ADDONS="False"
#EL_INSTALL_NGINX="True" #EL_INSTALL_NGINX="True"
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
./script/generate_config.sh ./script/generate_config.sh
#echo -e "\n---- Install Odoo with addons module ----" #echo -e "\n---- Install Odoo with addons module ----"
@ -57,7 +60,7 @@ if [[ ! -d "${PYENV_VERSION_PATH}" ]]; then
echo -e "\n---- Installing python ${PYTHON_VERSION} with pyenv in ${PYENV_VERSION_PATH} ----" echo -e "\n---- Installing python ${PYTHON_VERSION} with pyenv in ${PYENV_VERSION_PATH} ----"
yes n|pyenv install ${PYTHON_VERSION} yes n|pyenv install ${PYTHON_VERSION}
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error when installing pyenv" echo -e "${Red}Error${Color_Off} when installing pyenv"
exit 1 exit 1
fi fi
fi fi

View file

@ -2,10 +2,13 @@
. ./env_var.sh . ./env_var.sh
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
./script/install/install_locally.sh ./script/install/install_locally.sh
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/install/install_locally.sh" echo -e "${Red}Error${Color_Off} ./script/install/install_locally.sh"
exit 1 exit 1
fi fi
@ -13,7 +16,7 @@ fi
./script/manifest/update_manifest_local_dev.sh ./script/manifest/update_manifest_local_dev.sh
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error manifest update, check git-repo." echo -e "${Red}Error${Color_Off} manifest update, check git-repo."
exit 1 exit 1
fi fi

View file

@ -2,10 +2,13 @@
. ./env_var.sh . ./env_var.sh
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
./script/install/install_locally.sh ./script/install/install_locally.sh
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/install/install_locally.sh" echo -e "${Red}Error${Color_Off} ./script/install/install_locally.sh"
exit 1 exit 1
fi fi
@ -13,6 +16,6 @@ fi
./script/manifest/update_manifest_prod.sh ./script/manifest/update_manifest_prod.sh
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error manifest update, check git-repo." echo -e "${Red}Error${Color_Off} manifest update, check git-repo."
exit 1 exit 1
fi fi

View file

@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# This will format all python file # This will format all python file
# argument 1: directory or file to format # argument 1: directory or file to format
NPROC=$(nproc) NPROC=$(nproc)
@ -6,6 +9,6 @@ source ./script/OCA_maintainer-tools/env/bin/activate
oca-autopep8 -j ${NPROC} --max-line-length 79 -ari $@ oca-autopep8 -j ${NPROC} --max-line-length 79 -ari $@
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error oca-autopep8 format" echo -e "${Red}Error${Color_Off} oca-autopep8 format"
exit 1 exit 1
fi fi

View file

@ -1,10 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# This will format all python file # This will format all python file
# argument 1: directory or file to format # argument 1: directory or file to format
source ./.venv/bin/activate source ./.venv/bin/activate
black -l 79 --preview -t py37 "$@" black -l 79 --preview -t py37 "$@"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error black format" echo -e "${Red}Error${Color_Off} black format"
exit 1 exit 1
fi fi

View file

@ -1,9 +1,12 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# This will format all js,css,html # This will format all js,css,html
# argument 1: directory or file to format # argument 1: directory or file to format
./node_modules/.bin/prettier --tab-width 4 --print-width 120 --no-bracket-spacing --write "$@" ./node_modules/.bin/prettier --tab-width 4 --print-width 120 --no-bracket-spacing --write "$@"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error prettier format" echo -e "${Red}Error${Color_Off} prettier format"
exit 1 exit 1
fi fi

View file

@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
# This will format all xml # This will format all xml
# argument 1: directory or file to format # argument 1: directory or file to format
STR_ARG="'$*'" STR_ARG="'$*'"
@ -12,6 +15,6 @@ else
fi fi
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error prettier-xml format" echo -e "${Red}Error${Color_Off} prettier-xml format"
exit 1 exit 1
fi fi

View file

@ -1,4 +1,7 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
echo " echo "
===> ${@} ===> ${@}
" "
@ -10,6 +13,6 @@ echo "
" "
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error make ${@}" echo -e "${Red}Error${Color_Off} make ${@}"
exit 1 exit 1
fi fi

View file

@ -1,10 +1,13 @@
#!/usr/bin/env bash #!/usr/bin/env bash
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
./.venv/bin/poetry add -vv $(grep -v ";" ./.venv/build_dependency.txt | grep -v "*" ) ./.venv/bin/poetry add -vv $(grep -v ";" ./.venv/build_dependency.txt | grep -v "*" )
# poetry add -vv $(grep -v ";" ./.venv/build_dependency.txt | grep -v "*" | sed 's/==/@^/' ) # poetry add -vv $(grep -v ";" ./.venv/build_dependency.txt | grep -v "*" | sed 's/==/@^/' )
# poetry export -f ./.venv/build_dependency.txt --dev | poetry run -- pip install -r /dev/stdin # poetry export -f ./.venv/build_dependency.txt --dev | poetry run -- pip install -r /dev/stdin
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error ./script/poetry/poetry_add_build_dependency.sh" echo -e "${Red}Error${Color_Off} ./script/poetry/poetry_add_build_dependency.sh"
cat ./.venv/build_dependency.txt cat ./.venv/build_dependency.txt
exit 1 exit 1
fi fi

View file

@ -3,9 +3,9 @@ import argparse
import ast import ast
import logging import logging
import os import os
import sys
from collections import OrderedDict, defaultdict from collections import OrderedDict, defaultdict
from pathlib import Path from pathlib import Path
from colorama import Fore, Style
import iscompatible import iscompatible
import toml import toml
@ -267,8 +267,8 @@ def combine_requirements(config):
] ]
) )
print( print(
f"WARNING - Not compatible {str_versions} - " f"{Fore.YELLOW}WARNING{Style.RESET_ALL} - Not"
f"{str_result_choose}." f" compatible {str_versions} - {str_result_choose}."
) )
elif len(lst_version_requirement) == 1: elif len(lst_version_requirement) == 1:
result = lst_version_requirement[0][0] result = lst_version_requirement[0][0]

View file

@ -15,7 +15,7 @@ from collections import defaultdict
import aioshutil import aioshutil
import git import git
from colorama import Fore from colorama import Fore, Style
new_path = os.path.normpath( new_path = os.path.normpath(
os.path.join(os.path.dirname(__file__), "..", "..") os.path.join(os.path.dirname(__file__), "..", "..")
@ -150,14 +150,14 @@ def check_result(task_list, tpl_result):
status = False status = False
if lst_warning: if lst_warning:
print(f"{Fore.YELLOW}{len(lst_warning)} WARNING{Fore.RESET}") print(f"{Fore.YELLOW}{len(lst_warning)} WARNING{Style.RESET_ALL}")
i = 0 i = 0
for warning in lst_warning: for warning in lst_warning:
i += 1 i += 1
print(f"[{i}]{warning}") print(f"[{i}]{warning}")
if lst_error: if lst_error:
print(f"{Fore.RED}{len(lst_error)} ERROR{Fore.RESET}") print(f"{Fore.RED}{len(lst_error)} ERROR{Style.RESET_ALL}")
i = 0 i = 0
for error in lst_error: for error in lst_error:
i += 1 i += 1
@ -165,13 +165,13 @@ def check_result(task_list, tpl_result):
if lst_error or lst_warning: if lst_error or lst_warning:
str_result = ( str_result = (
f"{Fore.RED}{len(lst_error)} ERROR" f"{Fore.RED}{len(lst_error)} ERROR{Style.RESET_ALL}"
f" {Fore.YELLOW}{len(lst_warning)} WARNING" f" {Fore.YELLOW}{len(lst_warning)} WARNING{Style.RESET_ALL}"
) )
else: else:
str_result = f"{Fore.GREEN}SUCCESS 🍰" str_result = f"{Fore.GREEN}SUCCESS{Style.RESET_ALL} 🍰"
print(f"{Fore.BLUE}Summary TEST {str_result}{Fore.RESET}") print(f"{Fore.BLUE}Summary TEST {str_result}{Style.RESET_ALL}")
return status return status
@ -182,7 +182,11 @@ def print_log(lst_task, tpl_result):
with open(LOG_FILE, "w") as f: with open(LOG_FILE, "w") as f:
for i, task in enumerate(lst_task): for i, task in enumerate(lst_task):
result = tpl_result[i] result = tpl_result[i]
status_str = "PASS" if not result[1] else "FAIL" status_str = (
f"{Fore.GREEN}PASS{Style.RESET_ALL}"
if not result[1]
else f"{Fore.RED}FAIL{Style.RESET_ALL}"
)
f.write( f.write(
f"\nTest execution {i + 1} - {status_str} -" f"\nTest execution {i + 1} - {status_str} -"
f" {task.cr_code.co_name}\n\n" f" {task.cr_code.co_name}\n\n"
@ -206,7 +210,11 @@ def print_log_output_into_dir(tpl_result, output_dir):
f.write(f"{test_name}\n") f.write(f"{test_name}\n")
f.write(f"{time_execution}\n") f.write(f"{time_execution}\n")
f.write(f"{date_now}\n") f.write(f"{date_now}\n")
status_str = "PASS" if not status else "FAIL" status_str = (
f"{Fore.GREEN}PASS{Style.RESET_ALL}"
if not status
else f"{Fore.RED}FAIL{Style.RESET_ALL}"
)
f.write( f.write(
f"\nTest execution {i + 1} - {status_str} - {test_name}\n\n" f"\nTest execution {i + 1} - {status_str} - {test_name}\n\n"
) )
@ -232,7 +240,11 @@ async def run_command(*args, test_name=None):
# Return stdout + stderr, returncode # Return stdout + stderr, returncode
str_out = "\n" + stdout.decode().strip() + "\n" if stdout else "" str_out = "\n" + stdout.decode().strip() + "\n" if stdout else ""
str_err = "\n" + stderr.decode().strip() + "\n" if stderr else "" str_err = "\n" + stderr.decode().strip() + "\n" if stderr else ""
status_str = "FAIL" if process.returncode else "PASS" status_str = (
f"{Fore.RED}FAIL{Style.RESET_ALL}"
if process.returncode
else f"{Fore.GREEN}PASS{Style.RESET_ALL}"
)
if test_name: if test_name:
str_output_init = ( str_output_init = (
f"\n\n{status_str} [{test_name}] [{diff_sec:.3f}s] Execute" f"\n\n{status_str} [{test_name}] [{diff_sec:.3f}s] Execute"
@ -356,8 +368,8 @@ async def test_exec(
if not os.path.exists(path_module_check): if not os.path.exists(path_module_check):
# TODO wrong return # TODO wrong return
return ( return (
f"Error var path_module_check '{path_module_check}' not" f"{Fore.RED}Error{Style.RESET_ALL} var path_module_check"
" exist.", f" '{path_module_check}' not exist.",
-1, -1,
) )
@ -413,8 +425,8 @@ async def test_exec(
if not s_lst_path_tested_module: if not s_lst_path_tested_module:
# TODO wrong return # TODO wrong return
return ( return (
f"Error cannot find module '{path_module_check}' not" f"{Fore.RED}Error{Style.RESET_ALL} cannot find module"
" exist.", f" '{path_module_check}' not exist.",
-1, -1,
) )
else: else:
@ -738,7 +750,8 @@ async def test_exec(
else: else:
test_status += 1 test_status += 1
test_result += ( test_result += (
f"\n\nFAIL - inspect to delete file {lst_file_to_ignore}" f"\n\n{Fore.RED}FAIL{Style.RESET_ALL} - inspect to delete file"
f" {lst_file_to_ignore}"
) )
delta = datetime.datetime.now() - time_init delta = datetime.datetime.now() - time_init
@ -893,7 +906,7 @@ def run_all_test(config) -> bool:
if status: if status:
log_file_print = LOG_FILE log_file_print = LOG_FILE
else: else:
log_file_print = f"{Fore.RED}{LOG_FILE}{Fore.RESET}" log_file_print = f"{Fore.RED}{LOG_FILE}{Style.RESET_ALL}"
if config.output_result_dir: if config.output_result_dir:
print_log_output_into_dir(total_tpl_result, config.output_result_dir) print_log_output_into_dir(total_tpl_result, config.output_result_dir)

View file

@ -1,20 +1,22 @@
#!/usr/bin/env bash #!/usr/bin/env bash
# Usage, ./test.sh -d test_addons_name -i module_name # Usage, ./test.sh -d test_addons_name -i module_name
source ./.venv/bin/activate source ./.venv/bin/activate
Red='\033[0;31m' # Red
Color_Off='\033[0m' # Text Reset
CONFIG_PATH="./config.conf" CONFIG_PATH="./config.conf"
ORIGIN_CONFIG_PATH=CONFIG_PATH ORIGIN_CONFIG_PATH=CONFIG_PATH
if [ ! -f "${CONFIG_PATH}" ]; then if [ ! -f "${CONFIG_PATH}" ]; then
CONFIG_PATH="/etc/odoo/odoo.conf" CONFIG_PATH="/etc/odoo/odoo.conf"
if [ ! -f "${CONFIG_PATH}" ]; then if [ ! -f "${CONFIG_PATH}" ]; then
echo "Cannot find ERPLibre configuration ${ORIGIN_CONFIG_PATH}, did you install ERPLibre? > make install" echo "${Red}Cannot find${Color_Off} ERPLibre configuration ${ORIGIN_CONFIG_PATH}, did you install ERPLibre? > make install"
exit 1 exit 1
fi fi
fi fi
coverage run -p ./odoo/odoo-bin -c ${CONFIG_PATH} --limit-time-real 99999 --limit-time-cpu 99999 --log-level=test --test-enable --stop-after-init $@ coverage run -p ./odoo/odoo-bin -c "${CONFIG_PATH}" --limit-time-real 99999 --limit-time-cpu 99999 --log-level=test --test-enable --stop-after-init "$@"
retVal=$? retVal=$?
if [[ $retVal -ne 0 ]]; then if [[ $retVal -ne 0 ]]; then
echo "Error test.sh" echo "${Red}Error${Color_Off} run.sh"
exit 1 exit 1
fi fi