From ea9be9b2cacfce42da812dece3f77c710995aac3 Mon Sep 17 00:00:00 2001 From: Mathieu Benoit Date: Fri, 23 Feb 2024 13:01:10 -0500 Subject: [PATCH] [FIX] script python: missing color log error --- coverage_run.sh | 8 ++-- run.sh | 8 ++-- script/addons/coverage_install_addons.sh | 7 ++- script/addons/coverage_install_addons_dev.sh | 7 ++- .../coverage_install_addons_restore_dev.sh | 7 ++- script/addons/install_addons.sh | 7 ++- .../install_addons_cg_template_restore_dev.sh | 9 ++-- script/addons/install_addons_dev.sh | 7 ++- script/addons/install_addons_from_file.sh | 5 ++- script/addons/install_addons_restore_dev.sh | 7 ++- script/addons/install_addons_theme.sh | 7 ++- script/addons/reinstall_addons.sh | 7 ++- script/addons/uninstall_addons.sh | 5 ++- script/addons/update_addons_all.sh | 4 +- script/addons/update_prod_to_dev.sh | 5 ++- .../check_git_change_code_generator.sh | 8 ++-- ...overage_install_and_test_code_generator.sh | 12 ++--- .../install_and_test_code_generator.sh | 12 ++--- .../test_code_generator_update_module.py | 7 +-- .../transform_xml_to_code_writer.py | 3 +- script/docker/docker_build.sh | 4 +- script/fork_github_repo/__init__.py | 6 ++- script/git/git_diff_repo_manifest.py | 5 ++- script/git/git_tool.py | 18 +++++--- script/install/install_locally.sh | 5 ++- script/install/install_locally_dev.sh | 7 ++- script/install/install_locally_prod.sh | 7 ++- script/maintenance/autopep8.sh | 5 ++- script/maintenance/black.sh | 5 ++- script/maintenance/prettier.sh | 5 ++- script/maintenance/prettier_xml.sh | 5 ++- script/make.sh | 5 ++- script/poetry/poetry_add_build_dependency.sh | 5 ++- script/poetry/poetry_update.py | 6 +-- script/test/run_parallel_test.py | 45 ++++++++++++------- test.sh | 8 ++-- 36 files changed, 194 insertions(+), 89 deletions(-) diff --git a/coverage_run.sh b/coverage_run.sh index 5c79454..8038a06 100755 --- a/coverage_run.sh +++ b/coverage_run.sh @@ -1,19 +1,21 @@ #!/usr/bin/env bash source ./.venv/bin/activate +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset CONFIG_PATH="./config.conf" ORIGIN_CONFIG_PATH=CONFIG_PATH if [ ! -f "${CONFIG_PATH}" ]; then CONFIG_PATH="/etc/odoo/odoo.conf" 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 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=$? if [[ $retVal -ne 0 ]]; then - echo "Error coverage_run.sh" + echo "${Red}Error${Color_Off} run.sh" exit 1 fi diff --git a/run.sh b/run.sh index 24a8483..15ec721 100755 --- a/run.sh +++ b/run.sh @@ -1,22 +1,24 @@ #!/usr/bin/env bash source ./.venv/bin/activate +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset CONFIG_PATH="./config.conf" ORIGIN_CONFIG_PATH=CONFIG_PATH if [ ! -f "${CONFIG_PATH}" ]; then CONFIG_PATH="/etc/odoo/odoo.conf" 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 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 #python3 ./odoo/odoo-bin -c ${CONFIG_PATH} --limit-time-real 99999 --limit-time-cpu 99999 --limit-memory-soft=8589934592 --limit-memory-hard=10737418240 $@ retVal=$? if [[ $retVal -ne 0 ]]; then - echo "Error run.sh" + echo "${Red}Error${Color_Off} run.sh" exit 1 fi diff --git a/script/addons/coverage_install_addons.sh b/script/addons/coverage_install_addons.sh index 790f49a..48194de 100755 --- a/script/addons/coverage_install_addons.sh +++ b/script/addons/coverage_install_addons.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + # Argument 3 is config if [[ $# -eq 3 ]]; then ./script/addons/check_addons_exist.py -m "$2" -c "$3" @@ -7,7 +10,7 @@ else fi retVal=$? 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 fi @@ -21,6 +24,6 @@ fi retVal=$? 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 fi diff --git a/script/addons/coverage_install_addons_dev.sh b/script/addons/coverage_install_addons_dev.sh index 8363bf0..4a56c86 100755 --- a/script/addons/coverage_install_addons_dev.sh +++ b/script/addons/coverage_install_addons_dev.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + # Argument 3 is config if [[ $# -eq 3 ]]; then ./script/addons/check_addons_exist.py -m "$2" -c "$3" @@ -7,7 +10,7 @@ else fi retVal=$? 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 fi @@ -21,6 +24,6 @@ fi retVal=$? 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 fi diff --git a/script/addons/coverage_install_addons_restore_dev.sh b/script/addons/coverage_install_addons_restore_dev.sh index 93cfb31..8154f89 100755 --- a/script/addons/coverage_install_addons_restore_dev.sh +++ b/script/addons/coverage_install_addons_restore_dev.sh @@ -1,15 +1,18 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + # "$1" code_generator_name ./script/database/db_restore.py --database "$1" retVal=$? 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 fi ./script/addons/coverage_install_addons_dev.sh "$1" "$1" retVal=$? 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 fi diff --git a/script/addons/install_addons.sh b/script/addons/install_addons.sh index af0d7ee..6cbb224 100755 --- a/script/addons/install_addons.sh +++ b/script/addons/install_addons.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + # Argument 3 is config if [[ $# -eq 3 ]]; then ./script/addons/check_addons_exist.py -m "$2" -c "$3" @@ -7,7 +10,7 @@ else fi retVal=$? 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 fi @@ -21,6 +24,6 @@ fi retVal=$? 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 fi diff --git a/script/addons/install_addons_cg_template_restore_dev.sh b/script/addons/install_addons_cg_template_restore_dev.sh index fc614ec..3acb325 100755 --- a/script/addons/install_addons_cg_template_restore_dev.sh +++ b/script/addons/install_addons_cg_template_restore_dev.sh @@ -1,21 +1,24 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + # "$1" module_name # "$1" code_generator_template_name ./script/database/db_restore.py --database "$2" retVal=$? 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 fi ./script/addons/install_addons_dev.sh "$2" "$1" retVal=$? 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 fi ./script/addons/install_addons_dev.sh "$2" "$2" retVal=$? 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 fi diff --git a/script/addons/install_addons_dev.sh b/script/addons/install_addons_dev.sh index f42e7cd..e010cc0 100755 --- a/script/addons/install_addons_dev.sh +++ b/script/addons/install_addons_dev.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + # Argument 3 is config if [[ $# -eq 3 ]]; then ./script/addons/check_addons_exist.py -m "$2" -c "$3" @@ -7,7 +10,7 @@ else fi retVal=$? 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 fi @@ -22,6 +25,6 @@ fi retVal=$? 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 fi diff --git a/script/addons/install_addons_from_file.sh b/script/addons/install_addons_from_file.sh index 6c347e4..0c7278d 100755 --- a/script/addons/install_addons_from_file.sh +++ b/script/addons/install_addons_from_file.sh @@ -1,9 +1,12 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + # $1 BD NAME # $2 file_path ./script/addons/install_addons.sh "$1" "$(<$2)" retVal=$? 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 fi diff --git a/script/addons/install_addons_restore_dev.sh b/script/addons/install_addons_restore_dev.sh index 1d51b44..a321317 100755 --- a/script/addons/install_addons_restore_dev.sh +++ b/script/addons/install_addons_restore_dev.sh @@ -1,15 +1,18 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + # "$1" code_generator_name ./script/database/db_restore.py --database "$1" retVal=$? 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 fi ./script/addons/install_addons_dev.sh "$1" "$1" retVal=$? 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 fi diff --git a/script/addons/install_addons_theme.sh b/script/addons/install_addons_theme.sh index 657767e..1ddf7db 100755 --- a/script/addons/install_addons_theme.sh +++ b/script/addons/install_addons_theme.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash # 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 if [[ $# -eq 3 ]]; then ./script/addons/check_addons_exist.py -m "$2" -c "$3" @@ -8,7 +11,7 @@ else fi retVal=$? 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 fi @@ -22,6 +25,6 @@ fi retVal=$? 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 fi diff --git a/script/addons/reinstall_addons.sh b/script/addons/reinstall_addons.sh index f9c50fd..7926c1e 100755 --- a/script/addons/reinstall_addons.sh +++ b/script/addons/reinstall_addons.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + # Argument 3 is config if [[ $# -eq 3 ]]; then ./script/addons/check_addons_exist.py -m "$2" -c "$3" @@ -7,7 +10,7 @@ else fi retVal=$? 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 fi @@ -28,6 +31,6 @@ else fi retVal=$? 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 fi diff --git a/script/addons/uninstall_addons.sh b/script/addons/uninstall_addons.sh index 564a659..bedb48f 100755 --- a/script/addons/uninstall_addons.sh +++ b/script/addons/uninstall_addons.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + # Argument 3 is config if [[ $# -eq 3 ]]; then ./script/addons/check_addons_exist.py -m "$2" -c "$3" @@ -7,7 +10,7 @@ else fi retVal=$? 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 fi diff --git a/script/addons/update_addons_all.sh b/script/addons/update_addons_all.sh index 9a717b1..7998618 100755 --- a/script/addons/update_addons_all.sh +++ b/script/addons/update_addons_all.sh @@ -1,4 +1,6 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset echo "Update all on BD '$1'" @@ -6,6 +8,6 @@ echo "Update all on BD '$1'" retVal=$? 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 fi diff --git a/script/addons/update_prod_to_dev.sh b/script/addons/update_prod_to_dev.sh index 6b948eb..b3c3554 100755 --- a/script/addons/update_prod_to_dev.sh +++ b/script/addons/update_prod_to_dev.sh @@ -1,4 +1,7 @@ #!/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 echo "Update prod to dev on BD '$1'" @@ -6,6 +9,6 @@ echo "Update prod to dev on BD '$1'" retVal=$? 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 fi diff --git a/script/code_generator/check_git_change_code_generator.sh b/script/code_generator/check_git_change_code_generator.sh index 14a101f..453c81c 100755 --- a/script/code_generator/check_git_change_code_generator.sh +++ b/script/code_generator/check_git_change_code_generator.sh @@ -84,15 +84,15 @@ check_git() { fi if [ -z "$output" ]; then if [ $# -gt 1 ]; then - echo "PASS - ${REP}/${2}" + echo -e "${Green}PASS${Color_Off} - ${REP}/${2}" else - echo "PASS - ${REP}" + echo -e "${Green}PASS${Color_Off} - ${REP}" fi else if [ $# -gt 1 ]; then - echo -e "${Red}FAIL - ${REP}${2}${Color_Off}" + echo -e "${Red}FAIL${Color_Off} - ${REP}${2}" else - echo -e "${Red}FAIL - ${REP}${Color_Off}" + echo -e "${Red}FAIL${Color_Off} - ${REP}" fi echo -e "${BRed}${output}${Color_Off}" cd - >/dev/null || exit diff --git a/script/code_generator/coverage_install_and_test_code_generator.sh b/script/code_generator/coverage_install_and_test_code_generator.sh index 541231e..bf9e745 100755 --- a/script/code_generator/coverage_install_and_test_code_generator.sh +++ b/script/code_generator/coverage_install_and_test_code_generator.sh @@ -4,9 +4,11 @@ # $3 is directory path to check # $4 is generated module name separate by , # $5 optional, the config path +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset 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 fi @@ -16,14 +18,14 @@ if [[ $# -eq 5 ]]; then ./script/addons/coverage_install_addons_dev.sh "$1" "$2" "$5" retVal=$? 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 fi else ./script/addons/coverage_install_addons_dev.sh "$1" "$2" retVal=$? 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 fi fi @@ -32,7 +34,7 @@ fi ./script/code_generator/test_code_generator_update_module.py -m "$4" -d "$3" --datetime "${INIT_DATETIME}" retVal=$? 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 fi @@ -54,6 +56,6 @@ echo "TEST ${2}" ./script/code_generator/check_git_change_code_generator.sh "$3" retVal=$? 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 fi diff --git a/script/code_generator/install_and_test_code_generator.sh b/script/code_generator/install_and_test_code_generator.sh index 57267d8..4d71798 100755 --- a/script/code_generator/install_and_test_code_generator.sh +++ b/script/code_generator/install_and_test_code_generator.sh @@ -4,9 +4,11 @@ # $3 is directory path to check # $4 is generated module name separate by , # $5 optional, the config path +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset 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 fi @@ -16,14 +18,14 @@ if [[ $# -eq 5 ]]; then ./script/addons/install_addons_dev.sh "$1" "$2" "$5" retVal=$? 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 fi else ./script/addons/install_addons_dev.sh "$1" "$2" retVal=$? 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 fi fi @@ -32,7 +34,7 @@ fi ./script/code_generator/test_code_generator_update_module.py -m "$4" -d "$3" --datetime "${INIT_DATETIME}" retVal=$? 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 fi @@ -64,6 +66,6 @@ echo "TEST ${2}" ./script/code_generator/check_git_change_code_generator.sh "$3" retVal=$? 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 fi diff --git a/script/code_generator/test_code_generator_update_module.py b/script/code_generator/test_code_generator_update_module.py index aa385fa..676d696 100755 --- a/script/code_generator/test_code_generator_update_module.py +++ b/script/code_generator/test_code_generator_update_module.py @@ -3,6 +3,7 @@ import argparse import logging import os import sys +from colorama import Fore, Style logging.basicConfig(level=logging.DEBUG) _logger = logging.getLogger(__name__) @@ -75,12 +76,12 @@ def main(): if lst_result_wrong: _logger.error( - "FAIL - Some modules wasn't updated, did you execute the code" - f" generator? {lst_result_wrong}" + f"{Fore.RED}FAIL{Style.RESET_ALL} - Some modules wasn't updated," + f" did you execute the code generator? {lst_result_wrong}" ) return -1 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 diff --git a/script/code_generator/transform_xml_to_code_writer.py b/script/code_generator/transform_xml_to_code_writer.py index cb71a3b..da4429c 100644 --- a/script/code_generator/transform_xml_to_code_writer.py +++ b/script/code_generator/transform_xml_to_code_writer.py @@ -4,6 +4,7 @@ import logging import os import sys from xml.dom import Node, minidom +from colorama import Fore, Style from code_writer import CodeWriter @@ -109,7 +110,7 @@ def main(): mydoc = minidom.parse(config.file) 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) cw.emit("from lxml.builder import E") diff --git a/script/docker/docker_build.sh b/script/docker/docker_build.sh index c27c6e9..8ed2bf2 100755 --- a/script/docker/docker_build.sh +++ b/script/docker/docker_build.sh @@ -1,5 +1,7 @@ #!/usr/bin/env bash . ./env_var.sh +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset ARGS="" IS_RELEASE=false @@ -50,7 +52,7 @@ echo "Create docker ${ERPLIBRE_DOCKER_PROD_VERSION}" retVal=$? 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 fi diff --git a/script/fork_github_repo/__init__.py b/script/fork_github_repo/__init__.py index 604c72a..d581db9 100644 --- a/script/fork_github_repo/__init__.py +++ b/script/fork_github_repo/__init__.py @@ -3,6 +3,7 @@ from __future__ import print_function import argparse import os.path import shutil +from colorama import Fore, Style import yaml # pip install PyYAML from agithub.GitHub import GitHub # pip install agithub @@ -169,7 +170,10 @@ def fork_and_clone_repo( parsed_url.repo ].forks.post(**args) 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) else: print("Forked %s to %s" % (upstream_url, forked_repo["html_url"])) diff --git a/script/git/git_diff_repo_manifest.py b/script/git/git_diff_repo_manifest.py index 5234029..2144d91 100755 --- a/script/git/git_diff_repo_manifest.py +++ b/script/git/git_diff_repo_manifest.py @@ -3,6 +3,7 @@ import argparse import logging import os import sys +from colorama import Fore, Style from git import Repo @@ -91,8 +92,8 @@ def main(): path2 = value2.get("@path") if path1 != path2: print( - f"WARNING id {i}, path of git are different. " - f"Input1 {path1}, input2 {path2}" + f"{Fore.YELLOW}WARNING{Style.RESET_ALL} id {i}, path of git" + f" are different. Input1 {path1}, input2 {path2}" ) continue diff --git a/script/git/git_tool.py b/script/git/git_tool.py index 171786a..85e850d 100644 --- a/script/git/git_tool.py +++ b/script/git/git_tool.py @@ -5,6 +5,7 @@ import os import webbrowser from collections import OrderedDict from typing import List +from colorama import Fore, Style import git import xmltodict @@ -307,9 +308,10 @@ class GitTool: url = repo_root.git.remote("get-url", "origin") except Exception as e: print( - "WARNING: Missing origin remote, use default url " - f"{DEFAULT_REMOTE_URL}. Suggest to add a remote origin: \n" - f"> git remote add origin {DEFAULT_REMOTE_URL}" + f"{Fore.YELLOW}WARNING{Style.RESET_ALL}: Missing origin" + f" remote, use default url {DEFAULT_REMOTE_URL}. Suggest" + " to add a remote origin: \n> git remote add origin" + f" {DEFAULT_REMOTE_URL}" ) url = DEFAULT_REMOTE_URL url, url_https, url_git = self.get_url(url) @@ -694,7 +696,10 @@ class GitTool: continue line_split = line.split(",") 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) url, path, revision, clone_depth = line_split # Validate url @@ -962,7 +967,10 @@ class GitTool: parsed_url.repo ].forks.post(**args) 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) else: try: diff --git a/script/install/install_locally.sh b/script/install/install_locally.sh index 912d9f4..6f7bb0c 100755 --- a/script/install/install_locally.sh +++ b/script/install/install_locally.sh @@ -13,6 +13,9 @@ EL_HOME_ODOO="${EL_HOME}/odoo" #EL_MINIMAL_ADDONS="False" #EL_INSTALL_NGINX="True" +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + ./script/generate_config.sh #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} ----" yes n|pyenv install ${PYTHON_VERSION} if [[ $retVal -ne 0 ]]; then - echo "Error when installing pyenv" + echo -e "${Red}Error${Color_Off} when installing pyenv" exit 1 fi fi diff --git a/script/install/install_locally_dev.sh b/script/install/install_locally_dev.sh index f7deef6..01dbbea 100755 --- a/script/install/install_locally_dev.sh +++ b/script/install/install_locally_dev.sh @@ -2,10 +2,13 @@ . ./env_var.sh +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + ./script/install/install_locally.sh retVal=$? 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 fi @@ -13,7 +16,7 @@ fi ./script/manifest/update_manifest_local_dev.sh retVal=$? 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 fi diff --git a/script/install/install_locally_prod.sh b/script/install/install_locally_prod.sh index 2d23e59..f6ab9ea 100755 --- a/script/install/install_locally_prod.sh +++ b/script/install/install_locally_prod.sh @@ -2,10 +2,13 @@ . ./env_var.sh +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + ./script/install/install_locally.sh retVal=$? 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 fi @@ -13,6 +16,6 @@ fi ./script/manifest/update_manifest_prod.sh retVal=$? 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 fi diff --git a/script/maintenance/autopep8.sh b/script/maintenance/autopep8.sh index 7042148..3245c30 100755 --- a/script/maintenance/autopep8.sh +++ b/script/maintenance/autopep8.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + # This will format all python file # argument 1: directory or file to format NPROC=$(nproc) @@ -6,6 +9,6 @@ source ./script/OCA_maintainer-tools/env/bin/activate oca-autopep8 -j ${NPROC} --max-line-length 79 -ari $@ retVal=$? if [[ $retVal -ne 0 ]]; then - echo "Error oca-autopep8 format" + echo -e "${Red}Error${Color_Off} oca-autopep8 format" exit 1 fi diff --git a/script/maintenance/black.sh b/script/maintenance/black.sh index 630f61a..1ed2812 100755 --- a/script/maintenance/black.sh +++ b/script/maintenance/black.sh @@ -1,10 +1,13 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + # This will format all python file # argument 1: directory or file to format source ./.venv/bin/activate black -l 79 --preview -t py37 "$@" retVal=$? if [[ $retVal -ne 0 ]]; then - echo "Error black format" + echo -e "${Red}Error${Color_Off} black format" exit 1 fi diff --git a/script/maintenance/prettier.sh b/script/maintenance/prettier.sh index 4494ecc..2fc6adf 100755 --- a/script/maintenance/prettier.sh +++ b/script/maintenance/prettier.sh @@ -1,9 +1,12 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + # This will format all js,css,html # argument 1: directory or file to format ./node_modules/.bin/prettier --tab-width 4 --print-width 120 --no-bracket-spacing --write "$@" retVal=$? if [[ $retVal -ne 0 ]]; then - echo "Error prettier format" + echo -e "${Red}Error${Color_Off} prettier format" exit 1 fi diff --git a/script/maintenance/prettier_xml.sh b/script/maintenance/prettier_xml.sh index 853484e..33b810e 100755 --- a/script/maintenance/prettier_xml.sh +++ b/script/maintenance/prettier_xml.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + # This will format all xml # argument 1: directory or file to format STR_ARG="'$*'" @@ -12,6 +15,6 @@ else fi retVal=$? if [[ $retVal -ne 0 ]]; then - echo "Error prettier-xml format" + echo -e "${Red}Error${Color_Off} prettier-xml format" exit 1 fi diff --git a/script/make.sh b/script/make.sh index 577410a..5acc5a6 100755 --- a/script/make.sh +++ b/script/make.sh @@ -1,4 +1,7 @@ #!/usr/bin/env bash +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset + echo " ===> ${@} " @@ -10,6 +13,6 @@ echo " " if [[ $retVal -ne 0 ]]; then - echo "Error make ${@}" + echo -e "${Red}Error${Color_Off} make ${@}" exit 1 fi diff --git a/script/poetry/poetry_add_build_dependency.sh b/script/poetry/poetry_add_build_dependency.sh index 9d859b4..2e91592 100755 --- a/script/poetry/poetry_add_build_dependency.sh +++ b/script/poetry/poetry_add_build_dependency.sh @@ -1,10 +1,13 @@ #!/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 "*" ) # 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 retVal=$? 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 exit 1 fi diff --git a/script/poetry/poetry_update.py b/script/poetry/poetry_update.py index 02d7e6d..04e8cbc 100755 --- a/script/poetry/poetry_update.py +++ b/script/poetry/poetry_update.py @@ -3,9 +3,9 @@ import argparse import ast import logging import os -import sys from collections import OrderedDict, defaultdict from pathlib import Path +from colorama import Fore, Style import iscompatible import toml @@ -267,8 +267,8 @@ def combine_requirements(config): ] ) print( - f"WARNING - Not compatible {str_versions} - " - f"{str_result_choose}." + f"{Fore.YELLOW}WARNING{Style.RESET_ALL} - Not" + f" compatible {str_versions} - {str_result_choose}." ) elif len(lst_version_requirement) == 1: result = lst_version_requirement[0][0] diff --git a/script/test/run_parallel_test.py b/script/test/run_parallel_test.py index b12bc49..d739bb3 100755 --- a/script/test/run_parallel_test.py +++ b/script/test/run_parallel_test.py @@ -15,7 +15,7 @@ from collections import defaultdict import aioshutil import git -from colorama import Fore +from colorama import Fore, Style new_path = os.path.normpath( os.path.join(os.path.dirname(__file__), "..", "..") @@ -150,14 +150,14 @@ def check_result(task_list, tpl_result): status = False 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 for warning in lst_warning: i += 1 print(f"[{i}]{warning}") 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 for error in lst_error: i += 1 @@ -165,13 +165,13 @@ def check_result(task_list, tpl_result): if lst_error or lst_warning: str_result = ( - f"{Fore.RED}{len(lst_error)} ERROR" - f" {Fore.YELLOW}{len(lst_warning)} WARNING" + f"{Fore.RED}{len(lst_error)} ERROR{Style.RESET_ALL}" + f" {Fore.YELLOW}{len(lst_warning)} WARNING{Style.RESET_ALL}" ) 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 @@ -182,7 +182,11 @@ def print_log(lst_task, tpl_result): with open(LOG_FILE, "w") as f: for i, task in enumerate(lst_task): 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"\nTest execution {i + 1} - {status_str} -" 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"{time_execution}\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"\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 str_out = "\n" + stdout.decode().strip() + "\n" if stdout 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: str_output_init = ( 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): # TODO wrong return return ( - f"Error var path_module_check '{path_module_check}' not" - " exist.", + f"{Fore.RED}Error{Style.RESET_ALL} var path_module_check" + f" '{path_module_check}' not exist.", -1, ) @@ -413,8 +425,8 @@ async def test_exec( if not s_lst_path_tested_module: # TODO wrong return return ( - f"Error cannot find module '{path_module_check}' not" - " exist.", + f"{Fore.RED}Error{Style.RESET_ALL} cannot find module" + f" '{path_module_check}' not exist.", -1, ) else: @@ -738,7 +750,8 @@ async def test_exec( else: test_status += 1 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 @@ -893,7 +906,7 @@ def run_all_test(config) -> bool: if status: log_file_print = LOG_FILE 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: print_log_output_into_dir(total_tpl_result, config.output_result_dir) diff --git a/test.sh b/test.sh index 85db1ad..e1573d3 100755 --- a/test.sh +++ b/test.sh @@ -1,20 +1,22 @@ #!/usr/bin/env bash # Usage, ./test.sh -d test_addons_name -i module_name source ./.venv/bin/activate +Red='\033[0;31m' # Red +Color_Off='\033[0m' # Text Reset CONFIG_PATH="./config.conf" ORIGIN_CONFIG_PATH=CONFIG_PATH if [ ! -f "${CONFIG_PATH}" ]; then CONFIG_PATH="/etc/odoo/odoo.conf" 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 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=$? if [[ $retVal -ne 0 ]]; then - echo "Error test.sh" + echo "${Red}Error${Color_Off} run.sh" exit 1 fi