Skip to content
Snippets Groups Projects
Commit 2ac9d0e12a31 authored by Vincent Hatakeyama's avatar Vincent Hatakeyama
Browse files

add option to not fail on errors when installing, changed rm to trap, change a bit output

parent 00843b2a729b
No related branches found
No related tags found
No related merge requests found
......@@ -26,6 +26,7 @@
dbowner=odoo
fi
modules_to_install=$(python -B -c "import ConfigParser ; c = ConfigParser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print ','.join(c.get('odoo_scripts', 'module_list', '').split())")
fail_on_errors=$(python -B -c "import ConfigParser ; c = ConfigParser.ConfigParser() ; c.read('${project_home}/setup.cfg') ; print c.get('odoo_scripts', 'fail_on_errors', 'True')")
# color stuff
autoload colors
......@@ -42,9 +43,9 @@
# argument handling
if [[ $# -gt 0 ]];
then
echo ${YELLOW}INFO ${RESET} - Using database host $1
echo "[${YELLOW}INFO${RESET}] Using database host $1"
PG_HOST=-h$1
ODOO_HOST=--db_host=$1
shift
if [[ $# -gt 0 ]];
then
......@@ -46,9 +47,9 @@
PG_HOST=-h$1
ODOO_HOST=--db_host=$1
shift
if [[ $# -gt 0 ]];
then
echo ${YELLOW}INFO ${RESET} - Using database user $1
echo "[${YELLOW}INFO${RESET}] Using database user $1"
PG_USER=-U$1
ODOO_USER=--db_user=$1
dbowner=$1
......@@ -78,7 +79,11 @@
echo "[${YELLOW}INFO${RESET}] Modules to install: $modules_to_install"
echo "[${YELLOW}INFO${RESET}] Install those modules"
logfile=$(tempfile --suffix=.log)
function clean_logfile() {
rm $logfile
}
trap clean_logfile INT TERM
$here/start $INSTALL_ARGUMENTS -i $modules_to_install -d $dbname --max-cron=0 --stop-after-init $* $ODOO_HOST $ODOO_USER 2>&1 | tee $logfile | sed -e 's/\(.*\) \(INFO\) \(.*\)/\o033[2m\1\o033[22m \o033[32m\o033[7m\2\o033[27m \3\o033[39m/' -e 's/\(.*\) \(DEBUG\) \(.*\)/\o033[2m\1\o033[22m \o033[33m\o033[7m\2\o033[27m \2\o033[39m/' -e 's/\(.*\) \(WARNING\) \(.*\)/\o033[2m\1\o033[22m \o033[33m\o033[7m\2\o033[27m \3\o033[39m/' -e 's/\(.*\) \(ERROR\) \(.*\)/\o033[2m\1\o033[22m \o033[31m\o033[7m\2\o033[27m \3\o033[0m/' -e 's/ FAILED/ \o033[41m\o033[97m\o033[1mFAILED\o033[0m/' -e 's/ FAIL\(.*\)/ \o033[41m\o033[97m\o033[1mFAIL\o033[49m\o033[31m\1\o033[0m/' -e 's/\(.*\) \(CRITICAL\) \(.*\)/\o033[2m\1\o033[22m \o033[33m\o033[7m\2\o033[27m \3\o033[39m/' -e 's/\(.*\) \(TEST\) \(.*\) \(ERROR\)\(.*\)/\o033[2m\1\o033[22m \o033[34m\o033[7m\2\o033[27m \3\o033[0m \o033[41m\o033[97m\o033[1m\4\o033[49m\o033[31m\5\o033[0m/' -e 's/\(.*\) \(TEST\) \(.*\) \(OK\)/\o033[2m\1\o033[22m \o033[34m\o033[7m\2\o033[27m \3\o033[0m \o033[32m\o033[7m\4\o033[27m\o033[39m/' -e 's/\(.*\) \(TEST\) \(.*\)/\o033[2m\1\o033[22m \o033[34m\o033[7m\2\o033[27m \3 \o033[0m/'
start_status=$pipestatus[1]
if [[ $start_status -ne 0 ]];
then
......@@ -81,7 +86,7 @@
$here/start $INSTALL_ARGUMENTS -i $modules_to_install -d $dbname --max-cron=0 --stop-after-init $* $ODOO_HOST $ODOO_USER 2>&1 | tee $logfile | sed -e 's/\(.*\) \(INFO\) \(.*\)/\o033[2m\1\o033[22m \o033[32m\o033[7m\2\o033[27m \3\o033[39m/' -e 's/\(.*\) \(DEBUG\) \(.*\)/\o033[2m\1\o033[22m \o033[33m\o033[7m\2\o033[27m \2\o033[39m/' -e 's/\(.*\) \(WARNING\) \(.*\)/\o033[2m\1\o033[22m \o033[33m\o033[7m\2\o033[27m \3\o033[39m/' -e 's/\(.*\) \(ERROR\) \(.*\)/\o033[2m\1\o033[22m \o033[31m\o033[7m\2\o033[27m \3\o033[0m/' -e 's/ FAILED/ \o033[41m\o033[97m\o033[1mFAILED\o033[0m/' -e 's/ FAIL\(.*\)/ \o033[41m\o033[97m\o033[1mFAIL\o033[49m\o033[31m\1\o033[0m/' -e 's/\(.*\) \(CRITICAL\) \(.*\)/\o033[2m\1\o033[22m \o033[33m\o033[7m\2\o033[27m \3\o033[39m/' -e 's/\(.*\) \(TEST\) \(.*\) \(ERROR\)\(.*\)/\o033[2m\1\o033[22m \o033[34m\o033[7m\2\o033[27m \3\o033[0m \o033[41m\o033[97m\o033[1m\4\o033[49m\o033[31m\5\o033[0m/' -e 's/\(.*\) \(TEST\) \(.*\) \(OK\)/\o033[2m\1\o033[22m \o033[34m\o033[7m\2\o033[27m \3\o033[0m \o033[32m\o033[7m\4\o033[27m\o033[39m/' -e 's/\(.*\) \(TEST\) \(.*\)/\o033[2m\1\o033[22m \o033[34m\o033[7m\2\o033[27m \3 \o033[0m/'
start_status=$pipestatus[1]
if [[ $start_status -ne 0 ]];
then
echo "[${RED}FATAL${RESET}] Cannot install modules (exit ${start_status})"
echo "[${RED} KO ${RESET}] Cannot install modules (exit ${start_status})"
exit $start_status
fi
......@@ -86,6 +91,11 @@
exit $start_status
fi
failed=$(grep ' CRITICAL\| ERROR' $logfile -c)
rm $logfile
if [[ $failed -gt 0 ]];
criticals=$(grep ' CRITICAL' $logfile -c)
errors=$(grep ' ERROR' $logfile -c
if [[ $criticals -gt 0 ]];
then
echo "[${RED} KO ${RESET}] Cannot install modules ($criticals CRITICAL messages found)"
exit 2
fi
if [[ $errors -gt 0 ]];
then
......@@ -91,4 +101,9 @@
then
echo "[${RED}FATAL${RESET}] Cannot install modules (ERROR or CRITICAL found)"
exit 1
if [[ "$fail_on_errors" == "False" ]];
then
echo "[${MAGENTA}WARN${RESET}] Cannot install modules ($errors ERROR messages found)"
else
echo "[${RED} KO ${RESET}] Cannot install modules ($errors ERROR messages found)"
exit 1
fi
fi
......@@ -94,3 +109,3 @@
fi
echo "[${YELLOW}INFO ${RESET}] Run tests on $dbname"
echo "[${YELLOW}INFO${RESET}] Run tests on $dbname"
$here/run_tests $dbname $ODOO_HOST $ODOO_USER $*
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment